@font-face {
  font-family: Vazirmatn;
  src: url("vazirmatn.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --background: #f3f6fa;
  --surface: #ffffff;
  --surface-tint: #eaf5f3;
  --soft: #f7f9fb;
  --line: #dce5ec;
  --text: #172b3b;
  --muted: #576b7c;
  --accent: #007a69;
  --accent-strong: #006253;
  --on-accent: #fff;
  --focus: #168e7a;
  --sky: #60d3be;
  --danger: #a02142;
  --danger-bg: #fff0f4;
  --warning: #76500c;
  --warning-bg: #fff6df;
  --shadow: 0 14px 40px rgba(32, 58, 76, 0.07);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0b141e;
  --surface: #111e2a;
  --surface-tint: #15342f;
  --soft: #142330;
  --line: #263846;
  --text: #eaf4f8;
  --muted: #a3b7c9;
  --accent: #63dbc0;
  --accent-strong: #84ead3;
  --on-accent: #09231e;
  --focus: #79e3cc;
  --sky: #6fe3cb;
  --danger: #ffb5c8;
  --danger-bg: #452334;
  --warning: #f8d38b;
  --warning-bg: #3a3021;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.14);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 280px;
  color: var(--text);
  background: var(--background);
  font: 400 1rem/1.75 Vazirmatn, Tahoma, Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .63; }
input, select, textarea { max-width: 100%; }
[dir="ltr"], bdi { letter-spacing: .005em; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.68rem, 3vw, 2.22rem); line-height: 1.35; font-weight: 780; }
h2 { font-size: 1.22rem; line-height: 1.5; font-weight: 720; }
h3 { margin-block-end: 10px; font-size: 1rem; font-weight: 720; }
.muted, .hint, small, time { color: var(--muted); }
small, .hint { font-size: .86rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 1.14rem; font-weight: 650; white-space: nowrap; width: fit-content; }
.brand strong { font-weight: 850; }
.brand small { display: block; font-size: .78rem; font-weight: 500; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: #123b43;
  color: #a5ffdf;
  font: 800 1.35rem/1 Vazirmatn, sans-serif;
  border: 1px solid rgba(171, 255, 218, .23);
  box-shadow: inset 0 -5px 14px rgba(5, 19, 24, .20);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: .94rem;
  font-weight: 680;
  line-height: 1.5;
  text-align: center;
  white-space: nowrap;
}
.button.primary { background: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-strong); }
.button.secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
.button.secondary:hover, .button.quiet:hover { background: var(--soft); }
.button.quiet { background: transparent; color: var(--muted); }
.button.large { min-height: 50px; }
.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font: 650 1.4rem/1 Tahoma, sans-serif;
}
.icon-button:hover { background: var(--soft); }
.theme-button .sun { display: none; }
[data-theme="dark"] .theme-button .sun { display: inline; }
[data-theme="dark"] .theme-button .moon { display: none; }
.quiet-link { color: var(--accent); font-weight: 650; }
.quiet-link:hover { text-decoration: underline; }

