:root {
  --chch-ink: #212325;
  --chch-orange: #ff7900;
  --chch-paper: #f4f2ee;
  --chch-muted: #565a5d;
  --chch-link: #964500;
  --chch-line: #d9d8d4;
}

body.task-login #layout-content {
  display: flex;
  justify-content: safe center;
  align-items: safe center;
  overflow: auto;
  padding: clamp(16px, 4vw, 56px);
  background: var(--chch-paper);
  color: var(--chch-ink);
  text-align: start;
}
.chch-login {
  width: min(100%, 900px);
  margin: auto;
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  border: 1px solid var(--chch-line);
  border-radius: 20px;
  overflow: hidden;
  background: white;
  box-shadow: 0 16px 55px -28px #24232150;
}
.chch-brand {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 446px;
  padding: 42px 38px;
  background: #242628;
  color: #fff;
}
.chch-brand .chch-wordmark {
  width: 110px;
  height: auto;
  background: #fff;
  border-radius: 5px;
  box-sizing: content-box;
  padding: 9px 12px;
}
.chch-identity { margin: auto 0 3px; z-index: 1; }
.chch-title { margin: 0 0 4px; font-size: clamp(38px, 4.5vw, 58px); font-weight: 700; line-height: 1.08; letter-spacing: -.045em; }
.chch-tag { margin: 0; color: #e4e2df; font-size: 1.08rem; }
.chch-envelope {
  position: absolute;
  z-index: -1;
  right: -54px;
  top: 90px;
  width: 220px;
  height: 138px;
  overflow: hidden;
  border: 2px solid #a85c24;
  border-radius: 12px;
  transform: rotate(-15deg);
}
.chch-envelope i {
  position: absolute;
  width: 73%;
  aspect-ratio: 1;
  border: 2px solid #ff8e35;
  border-radius: 10px;
  top: -69%;
  left: 13.5%;
  transform: rotate(45deg);
}
.chch-panel { align-self: center; padding: 44px clamp(24px, 4.5vw, 56px); }
.chch-panel h1 { margin: 0 0 9px; color: inherit; font-size: clamp(28px, 3vw, 38px); font-weight: 700; letter-spacing: -.035em; line-height: 1.15; }
.chch-hint { margin: 0 0 26px; color: var(--chch-muted); font-size: 1rem; }
body.task-login #login-form { position: static; width: 100%; max-width: none; margin: 0; }
body.task-login #login-form .form-group { margin-bottom: 12px; }
body.task-login #login-form .input-group-text { background: #f2f1ee; color: #57595b; }
body.task-login #login-form .formbuttons { margin: 18px 0 0; }
body.task-login #rcmloginsubmit {
  background: var(--chch-orange);
  border-color: var(--chch-orange);
  color: #231c16;
  font-weight: 700;
  text-transform: none !important; /* Elastic adds Bootstrap's uppercase utility at runtime. */
}
body.task-login #rcmloginsubmit:hover { background: #ff963a; border-color: #ff963a; }
body.task-login #login-footer > .chch-links {
  margin: 22px 0 0;
  padding: 15px 0 0;
  border-top: 1px solid var(--chch-line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  border-radius: 0;
  background: transparent;
}
body.task-login .chch-links a { color: var(--chch-link); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
body.task-login #login-form :focus-visible,
body #taskmenu a:focus-visible { outline: 3px solid #ab5000; outline-offset: 2px; }

body #layout-menu, body #taskmenu { background-color: #25272a; }
body #taskmenu a { color: #f5f4f0; }
body #taskmenu a.selected, body #taskmenu a:hover { color: #fff; background-color: #383a3d; }
body #taskmenu a.selected { box-shadow: inset 3px 0 var(--chch-orange); }
body #taskmenu a.compose { color: var(--chch-orange); }
body #layout-menu #logo { object-fit: contain; }
body #mailboxlist li.selected > a { box-shadow: inset 3px 0 var(--chch-orange); }
html:not(.dark-mode) body #mailboxlist li.selected > a,
html:not(.dark-mode) body #messagelist tr.selected > td { background-color: #fff0e2; color: #242424; }

html.dark-mode body.task-login #layout-content { background: #1b1c1e; color: #f3f2ef; }
html.dark-mode .chch-login { background: #2b2d30; border-color: #484a4c; }
html.dark-mode .chch-hint { color: #cfceca; }
html.dark-mode body.task-login .chch-links a { color: #ffad69; }
html.dark-mode body.task-login #login-footer > .chch-links { border-color: #525456; }
html.dark-mode body.task-login #login-form .input-group-text { background: #383a3d; color: #f3f2ef; }
@media (max-width: 650px) {
  .chch-login { max-width: 440px; grid-template-columns: 1fr; border-radius: 14px; }
  .chch-brand { min-height: 0; padding: 23px 24px; gap: 24px; }
  .chch-brand .chch-wordmark { width: 78px; padding: 6px 9px; }
  .chch-title { font-size: 35px; }
  .chch-tag { font-size: .95rem; }
  .chch-envelope { right: -68px; top: 0; }
  .chch-panel { padding: 26px 24px; }
  .chch-hint { margin-bottom: 20px; }
}
body #mailboxlist .unreadcount { background-color: var(--chch-orange); color: #241e18; }
html:not(.dark-mode) body #message-header a { color: var(--chch-link); }
html.dark-mode body #message-header a { color: #ffad69; }
body.task-login #login-form input:focus-visible { border-color: var(--chch-link); box-shadow: none; }
@media (max-width: 650px) {
  .chch-envelope { width: 145px; height: 88px; right: -52px; top: -2px; }
}

/* Roundcube controls. Keep message contents and the HTML editor canvas independent. */
:root {
  --chch-control-link: #914100;
  --chch-focus: #a74d00;
  --chch-focus-halo: rgba(167, 77, 0, .25);
  --chch-warning: #b42318;
}
html.dark-mode {
  --chch-control-link: #ffae70;
  --chch-focus: #ffae70;
  --chch-focus-halo: rgba(255, 174, 112, .32);
  --chch-warning: #ff8278;
}

body #layout .btn.btn-primary:not(.btn-danger) {
  background-color: var(--chch-orange);
  border-color: var(--chch-orange);
  color: #201810;
}
body #layout .btn.btn-primary:not(.btn-danger):not(:disabled):not(.disabled):is(:hover, :active) {
  background-color: #ff9b48;
  border-color: #ff9b48;
}
body #layout a.btn-link.extwin,
body #layout #message-header a.extwin { color: var(--chch-control-link); }
body #layout a.btn-link.extwin:is(:hover, :focus-visible) { text-decoration: underline !important; }

body #layout #taskmenu a:not(.disabled):is(:hover, :focus-visible) {
  background-color: #39332e;
  color: #ffae70;
}
body #layout #taskmenu a.selected { box-shadow: inset 3px 0 var(--chch-orange); }
body #layout #taskmenu a:focus-visible { outline: 2px solid #ffae70; outline-offset: -3px; }
body #layout :is(#mailboxlist, #settings-menu, #directorylist) li > a:is(:hover, :focus-visible) {
  background-color: #fff0e2;
  color: #34271e;
}
html.dark-mode body #layout :is(#mailboxlist, #settings-menu, #directorylist) li > a:is(:hover, :focus-visible) {
  background-color: #40342a;
  color: #ffdbc0;
}

