:root {
  --ink: #17181b;
  --muted: #5f6670;
  --line: #d4d7dc;
  --paper: #eef0f2;
  --card: #fff;
  --accent: #123a8c;
  --accent-dark: #0c2d6e;
  --danger: #9f1d16;
  --ok: #1b6b3a;
  --shadow: 0 1px 2px rgba(23, 24, 27, 0.06);
  --hover: #f4f5f6;
  --input-bg: #fff;
  --input-border: #c9ced4;
  --track: #dfe3e8;
  --drop-bg: #f7f8f9;
  --drop-over: #eef2f8;
  --icon-bg: #f1f3f5;
  --icon-image: #f3efe6;
  --icon-pdf: #f3eaea;
  --icon-archive: #e8eef4;
  --flash-error-bg: #f8eaea;
  --flash-error-border: #ebcfcf;
  --flash-ok-bg: #e8f3ec;
  --flash-ok-border: #c4ddcd;
  --flash-info-bg: #eef2f8;
  --flash-info-border: #d3dbe8;
  --danger-border: #e3c5c3;
  --badge-bg: #eef2f8;
  --dialog-dim: rgba(23, 24, 27, 0.4);
  --dialog-shadow: 0 12px 40px rgba(23, 24, 27, 0.18);
  --menu-shadow: 0 8px 24px rgba(23, 24, 27, 0.12);
  --focus-ring: 0 0 0 2px rgba(18, 58, 140, 0.15);
  --google-bg: #fff;
  color-scheme: light;
}

html[data-theme="dark"],
html.theme-dark {
  --ink: #e8eaed;
  --muted: #9aa0a6;
  --line: #3c4043;
  --paper: #1a1b1e;
  --card: #2a2b2e;
  --accent: #8ab4f8;
  --accent-dark: #aecbfa;
  --danger: #f28b82;
  --ok: #81c995;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --hover: #3c4043;
  --input-bg: #1a1b1e;
  --input-border: #5f6368;
  --track: #3c4043;
  --drop-bg: #1f2023;
  --drop-over: #243044;
  --icon-bg: #3c4043;
  --icon-image: #3d382c;
  --icon-pdf: #3d2f2f;
  --icon-archive: #2f3843;
  --flash-error-bg: #3d2a2a;
  --flash-error-border: #5c3a3a;
  --flash-ok-bg: #24362c;
  --flash-ok-border: #3d5c48;
  --flash-info-bg: #273246;
  --flash-info-border: #3d4d68;
  --danger-border: #5c3a3a;
  --badge-bg: #273246;
  --dialog-dim: rgba(0, 0, 0, 0.62);
  --dialog-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --focus-ring: 0 0 0 2px rgba(138, 180, 248, 0.28);
  --google-bg: #2a2b2e;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not(.theme-light) {
    --ink: #e8eaed;
    --muted: #9aa0a6;
    --line: #3c4043;
    --paper: #1a1b1e;
    --card: #2a2b2e;
    --accent: #8ab4f8;
    --accent-dark: #aecbfa;
    --danger: #f28b82;
    --ok: #81c995;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --hover: #3c4043;
    --input-bg: #1a1b1e;
    --input-border: #5f6368;
    --track: #3c4043;
    --drop-bg: #1f2023;
    --drop-over: #243044;
    --icon-bg: #3c4043;
    --icon-image: #3d382c;
    --icon-pdf: #3d2f2f;
    --icon-archive: #2f3843;
    --flash-error-bg: #3d2a2a;
    --flash-error-border: #5c3a3a;
    --flash-ok-bg: #24362c;
    --flash-ok-border: #3d5c48;
    --flash-info-bg: #273246;
    --flash-info-border: #3d4d68;
    --danger-border: #5c3a3a;
    --badge-bg: #273246;
    --dialog-dim: rgba(0, 0, 0, 0.62);
    --dialog-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --menu-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --focus-ring: 0 0 0 2px rgba(138, 180, 248, 0.28);
    --google-bg: #2a2b2e;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-body,
.app-body {
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
}

.auth-bg { display: none; }

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.app-bar__start {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0;
  text-decoration: none;
}

.app-brand strong {
  font-weight: 400;
}

.app-logo,
.auth-logo {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  object-fit: cover;
  background: #111;
}

.auth-logo { width: 36px; height: 36px; }

.app-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
  margin-left: auto;
}