.auth { display: grid; grid-template-columns: minmax(390px, .9fr) minmax(0, 1.1fr); min-height: 100svh; }
.auth-form { min-height: 100svh; display: flex; flex-direction: column; background: var(--surface); padding: clamp(24px, 5.3vw, 78px); }
.auth-top, .app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auth-content { width: min(100%, 405px); margin: auto; padding-block: 48px; }
.auth-lead { margin: 12px 0 26px; }
.auth-help { display: block; margin-block-start: 18px; font-size: .92rem; }
.auth-foot { color: var(--muted); font-size: .87rem; width: fit-content; }
.auth-visual {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 24% 15%, #2b746e 0, transparent 53%),
    radial-gradient(ellipse at 90% 88%, #203750 0, transparent 52%), #0d282f;
  border: 12px solid var(--background);
  border-radius: 30px;
}
.visual-grid {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, #8de7ca 0 1px, transparent 1px 46px),
    repeating-linear-gradient(90deg, #8de7ca 0 1px, transparent 1px 46px);
  opacity: .13;
  mask-image: radial-gradient(ellipse, black 0%, transparent 78%);
}
.visual-envelope {
  position: relative;
  display: grid;
  gap: 13px;
  align-content: center;
  width: min(58%, 320px);
  aspect-ratio: 1.45;
  padding-inline: 14%;
  transform: rotate(-8deg);
  border: 1px solid rgba(156, 242, 214, .57);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(164, 245, 217, .24), rgba(22, 59, 64, .82));
  box-shadow: 0 26px 90px #061d24, inset 0 1px 0 rgba(255, 255, 255, .25);
}
.visual-envelope::before, .visual-envelope::after {
  content: "";
  position: absolute;
  width: 96%;
  height: 100%;
  border-radius: 23px;
  border: 1px solid rgba(164, 245, 217, .24);
  pointer-events: none;
}
.visual-envelope::before { inset: -26px -33px auto auto; }
.visual-envelope::after { inset: auto auto -26px -33px; }
.visual-envelope i { display: block; height: 6px; background: #a9ffe4; border-radius: 12px; opacity: .65; }
.visual-envelope i:nth-child(2) { width: 74%; opacity: .43; }
.visual-envelope i:nth-child(3) { width: 52%; opacity: .27; }
.visual-envelope span { position: absolute; width: 16px; height: 16px; inset: 17px 17px auto auto; border-radius: 50%; background: var(--sky); box-shadow: 0 0 0 7px rgba(117, 233, 202, .12); }

.workspace { min-height: 100svh; display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.side {
  position: sticky;
  top: 0;
  min-width: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 29px 20px 22px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
}
.side .brand { margin-inline-start: 4px; }
.new-message { margin-block-start: 34px; min-height: 50px; }
.navigation { display: grid; gap: 5px; margin-block-start: 28px; }
.navigation a { display: flex; align-items: center; gap: 13px; min-height: 46px; padding: 8px 12px; border-radius: 10px; font-weight: 630; color: var(--muted); }
.navigation a:hover { background: var(--soft); }
.navigation a[aria-current="page"] { background: var(--surface-tint); color: var(--accent-strong); }
.nav-glyph { display: inline-block; position: relative; flex: 0 0 19px; width: 19px; height: 17px; vertical-align: middle; line-height: 1; }
.glyph-inbox, .glyph-boxes { border: 1.75px solid currentColor; border-radius: 4px; }
.glyph-inbox::after, .glyph-boxes::after { content: ""; position: absolute; top: 5px; left: 3px; right: 3px; border-top: 1.75px solid currentColor; }
.glyph-boxes { box-shadow: inset 0 4px transparent, 0 -2px currentColor; }
.glyph-sent { width: 16px; height: 16px; border: 1.75px solid currentColor; border-radius: 3px; }
.glyph-sent::after { content: ""; position: absolute; inset: 3px 4px 5px; border-right: 1.75px solid currentColor; border-bottom: 1.75px solid currentColor; transform: rotate(45deg); }
.glyph-lock { height: 12px; margin-top: 5px; border: 1.75px solid currentColor; border-radius: 4px; }
.glyph-lock::after { content: ""; position: absolute; width: 9px; height: 8px; border: 1.75px solid currentColor; border-bottom: 0; border-radius: 7px 7px 0 0; inset: -7px 3px auto auto; }
.side-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; border-top: 1px solid var(--line); padding-top: 16px; font-size: .81rem; color: var(--muted); overflow-wrap: anywhere; }
.account-dot { flex: 0 0 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.main { min-width: 0; }
.app-header { min-height: 85px; padding: 13px clamp(18px, 4vw, 52px); border-bottom: 1px solid var(--line); background: var(--surface); }
.mobile-brand { display: none; }
.box-picker, .header-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.box-picker select { min-height: 42px; width: min(220px, 100%); }
.box-picker label { color: var(--muted); font-size: .91rem; font-weight: 620; white-space: nowrap; }
.header-actions { margin-inline-start: auto; }
.content { width: min(100%, 1380px); margin-inline: auto; padding: clamp(20px, 4vw, 52px); }
.page-heading { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-block-end: 24px; }
.address { display: inline-block; margin-top: 5px; font-size: .94rem; overflow-wrap: anywhere; }
.surface { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.settings-card { padding: clamp(18px, 3vw, 30px); }
.settings-card > h2 { margin-block-end: 20px; }
.management-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: start; gap: 18px; }
.count { padding: 5px 12px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 100px; font-size: .91rem; color: var(--muted); background: var(--surface); }

input:not([type="hidden"]), textarea, select {
  display: block;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
  color: var(--text);
  padding: 10px 12px;
}
input:not([type="hidden"]):focus, textarea:focus, select:focus { border-color: var(--focus); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; min-height: 180px; }
input[type="file"] { min-height: 38px; padding: 4px; font-size: .83rem; }
input[type="file"]::file-selector-button { color: var(--text); border: 0; padding: 5px; font: inherit; background: transparent; }
.form-stack { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.form-stack label, .attach-control label { margin-block-start: 5px; font-weight: 660; font-size: .94rem; }
.form-stack > .button { margin-block-start: 8px; }
.notice, .errorlist { margin: 0 0 14px; padding: 11px 14px; font-size: .94rem; border-radius: 10px; background: var(--surface-tint); }
.notice.success { color: var(--accent-strong); }
.notice.warning { background: var(--warning-bg); color: var(--warning); }
.notice.error, .errorlist { background: var(--danger-bg); color: var(--danger); }
.errorlist { padding-inline-start: 23px; }
.domain-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.domain-input input { min-width: 0; border: 0; }
.domain-input bdi { color: var(--muted); margin-inline: 9px 11px; font-size: .86rem; white-space: nowrap; }
.search-form { display: flex; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.search-form input[type="search"] { max-width: 410px; }
.empty { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 65px 18px; }
.empty p { color: var(--muted); }
.empty .button { margin-top: 7px; }
.empty-icon { display: grid; place-items: center; width: 65px; height: 65px; margin-bottom: 6px; border-radius: 21px; background: var(--surface-tint); color: var(--accent); }
.empty-icon i { display: block; width: 31px; height: 22px; border: 2px solid currentColor; border-radius: 5px; position: relative; overflow: hidden; }
.empty-icon i::after { content: ""; position: absolute; width: 21px; height: 21px; top: -12px; left: 3px; border: 2px solid currentColor; border-radius: 3px; transform: rotate(45deg); }
.mail-list, .box-list, .activity-list { list-style: none; margin: 0; padding: 0; }
.mail-list li + li, .box-list li + li, .activity-list li + li { border-block-start: 1px solid var(--line); }
.mail-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto 9px;
  align-items: center;
  gap: 13px;
  padding: 14px 17px;
  min-height: 76px;
}
.mail-row:hover { background: var(--soft); }
.mail-row.unread { background: color-mix(in srgb, var(--surface) 62%, var(--surface-tint)); }
.row-avatar { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; border-radius: 12px; background: var(--surface-tint); color: var(--accent-strong); font-weight: 760; }
.row-copy, .box-list li div { min-width: 0; }
.row-copy bdi { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.row-peer { font-size: .93rem; font-weight: 680; }
.row-subject { color: var(--muted); }
.unread .row-subject { font-weight: 720; color: var(--text); }
.row-date { color: var(--muted); font-size: .83rem; text-align: left; }
.unread-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px; }
.box-list li, .activity-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding-block: 11px; }
.box-list li div { flex: 1; overflow-wrap: anywhere; }
.box-list small, .activity-list small { display: block; }
.activity-list time { flex-shrink: 0; font-size: .82rem; }
.compose-card { max-width: 840px; }
.compose-footer { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 18px; }
.attach-control { display: grid; gap: 5px; min-width: 0; max-width: 100%; }
.copy-fields { margin-block: 10px; padding: 12px; border-radius: 10px; background: var(--soft); }
summary { color: var(--accent-strong); cursor: pointer; width: fit-content; font-size: .92rem; font-weight: 650; }
.read-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 7px 18px; }
.read-top h2, .message-body, .envelope dd { overflow-wrap: anywhere; }
.envelope { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1px 16px; border-top: 1px solid var(--line); padding-top: 15px; }
.envelope dt { color: var(--muted); font-weight: 650; }
.envelope dd { margin: 0; }
.message-body { white-space: pre-wrap; line-height: 1.9; padding-block: 18px; margin-block: 16px; border-block: 1px solid var(--line); }
.file-list { display: flex; flex-wrap: wrap; gap: 8px; margin-block-end: 18px; }
.file-list .button { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }

@media (max-width: 880px) {
  .workspace { grid-template-columns: 189px minmax(0, 1fr); }
  .side { padding-inline: 13px; }
  .management-grid { grid-template-columns: 1fr; }
}
@media (max-width: 690px) {
  .auth { grid-template-columns: 1fr; }
  .auth-form { padding: max(21px, env(safe-area-inset-top)) 22px 22px; }
  .auth-content { padding-block: 34px; }
  .auth-visual { display: none; }
  .workspace { display: block; padding-bottom: calc(77px + env(safe-area-inset-bottom)); }
  .side { position: fixed; z-index: 5; inset: auto 0 0; height: auto; padding: 5px 6px max(5px, env(safe-area-inset-bottom)); flex-direction: row; align-items: center; border-inline-end: 0; border-top: 1px solid var(--line); }
  .side .brand, .side-foot { display: none; }
  .new-message { margin: 0; min-height: 54px; min-width: 62px; padding: 4px 7px; flex-direction: column; gap: 2px; font-size: .75rem; }
  .new-message .nav-glyph { font-size: 1.05rem; }
  .navigation { display: flex; flex: 1; min-width: 0; gap: 0; margin: 0; }
  .navigation a { min-height: 54px; flex: 1 1 0; min-width: 0; justify-content: center; text-align: center; flex-direction: column; gap: 4px; padding: 3px 1px; font-size: .75rem; }
  .navigation .nav-glyph { flex: 0 0 auto; }
  .app-header { flex-wrap: wrap; padding: 11px 15px; min-height: auto; }
  .mobile-brand { display: inline-flex; }
  .mobile-brand .brand-mark { flex-basis: 37px; width: 37px; height: 37px; border-radius: 10px; }
  .box-picker { order: 3; flex-basis: 100%; }
  .box-picker select { flex: 1; }
  .content { padding: 20px 13px; }
  .page-heading { margin-block-end: 17px; gap: 10px; }
  .page-heading .button { padding-inline: 10px; }
  .search-form { padding: 10px; }
  .search-form button { padding-inline: 9px; }
  .button.large { min-height: 47px; }
  .empty { padding: 46px 12px; }
  .mail-row { gap: 7px; padding: 12px 9px; min-height: 69px; }
  .row-avatar { width: 32px; height: 32px; flex-basis: 32px; }
  .row-date { max-width: 72px; font-size: .75rem; }
  .row-subject { font-size: .88rem; }
  .reading { padding: 15px; }
  .box-list .button { min-width: 56px; padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