body #layout .form-control:focus,
body #layout .custom-select:focus,
body #layout .recipient-input.focus,
body #layout .btn:not(.disabled):focus-visible {
  border-color: var(--chch-focus);
  box-shadow: 0 0 0 .18rem var(--chch-focus-halo);
}
body #layout .custom-switch .custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--chch-control-link);
  border-color: var(--chch-control-link);
}
body #layout .custom-switch .custom-control-input:focus-visible ~ .custom-control-label::before {
  outline: 2px solid var(--chch-focus);
  outline-offset: 2px;
}

body #quotadisplay .bar .value { background: var(--chch-orange); opacity: 1; }
body #quotadisplay .bar .value.warning { background: var(--chch-warning); }
body #layout .footer:has(> #chch-storage-actions:not([hidden])) {
  height: auto;
  min-height: 0;
  flex: 0 0 auto;
  flex-flow: column nowrap;
  align-items: stretch;
  padding: 5px 10px;
  line-height: 1.35;
}
body #layout .footer:has(> #chch-storage-actions:not([hidden])) #quotadisplay {
  width: 100%;
  max-width: none;
  padding: 3px 4px;
  box-sizing: border-box;
}
body #chch-storage-actions:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0 .5rem;
  padding: 0 4px;
  font-size: .86rem;
}
#chch-storage-actions .chch-quota-warning { display: none; }
#quotadisplay:has(.value.warning) + #chch-storage-actions .chch-quota-warning {
  display: inline;
  margin-inline-end: auto;
  color: var(--chch-warning);
  font-weight: 700;
}
body #chch-storage-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  color: var(--chch-control-link);
  text-decoration: underline;
  text-underline-offset: 3px;
}
body #chch-storage-actions a:focus-visible { outline: 2px solid var(--chch-focus); outline-offset: 2px; }

