.app-shell {
  height: 100dvh;
  min-height: 0;
}
main {
  height: 100dvh;
  min-height: 0;
}
.topbar,
.page-footer,
.mail-controls,
.list-toolbar,
.list-footer {
  flex-shrink: 0;
}
#message-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
button.mobile-menu {
  display: none;
}
.login-top:before {
  content: none;
}
.login-dialog,
.login-dialog[open] {
  width: min(480px, 94vw);
  max-width: 480px;
  max-height: calc(100dvh - 2rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.login-dialog[open] {
  display: block;
}
#login-form {
  gap: 0.75rem;
}
.login-form-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem;
}
.login-top {
  margin-bottom: 1rem;
}
#turnstile-widget {
  min-height: 65px;
  width: 100%;
}
#turnstile-widget[data-widget-size="compact"] {
  min-height: 140px;
}
#turnstile-status {
  font-size: 0.65rem !important;
  margin-top: -0.8rem;
}
#turnstile-status:empty {
  display: none;
}
.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  text-decoration: underline;
}
.turnstile-fallback-link {
  font-size: 0.8rem !important;
  margin-top: -0.5rem;
  padding: 0.7rem 1rem;
  border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line));
  border-radius: 0.625rem;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
  transition:
    background 150ms ease,
    border-color 150ms ease;
}
.turnstile-fallback-link:hover {
  background: color-mix(in srgb, var(--blue) 10%, var(--blue-soft));
  border-color: var(--blue);
}
.legacy-verification-panel[hidden] {
  display: none;
}
.legacy-verification-panel {
  border: 1px solid color-mix(in srgb, var(--blue) 30%, var(--line));
  border-radius: 0.625rem;
  background: var(--blue-soft);
  color: var(--text);
  padding: 0.75rem;
}
.legacy-verification-heading,
.legacy-verification-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}
.legacy-verification-heading {
  margin-bottom: 0.5rem;
}
.legacy-verification-panel .status-pill {
  display: inline-block;
  border-radius: 999px;
  background: var(--surface);
  color: var(--blue);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
}
.legacy-verification-row input {
  background: var(--surface);
  color: var(--text);
  border-color: color-mix(in srgb, var(--blue) 25%, var(--line));
  flex: 1;
  min-width: 0;
}
.legacy-captcha-image-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}
.legacy-captcha-image-button img {
  width: 120px;
  height: 40px;
  border-radius: 0.375rem;
}
.row-check {
  cursor: pointer;
}
.message-open {
  cursor: pointer;
}
.brand-light {
  font-weight: 350;
}
.reader-toolbar {
  flex-wrap: wrap;
}
.drawer::backdrop {
  background: #101b2b22;
  backdrop-filter: blur(1px);
}
@media (max-width: 480px) {
  .topbar .breadcrumb {
    display: none;
  }
}
@media (max-width: 700px) {
  button.mobile-menu {
    display: inline-flex;
  }
  .login-top:before {
    content: none;
  }
  .login-dialog,
  .login-dialog[open] {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .login-form-wrap {
    min-height: 100%;
    justify-content: center;
    padding: 1rem 1.25rem;
  }
  .login-top {
    margin-bottom: 1rem;
  }
  .page-footer > span {
    display: none;
  }
  .page-footer {
    justify-content: flex-end;
    padding: 0.8rem 1rem;
  }
  .reader-toolbar {
    padding: 0.7rem;
  }
  .list-footer {
    display: none;
  }
  .login-form-wrap #login-form {
    gap: 0.75rem;
  }
}
@media (max-width: 700px) and (min-height: 700px) and (max-height: 820px) {
  .login-form-wrap {
    padding: 0.8rem 1.5rem;
  }
  .login-top {
    margin-bottom: 0.75rem;
  }
  .login-form-wrap #login-form {
    gap: 0.65rem;
  }
  .login-submit {
    min-height: 2.6rem;
  }
  #turnstile-widget {
    min-height: 55px;
  }
  #turnstile-widget[data-widget-size="compact"] {
    min-height: 110px;
  }
  .login-note {
    display: none;
  }
}

#search-scope-notice {
  margin: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.5;
}


.signature-settings textarea {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
  resize: vertical;
}


.drawer-close-control {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.drawer-escape-hint {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  padding: 0.15rem 0.35rem;
}
@media (max-width: 360px) {
  .drawer-close-control {
    gap: 0.25rem;
  }
  .drawer-escape-hint {
    font-size: 0.6875rem;
    padding-inline: 0.2rem;
  }
}

@media (max-width: 480px) {
  .reader-drawer .drawer-top {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .reader-drawer .drawer-top > .drawer-context {
    flex-basis: 100%;
  }
  .reader-drawer .drawer-top-actions {
    margin-left: auto;
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

/* iOS Safari zooms focused text controls below 16px. Keep that floor even
   when Small text or a compact label supplies a smaller inherited font. */
@media (max-width: 1024px), (any-pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(
      [type="hidden"]
    ):not([type="range"]):not([type="color"]):not([type="button"]):not(
      [type="submit"]
    ):not([type="reset"]):not([type="image"]),
  textarea,
  select,
  [contenteditable]:not([contenteditable="false"]) {
    font-size: max(16px, 1rem) !important;
  }
}

main {
  --workspace-control-size: 44px;
}
@media (min-width: 701px) {
  main {
    --workspace-control-size: 2.45rem;
  }
  .mail-search-actions .search-box {
    max-width: 17rem;
  }
  .mail-search-actions .search-box input {
    min-width: 0;
    height: 100%;
    padding-block: 0;
  }
}
.workspace-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
  white-space: nowrap;
}
.workspace-actions[hidden] {
  display: none;
}
.workspace-actions #page-create,
.workspace-actions #refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--workspace-control-size);
  height: var(--workspace-control-size);
  min-width: var(--workspace-control-size);
  min-height: var(--workspace-control-size);
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0;
  gap: 0;
}
.workspace-actions #page-create::before {
  content: "+";
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1;
}
.workspace-actions #refresh svg {
  width: 1.25rem;
  height: 1.25rem;
}
@media (min-width: 701px) {
  .workspace-actions #page-create::before {
    font-size: 1.55rem;
  }
  .workspace-actions #refresh svg {
    width: 1.1rem;
    height: 1.1rem;
  }
}
@media (width > 600px) {
  .workspace-actions #page-create {
    width: auto;
    padding-inline: 0.7rem;
    gap: 0.35rem;
    font-size: 0.85rem;
  }
}
@media (max-width: 700px) {
  .page-footer {
    display: none;
  }
  .app-shell[data-active-view="mail"] .mail-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .app-shell[data-active-view="mail"] .mail-controls .search-box {
    max-width: none;
  }
  .app-shell[data-active-view="mail"] .mail-controls .tabs {
    order: 2;
    width: 100%;
  }
}