.theme-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.theme-pills {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--card);
}

.theme-pill {
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
  border-right: 1px solid var(--line);
  background: transparent;
}

.theme-pill:last-child { border-right: 0; }
.theme-pill:hover { text-decoration: none; color: var(--ink); background: var(--hover); }

.theme-pill--active {
  color: var(--ink);
  background: var(--hover);
}

.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: calc(100dvh - 52px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 40px;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 24px 24px 20px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.auth-kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.auth-brand h1,
.auth-brand h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.2;
}

.auth-lead {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-tabs {
  display: flex;
  gap: 18px;
  margin: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  text-align: center;
  padding: 8px 0 10px;
  color: var(--muted);
  font-weight: 650;
  font-size: 14px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.auth-tab:hover { text-decoration: none; color: var(--ink); }

.auth-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  background: none;
  box-shadow: none;
}

.auth-form { display: grid; gap: 12px; }

.field { display: grid; gap: 5px; font-size: 13px; font-weight: 650; }
.field input {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 10px 11px;
  font: inherit;
  font-weight: 400;
  background: var(--input-bg);
  color: var(--ink);
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.code-input {
  letter-spacing: 0.28em;
  font-size: 20px !important;
  font-weight: 700 !important;
  text-align: center;
}

.auth-forgot, .auth-alt, .auth-hint, .auth-foot {
  color: var(--muted);
  font-size: 13px;
}

.auth-forgot { margin: -2px 0 4px; text-align: right; }
.auth-alt { margin: 14px 0 0; text-align: center; }
.auth-hint { margin: 10px 0 0; text-align: center; line-height: 1.45; }
.auth-foot { margin: 18px 0 0; }

.pixr-family {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 0;
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.pixr-family a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pixr-family a:hover {
  color: var(--ink);
}
.pixr-family__current {
  color: var(--ink);
  font-weight: 650;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lang-switch {
  display: flex;
  justify-content: center;
  margin: 16px 0 0;
}

.lang-switch select {
  max-width: 100%;
  min-width: 160px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.app-user .lang-switch { margin: 0; }

html[dir="rtl"] .auth-forgot { text-align: left; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }

html[data-theme="dark"] .btn-primary,
html.theme-dark .btn-primary {
  color: #0b1a33;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not(.theme-light) .btn-primary {
    color: #0b1a33;
  }
}

.btn-google {
  background: var(--google-bg);
  color: var(--ink);
  border-color: var(--line);
}
.btn-google:hover { background: var(--hover); text-decoration: none; }
.btn-google.is-disabled { opacity: 0.78; cursor: default; pointer-events: none; }

.btn-ghost {
  width: auto;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  padding: 6px 10px;
  font-size: 13px;
}
.btn-ghost:hover { background: var(--hover); text-decoration: none; }

.google-icon { display: flex; }

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.flash {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 13.5px;
  line-height: 1.45;
}
.flash--error { background: var(--flash-error-bg); color: var(--danger); border-color: var(--flash-error-border); }
.flash--success { background: var(--flash-ok-bg); color: var(--ok); border-color: var(--flash-ok-border); }
.flash--info { background: var(--flash-info-bg); color: var(--accent); word-break: break-all; border-color: var(--flash-info-border); }

.cloud-shell {
  width: min(880px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.cloud-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.cloud-hero h1 {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0;
}

.cloud-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.storage-meter {
  min-width: 180px;
  max-width: 240px;
  flex: 1;
}

.storage-meter__track {
  height: 6px;
  background: var(--track);
  border-radius: 99px;
  overflow: hidden;
}

.storage-meter__fill {
  height: 100%;
  background: var(--accent);
}

.cloud-choices {
  display: flex;
  gap: 0;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.cloud-choices.has-admin { display: flex; }

.choice-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 16px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  box-shadow: none;
  margin-bottom: -1px;
}

.choice-card:hover {
  text-decoration: none;
  transform: none;
  color: var(--ink);
  border-color: transparent;
}

.choice-card.is-active {
  color: var(--ink);
  border-bottom-color: var(--ink);
  box-shadow: none;
}

.choice-icon { display: none; }

.choice-card strong {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0;
}

.choice-card span { display: none; }

.cloud-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  padding: 18px 18px 16px;
}

.cloud-panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.cloud-limit {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.dropzone {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 32px 16px;
  border: 1px dashed var(--input-border);
  border-radius: 4px;
  background: var(--drop-bg);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.dropzone.is-over {
  background: var(--drop-over);
  border-color: var(--accent);
}

.dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.dropzone strong { font-size: 15px; }
.dropzone span { color: var(--muted); font-size: 13px; }

.upload-form {
  display: grid;
  gap: 12px;
  position: relative;
}

.upload-error {
  margin: 0;
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 700;
}

.btn-inline { width: auto; justify-self: start; padding-left: 16px; padding-right: 16px; }

.empty-files {
  display: grid;
  gap: 12px;
  justify-items: start;
  color: var(--muted);
}

.file-grid {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.file-card {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: var(--card);
}

.file-card:first-child { border-top: 0; }

.file-card__icon {
  width: 32px;
  height: 32px;
  border-radius: 3px;
  background: var(--icon-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2348505a' stroke-width='1.8'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E") center / 18px no-repeat;
}

html[data-theme="dark"] .file-card__icon,
html.theme-dark .file-card__icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='1.8'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not(.theme-light) .file-card__icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='1.8'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E");
  }
}

.file-card[data-kind="image"] .file-card__icon { background-color: var(--icon-image); }
.file-card[data-kind="pdf"] .file-card__icon { background-color: var(--icon-pdf); }
.file-card[data-kind="archive"] .file-card__icon { background-color: var(--icon-archive); }

.file-card__name {
  display: block;
  font-size: 14px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card__meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.file-card__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.file-card__actions form { margin: 0; }

.btn-tiny {
  width: auto;
  padding: 6px 9px;
  font-size: 12.5px;
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-tiny:hover { background: var(--hover); text-decoration: none; }

.btn-danger {
  background: var(--card);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger:hover { background: var(--flash-error-bg); }

.admin-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 14px;
}

.admin-toolbar form { margin: 0; }

.admin-subtitle {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.admin-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--badge-bg);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.dots-menu {
  position: relative;
  display: inline-block;
}

.dots-menu__btn {
  list-style: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  letter-spacing: 1px;
}

.dots-menu__btn::-webkit-details-marker { display: none; }
.dots-menu > summary { list-style: none; }

.dots-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 230px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  box-shadow: var(--menu-shadow);
}

.dots-menu__panel form {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
}

.dots-menu__panel form:last-child { margin-bottom: 0; }

.dots-menu__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.dots-menu__panel select {
  width: 100%;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--ink);
}

.pixr-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.pixr-dialog[hidden] { display: none; }

.pixr-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: var(--dialog-dim);
}

.pixr-dialog__card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  padding: 18px 18px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--dialog-shadow);
}

.pixr-dialog__card h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 400;
}

.pixr-dialog__card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.pixr-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.pixr-dialog-open,
body.mail-nav-open { overflow: hidden; }

.cookie-dialog { z-index: 90; }

.cookie-dialog__card {
  width: min(500px, 100%);
}

.cookie-dialog__list {
  margin: 0 0 16px;
  padding-left: 1.15em;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.cookie-dialog__list li + li { margin-top: 8px; }

.cookie-dialog__actions {
  justify-content: space-between;
}

.cookie-dialog__actions form { margin: 0; }

@media (max-width: 720px) {
  .cloud-hero { flex-direction: column; align-items: stretch; }
  .storage-meter { max-width: none; }
  .file-card {
    grid-template-columns: 32px 1fr;
  }
  .file-card__actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
  .app-user span { display: none; }
  .app-user .lang-switch select { min-width: 0; width: 7.5rem; }
  .app-bar { padding: 8px 12px; }
  .theme-pill { padding: 5px 7px; }
}

@media (max-width: 520px) {
  .auth-card { padding: 18px 16px 16px; }
  .app-brand strong { display: none; }
}

.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 10px 11px;
  font: inherit;
  font-weight: 400;
  background: var(--input-bg);
  color: var(--ink);
}
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.field textarea { min-height: 180px; resize: vertical; }

.mail-app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.mail-nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
}

.mail-search--bar {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 560px;
}

.mail-search input {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 8px 10px;
  font: inherit;
  background: var(--input-bg);
  color: var(--ink);
}

.mail-nav-backdrop {
  display: none;
}

.mail-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  width: 100%;
}

.mail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  padding: 14px 12px 16px;
  background: var(--card);
  border-right: 1px solid var(--line);
}