body #layout .floating-action-buttons a.button {
  background-color: var(--chch-orange);
  color: #201810;
  box-shadow: 0 2px 9px #0004;
}
body #layout .floating-action-buttons a.button:focus-visible {
  outline: 2px solid var(--chch-focus);
  outline-offset: 3px;
}
html.dark-mode body #layout #mailboxlist li.selected > a,
html.dark-mode body #layout #messagelist tr.selected > td {
  background-color: #40342a;
  color: #fff1e6;
}

:root {
  --chch-selected-bg: #fff0e2;
  --chch-scroll-thumb: #8d725e;
  --chch-scroll-track: #f3efea;
}
html.dark-mode {
  --chch-selected-bg: #40342a;
  --chch-scroll-thumb: #a98c76;
  --chch-scroll-track: #303639;
}

/* Elastic also applies its own colors inside the separate Preferences frame. */
html:root, html:root .scroller, html:root .popupmenu .listing, html:root .select-menu .popover-body, html:root select {
  scrollbar-color: var(--chch-scroll-thumb) var(--chch-scroll-track);
}
html:root:not(.touch) ::-webkit-scrollbar-track { background-color: var(--chch-scroll-track); }
html:root:not(.touch) ::-webkit-scrollbar-thumb { background-color: var(--chch-scroll-thumb); }
@media (forced-colors: active) {
  html:root, html:root .scroller, html:root .popupmenu .listing, html:root .select-menu .popover-body, html:root select { scrollbar-color: auto; }
}

body #layout #taskmenu .action-buttons a.compose { color: var(--chch-orange); }
body #layout #taskmenu .action-buttons a.compose:is(:hover, :focus-visible) { color: #ffae70; }
body #layout .treelist li.selected > .treetoggle,
body #layout .treelist .treetoggle:hover { color: var(--chch-control-link); }
body.task-settings #layout .listing li.selected,
body.task-settings #layout .listing li.selected > a,
body.task-settings #layout .listing tr.selected td,
body.task-settings #layout .listing tr:not(.disabled):hover td,
html:root body.task-settings .select-menu .listing li:is(.selected, :hover) > a {
  background-color: var(--chch-selected-bg);
  color: var(--chch-control-link);
}
body.task-settings .formcontent a:not(.btn),
body.task-settings .formbuttons a.btn-link { color: var(--chch-control-link); }
body.task-settings .formbuttons .btn.btn-primary:not(.btn-danger) {
  background-color: var(--chch-orange);
  border-color: var(--chch-orange);
  color: #201810;
}
body.task-settings .formbuttons .btn.btn-primary:not(.btn-danger):hover { background-color: #ff9b48; }
body.task-settings :is(input[type="radio"], input[type="checkbox"]) { accent-color: var(--chch-focus); }
html:root body.task-settings .custom-switch .custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--chch-control-link);
  border-color: var(--chch-control-link);
}
body.task-settings .custom-switch .custom-control-input:focus-visible ~ .custom-control-label::before {
  box-shadow: 0 0 0 .18rem var(--chch-focus-halo);
  outline: 2px solid var(--chch-focus);
  outline-offset: 2px;
}
body.task-settings :is(.form-control, .custom-select, .btn):focus-visible,
body.task-settings .pretty-select:focus-within { outline: 2px solid var(--chch-focus); outline-offset: 2px; }
body #taskmenu a.chch-language::before { content: "\f1ab"; }

.chch-language-picker { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.chch-panel .chch-language-picker { margin-bottom: 20px; }
body .chch-language-picker :is(a, button) {
  background-color: transparent;
  color: var(--chch-control-link);
  border: 1px solid var(--chch-line);
  border-radius: 4px;
  padding: 5px 10px;
  font: inherit;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
}
body .chch-language-picker :is([aria-current="true"], [aria-pressed="true"]) {
  background-color: var(--chch-selected-bg);
  border-color: var(--chch-focus);
  font-weight: 700;
}
body .chch-language-picker :is(a, button):focus-visible { outline: 2px solid var(--chch-focus); outline-offset: 2px; }
body.task-settings .skinselection img.skinthumbnail[src*="/chchlab/"] {
  object-fit: contain;
  padding: .35rem;
  background-color: #fff;
}
html:root body.task-settings .select-menu .listing li > a:is(.selected, :focus, :hover) {
  color: var(--chch-control-link);
  background-color: var(--chch-selected-bg);
}
html.dark-mode body.task-settings .custom-switch .custom-control-input:checked ~ .custom-control-label::after {
  background-color: #261e19;
}