@media (max-width: 700px) {
  .mail-controls .search-box input {
    min-width: 0;
    height: 100%;
    padding-block: 0;
  }
}

.settings-tabs {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 0.35rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.settings-tabs [role="tab"] {
  flex: 1 0 auto;
  min-height: 2.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 550;
  white-space: nowrap;
}
.settings-tabs [role="tab"][hidden] {
  display: none;
}
.spam-address-form,
.spam-address-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.spam-address-form input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--soft);
  color: var(--text);
}
.spam-address-list {
  padding: 0;
}
.spam-address-list li {
  justify-content: space-between;
  padding-block: 0.35rem;
  border-bottom: 1px solid var(--line);
}
.spam-address-list span {
  overflow-wrap: anywhere;
}
.settings-tabs [role="tab"]:hover {
  background: var(--soft);
  color: var(--text);
}
.settings-tabs [role="tab"][aria-selected="true"] {
  color: var(--blue);
  background: var(--soft);
  border-color: var(--line);
}
.settings-tabs [role="tab"]:focus-visible,
.settings-content [role="tabpanel"]:focus-visible {
  outline: 1px solid var(--muted);
  outline-offset: 2px;
}
.settings-content > [role="tabpanel"] > .setting-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
/* The same application controls move into the mobile drawer without duplicate handlers. */
#desktop-app-navigation {
  min-width: 0;
}
@media (min-width: 701px) {
  #app-navigation {
    display: flex;
    align-items: center;
    gap: 0.3rem;
  }
  #app-navigation .folder {
    width: auto;
    margin: 0;
    gap: 0.5rem;
    padding: 0.65rem 0.8rem;
    white-space: nowrap;
  }
  #app-navigation .folder-name {
    flex: none;
  }
  .topbar {
    gap: 0.75rem;
  }
  .topbar-actions {
    margin-inline-start: auto;
  }
}
@media (min-width: 701px) and (max-width: 1250px) {
  #app-navigation .folder {
    width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.65rem;
    justify-content: center;
  }
  #app-navigation .folder-name {
    display: none;
  }
  .topbar {
    padding-inline: 1rem;
  }
}
@media (max-width: 700px) {
  #desktop-app-navigation {
    display: none;
  }
  #sidebar-app-navigation .folder-name {
    display: block;
  }
  .topbar-actions {
    margin-inline-start: auto;
  }
}
.folder-tree-row {
  display: flex;
  align-items: center;
  min-width: 0;
  padding-inline-start: calc(var(--folder-depth, 0) * 0.85rem);
}
#folders .folder-tree-row .folder {
  flex: 1;
  min-width: 0;
  padding-inline: 0.45rem;
  gap: 0.65rem;
}
.folder-disclosure,
.folder-disclosure-spacer {
  width: 1.35rem;
  min-width: 1.35rem;
}
.folder-disclosure {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 2.5rem;
  color: var(--muted);
  border-radius: 5px;
}
.folder-disclosure svg {
  width: 1rem;
  height: 1rem;
}
.folder-disclosure:hover {
  background: var(--soft);
  color: var(--text);
}
.folder-tree-children[hidden] {
  display: none;
}
.folder-system-separator {
  height: 1px;
  margin: 0.75rem 1rem;
  background: var(--line);
}
#folders .folder-no-select {
  color: var(--muted);
}
/* Folder moves preserve normal touch scrolling until a deliberate long press. */
.folder-tree-row[draggable="true"] { cursor: grab; -webkit-touch-callout: none; user-select: none; }
.folder-dragging .folder-tree-row { transition: background-color .12s ease; }
.folder-drop-target { background: var(--accent-soft, #e6f1fc); border-radius: 8px; box-shadow: inset 0 0 0 1px var(--accent, #1474bc); }
.folder-root-drop { position: sticky; bottom: 0; z-index: 2; background: var(--surface, #fff); padding: 12px; margin: 4px 0 10px; text-align: center; border: 1px dashed var(--muted, #8392a6); border-radius: 8px; font-size: .875rem; }
.new-folder-trigger { width: 100%; border: 0; background: transparent; font-family: inherit; cursor: pointer; text-align: left; }
.new-folder-trigger > [data-icon] { width: 18px; height: 18px; flex: 0 0 18px; }
.new-folder-trigger:disabled { cursor: wait; opacity: .65; }