.mail-nav__compose {
  margin: 0 0 10px;
}

.mail-nav__folders {
  display: grid;
  gap: 2px;
  overflow: auto;
}

.mail-nav__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 4px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.mail-nav__link:hover {
  background: var(--hover);
  text-decoration: none;
}

.mail-nav__link.is-active {
  background: var(--hover);
}

.mail-nav__count {
  color: var(--muted);
  font-size: 12px;
}

.mail-nav__storage {
  margin-top: auto;
  padding-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.mail-nav__storage .storage-meter {
  min-width: 0;
  max-width: none;
  margin-top: 8px;
}

.mail-main {
  min-width: 0;
  padding: 18px 20px 28px;
}

.mail-main__head {
  margin: 0 0 14px;
}

.mail-main__head h1 {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0;
}

.mail-main__head p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.mail-split {
  display: grid;
  grid-template-columns: minmax(260px, 38%) 1fr;
  min-height: calc(100dvh - 180px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  overflow: hidden;
}

.mail-list {
  border-right: 1px solid var(--line);
  min-height: 0;
  overflow: auto;
}

.mail-empty { padding: 24px 16px; }

.mail-row {
  display: grid;
  grid-template-columns: minmax(0, 160px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.mail-row:hover { background: var(--hover); text-decoration: none; }
.mail-row.is-active { background: var(--flash-info-bg); }
.mail-row.is-unread .mail-row__from,
.mail-row.is-unread .mail-row__subject { font-weight: 700; }

.mail-row__from,
.mail-row__subject {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-row__meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.mail-read {
  min-height: 0;
  overflow: auto;
  padding: 18px 18px 24px;
}

.mail-read__back {
  display: none;
  margin: 0 0 12px;
}

.mail-read__empty {
  margin: 48px 0 0;
  color: var(--muted);
  text-align: center;
}

.mail-read__head h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.mail-read__head p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.mail-read__actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.mail-read__actions form { margin: 0; }

.mail-read__body {
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.mail-read__body pre {
  white-space: pre-wrap;
  font: inherit;
  margin: 0;
}

.file-card[data-kind="mail"] .file-card__icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2348505a' stroke-width='1.8'%3E%3Cpath d='M4 6h16v12H4z'/%3E%3Cpath d='m4 7 8 6 8-6'/%3E%3C/svg%3E");
}

.compose-form { max-width: 720px; }

.mail-compose-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .mail-nav-toggle { display: inline-flex; }
  .mail-search--bar {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .mail-layout {
    grid-template-columns: 1fr;
  }
  .mail-nav {
    position: fixed;
    z-index: 45;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    box-shadow: var(--menu-shadow);
    padding-top: 16px;
  }
  html[dir="rtl"] .mail-nav {
    left: auto;
    right: 0;
    transform: translateX(105%);
  }
  body.mail-nav-open .mail-nav {
    transform: none;
  }
  .mail-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 44;
    background: var(--dialog-dim);
  }
  body.mail-nav-open .mail-nav-backdrop {
    display: block;
  }
  .mail-main {
    padding: 14px 12px 24px;
  }
  .mail-main__head h1 { font-size: 22px; }
  .mail-split {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 210px);
  }
  .mail-split:not(.is-open) .mail-read { display: none; }
  .mail-split.is-open .mail-list { display: none; }
  .mail-list {
    border-right: 0;
  }
  .mail-row {
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    padding: 14px;
  }
  .mail-row__subject {
    grid-column: 1 / -1;
  }
  .mail-read { max-height: none; }
  .mail-read__back { display: inline-flex; }
  .mail-read__actions .btn-tiny,
  .mail-nav-toggle {
    min-height: 36px;
  }
  .mail-compose-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 0 -18px -16px;
    padding: 10px 18px 12px;
    background: var(--card);
    border-top: 1px solid var(--line);
  }
  .mail-compose-actions .btn-primary {
    flex: 1;
    width: auto;
  }
}

