@layer reset, tokens, base, layout, components, utilities, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { min-width: 320px; min-height: 100%; }
  body, h1, h2, h3, p, ul, ol, fieldset { margin: 0; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { border: 0; }
  img, svg { display: block; }
  a { color: inherit; text-decoration: none; }
  [hidden] { display: none !important; }
}

@layer tokens {
  :root {
    color-scheme: light;
    --font-ui: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --bg: #f4f7fb;
    --bg-soft: #edf2f9;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-hover: #edf3fb;
    --surface-active: #e1ebf8;
    --surface-subtle: #f7f9fc;
    --overlay: rgba(17, 26, 41, .44);
    --text: #162033;
    --text-soft: #536176;
    --text-muted: #5f6d82;
    --border: #dce3ed;
    --border-strong: #c8d2df;
    --accent: #2563eb;
    --accent-strong: #174cc6;
    --accent-soft: #e8f0ff;
    --accent-ink: #123a99;
    --on-accent: #ffffff;
    --brand-a: #2456d8;
    --brand-b: #47a4f3;
    --success: #18794e;
    --success-soft: #e7f7ef;
    --warning: #9a5b00;
    --warning-soft: #fff2d5;
    --danger: #c92a3b;
    --danger-soft: #ffeaed;
    --focus: #2f7df4;
    --shadow-sm: 0 1px 2px rgba(19, 35, 59, .07), 0 1px 4px rgba(19, 35, 59, .04);
    --shadow-md: 0 10px 30px rgba(22, 34, 53, .12), 0 2px 8px rgba(22, 34, 53, .08);
    --shadow-lg: 0 24px 70px rgba(15, 27, 46, .22), 0 8px 24px rgba(15, 27, 46, .12);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-xl: 30px;
    --header-height: 68px;
    --nav-width: 250px;
    --row-height: 47px;
    --motion: 160ms cubic-bezier(.2, .7, .2, 1);
  }

  html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #101620;
    --bg-soft: #171f2b;
    --surface: #18212e;
    --surface-raised: #202b3a;
    --surface-hover: #243143;
    --surface-active: #293c55;
    --surface-subtle: #141c27;
    --overlay: rgba(2, 6, 12, .7);
    --text: #eff4fb;
    --text-soft: #b9c5d5;
    --text-muted: #8f9db1;
    --border: #2e3b4d;
    --border-strong: #3c4b60;
    --accent: #78a9ff;
    --accent-strong: #9cc0ff;
    --accent-soft: #20385e;
    --accent-ink: #d3e3ff;
    --on-accent: #10264a;
    --brand-a: #4f7ff1;
    --brand-b: #57b6ff;
    --success: #6dd5a6;
    --success-soft: #173d31;
    --warning: #f4c56d;
    --warning-soft: #493515;
    --danger: #ff8490;
    --danger-soft: #52232a;
    --focus: #8bb7ff;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .25);
    --shadow-md: 0 12px 34px rgba(0, 0, 0, .34), 0 2px 8px rgba(0, 0, 0, .26);
    --shadow-lg: 0 28px 80px rgba(0, 0, 0, .54), 0 8px 26px rgba(0, 0, 0, .3);
  }

  @media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
      color-scheme: dark;
      --bg: #101620;
      --bg-soft: #171f2b;
      --surface: #18212e;
      --surface-raised: #202b3a;
      --surface-hover: #243143;
      --surface-active: #293c55;
      --surface-subtle: #141c27;
      --overlay: rgba(2, 6, 12, .7);
      --text: #eff4fb;
      --text-soft: #b9c5d5;
      --text-muted: #8f9db1;
      --border: #2e3b4d;
      --border-strong: #3c4b60;
      --accent: #78a9ff;
      --accent-strong: #9cc0ff;
      --accent-soft: #20385e;
      --accent-ink: #d3e3ff;
      --on-accent: #10264a;
      --brand-a: #4f7ff1;
      --brand-b: #57b6ff;
      --success: #6dd5a6;
      --success-soft: #173d31;
      --warning: #f4c56d;
      --warning-soft: #493515;
      --danger: #ff8490;
      --danger-soft: #52232a;
      --focus: #8bb7ff;
      --shadow-sm: 0 1px 3px rgba(0, 0, 0, .25);
      --shadow-md: 0 12px 34px rgba(0, 0, 0, .34), 0 2px 8px rgba(0, 0, 0, .26);
      --shadow-lg: 0 28px 80px rgba(0, 0, 0, .54), 0 8px 26px rgba(0, 0, 0, .3);
    }
  }
}

@layer base {
  body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.45;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }

  ::selection { color: var(--text); background: color-mix(in srgb, var(--accent) 30%, transparent); }
  :focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 66%, transparent); outline-offset: 2px; }
  button, a, select { -webkit-tap-highlight-color: transparent; }
  button { cursor: pointer; }
  button:disabled { cursor: default; opacity: .42; }
  input, select, textarea {
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
  }
  input, select { min-height: 42px; padding: 9px 12px; }
  textarea { padding: 12px; resize: vertical; }
  input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 65%, var(--text)); }
  input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 20%, transparent); }
  input[type="checkbox"], input[type="radio"] { min-height: auto; accent-color: var(--accent); }
  h1 { font-size: clamp(1.42rem, 2vw, 1.8rem); line-height: 1.15; letter-spacing: -.025em; }
  h2 { font-size: 1.2rem; line-height: 1.25; letter-spacing: -.015em; }
  h3 { font-size: 1rem; line-height: 1.3; }
  small { color: var(--text-muted); }
  .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
  .icon--small { width: 16px; height: 16px; }
}

@layer layout {
  .app-view {
    display: grid;
    grid-template: var(--header-height) minmax(0, 1fr) / var(--nav-width) minmax(0, 1fr);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }
  .topbar { grid-area: 1 / 1 / 2 / 3; }
  .navigation { grid-area: 2 / 1 / 3 / 2; }
  .main-content { grid-area: 2 / 2 / 3 / 3; min-width: 0; min-height: 0; }
  .app-view.nav-collapsed { --nav-width: 82px; }

  .topbar {
    position: relative;
    z-index: 40;
    display: grid;
    grid-template-columns: minmax(220px, var(--nav-width)) minmax(300px, 720px) minmax(210px, 1fr);
    align-items: center;
    gap: 16px;
    padding: 8px 18px 8px 12px;
    background: var(--bg);
  }
  .topbar__brand, .topbar__actions, .brand-lockup, .profile-button { display: flex; align-items: center; }
  .topbar__brand { gap: 7px; min-width: 0; }
  .topbar__actions { justify-content: flex-end; gap: 4px; }
  .brand-lockup { gap: 10px; padding: 3px; min-width: 0; border-radius: 12px; }
  .brand-name { font-size: 1.3rem; font-weight: 620; letter-spacing: -.025em; color: var(--text-soft); }

  .navigation {
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 8px 12px 18px 0;
    overflow: hidden auto;
    background: var(--bg);
    transition: width var(--motion);
  }
  .main-content {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) 0 0 0;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .mail-workspace { height: 100%; display: flex; flex-direction: column; }
  .mail-split { min-height: 0; flex: 1; display: grid; overflow: hidden; }
  .mail-split.reading-right { grid-template-columns: minmax(390px, 44%) minmax(440px, 1fr); }
  .mail-split.reading-bottom { grid-template-rows: minmax(220px, 45%) minmax(260px, 1fr); }
  .mail-split.reading-off { grid-template-columns: 1fr; }
  .mail-split.reading-off .reading-placeholder { display: none; }
  .message-list-panel, .reading-pane, .reading-placeholder { min-width: 0; min-height: 0; }
  .message-list-panel { overflow: auto; border-right: 1px solid var(--border); }
  .reading-bottom .message-list-panel { border-right: 0; border-bottom: 1px solid var(--border); }
  .reading-pane { overflow: auto; background: var(--surface); }
  .reading-placeholder { display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--text-muted); background: var(--surface-subtle); }

  .settings-view, .newsletters-view { height: 100%; padding: 30px clamp(18px, 3vw, 48px) 48px; overflow: auto; background: var(--surface-subtle); }
  .settings-layout { display: grid; grid-template-columns: 210px minmax(0, 840px); gap: 28px; max-width: 1120px; }
  .settings-content { min-width: 0; }
  .settings-section { display: grid; gap: 18px; }
  .newsletter-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 18px; max-width: 1240px; }
}

@layer components {
  .skip-link { position: fixed; z-index: 1000; top: 8px; left: 8px; transform: translateY(-150%); padding: 10px 14px; border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-md); }
  .skip-link:focus { transform: translateY(0); }
  .boot-view { position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; justify-items: center; gap: 20px; background: var(--bg); }
  .brand-orbit { display: grid; place-items: center; flex: none; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--brand-b), var(--brand-a)); box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 6px 16px rgba(37, 99, 235, .2); }
  .brand-orbit img { width: 64%; height: 64%; filter: brightness(0) invert(1); }
  .brand-orbit--boot { width: 72px; height: 72px; animation: boot-float 1.8s ease-in-out infinite alternate; }
  .brand-orbit--login { width: 70px; height: 70px; }
  .brand-orbit--header { width: 35px; height: 35px; }
  @keyframes boot-float { to { transform: translateY(-4px) rotate(3deg); } }

  .spinner { display: none; width: 17px; height: 17px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .72s linear infinite; }
  .spinner--brand { display: block; color: var(--accent); }
  @keyframes spin { to { transform: rotate(360deg); } }

  .login-view {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    overflow: auto;
    background:
      radial-gradient(circle at 28% 20%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 34%),
      radial-gradient(circle at 78% 75%, color-mix(in srgb, var(--brand-b) 7%, transparent), transparent 30%),
      var(--bg);
  }
  .login-card { width: min(100%, 390px); padding: 34px 38px 38px; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 28px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 26px 80px rgba(36, 55, 85, .1); backdrop-filter: blur(20px); }
  .login-brand { display: grid; justify-items: center; gap: 14px; margin-bottom: 34px; }
  .login-wordmark { font-size: 1.6rem; font-weight: 620; letter-spacing: .055em; color: var(--text-soft); }
  .login-form { display: grid; gap: 17px; }
  .field--floating { position: relative; }
  .field--floating input { width: 100%; height: 54px; padding: 20px 15px 6px; border-radius: 13px; background: var(--surface-subtle); }
  .field--floating label { position: absolute; top: 16px; left: 16px; color: var(--text-muted); pointer-events: none; transform-origin: left top; transition: transform var(--motion), color var(--motion); }
  .login-card .field--floating label { color: var(--text-soft); }
  .field--floating input:focus + label, .field--floating input:not(:placeholder-shown) + label { color: var(--accent); transform: translateY(-9px) scale(.78); }
  .field--password input { padding-right: 52px; }
  .password-toggle { position: absolute; top: 7px; right: 7px; }
  .form-message { padding: 10px 12px; border-radius: 10px; color: var(--danger); background: var(--danger-soft); font-size: .9rem; }
  .login-submit { min-height: 49px; margin-top: 2px; }
  .login-submit.is-loading .button-label { display: none; }
  .login-submit.is-loading .spinner { display: block; }
  .login-theme { position: fixed; right: 22px; bottom: 22px; display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--border); border-radius: 50%; color: var(--text-soft); background: var(--surface); box-shadow: var(--shadow-sm); }

  .icon-button, .row-icon { display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: var(--text-soft); background: transparent; transition: color var(--motion), background var(--motion), transform var(--motion); }
  .icon-button { width: 42px; height: 42px; }
  .icon-button--small { width: 32px; height: 32px; }
  .icon-button:hover, .row-icon:hover { color: var(--text); background: var(--surface-hover); }
  .icon-button:active, .row-icon:active { transform: scale(.94); }
  .primary-button, .secondary-button, .quiet-button, .text-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border-radius: 10px; font-weight: 650; transition: background var(--motion), transform var(--motion), box-shadow var(--motion); }
  .primary-button { padding: 9px 17px; color: var(--on-accent); background: var(--accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 24%, transparent); }
  .primary-button:hover { background: var(--accent-strong); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent); }
  .secondary-button { padding: 8px 14px; border: 1px solid var(--border-strong); color: var(--accent); background: var(--surface); }
  .secondary-button:hover { background: var(--surface-hover); }
  .quiet-button { padding: 8px 12px; color: var(--text-soft); background: var(--surface-subtle); }
  .text-button { min-height: 34px; padding: 5px 8px; color: var(--accent); background: transparent; }
  .text-button:hover { background: var(--accent-soft); }
  .primary-button:active, .secondary-button:active, .quiet-button:active { transform: translateY(1px); }

  .search-box { position: relative; display: flex; align-items: center; height: 48px; border: 1px solid transparent; border-radius: 15px; background: var(--bg-soft); transition: background var(--motion), box-shadow var(--motion), border var(--motion); }
  .search-box:focus-within { border-color: var(--border); background: var(--surface); box-shadow: var(--shadow-md); }
  .search-box input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: 0; box-shadow: none; }
  .search-box input:focus { border: 0; outline: 0; }
  .search-shortcut { padding: 2px 7px; border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); background: var(--surface); font-size: .78rem; }
  .popover { position: fixed; z-index: 90; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); box-shadow: var(--shadow-lg); }
  .search-options { position: absolute; top: calc(100% + 8px); right: 0; left: 0; width: min(630px, calc(100vw - 28px)); padding: 20px; }
  .popover__footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

  .profile-button { gap: 8px; min-width: 0; padding: 3px 7px 3px 4px; border: 1px solid transparent; border-radius: 24px; color: var(--text-soft); background: transparent; }
  .profile-button:hover, .profile-button[aria-expanded="true"] { border-color: var(--border); background: var(--surface-hover); }
  .profile-button__mailbox { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; font-weight: 650; }
  .avatar { display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; overflow: hidden; border-radius: 50%; color: white; background: linear-gradient(145deg, #6f7ce5, #344ec3); font-weight: 700; }
  .avatar img { width: 100%; height: 100%; object-fit: cover; }
  .avatar--large { width: 48px; height: 48px; font-size: 1.1rem; }
  .avatar--sender { width: 42px; height: 42px; }
  .badge-dot { position: absolute; top: 7px; right: 6px; width: 8px; height: 8px; border: 2px solid var(--bg); border-radius: 50%; background: var(--accent); }
  .status-button { position: relative; }

  .compose-button { display: flex; align-items: center; gap: 13px; min-height: 54px; margin: 0 10px 16px 8px; padding: 0 19px; border-radius: 17px; color: var(--accent-ink); background: linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 88%, white), var(--accent-soft)); box-shadow: var(--shadow-sm); font-size: .95rem; font-weight: 650; transition: box-shadow var(--motion), transform var(--motion); }
  .compose-button:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
  .nav-list { display: grid; }
  .nav-item { display: flex; align-items: center; gap: 16px; min-height: 40px; padding: 0 14px 0 22px; border-radius: 0 20px 20px 0; color: var(--text-soft); white-space: nowrap; transition: background var(--motion), color var(--motion); }
  .nav-item .icon { flex: none; }
  .nav-item:hover { color: var(--text); background: var(--surface-hover); }
  .nav-item.is-active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 700; }
  .nav-count { margin-left: auto; font-size: .78rem; font-weight: 700; }
  .nav-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
  .nav-section__title { display: flex; align-items: center; justify-content: space-between; min-height: 36px; padding: 0 12px 0 22px; font-weight: 700; }
  .label-navigation { display: grid; }
  .label-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--label-color, var(--accent)); }
  .label-color-red { --label-color: #dc2626; }
  .label-color-orange { --label-color: #ea580c; }
  .label-color-amber { --label-color: #d97706; }
  .label-color-green { --label-color: #16a34a; }
  .label-color-teal { --label-color: #0d9488; }
  .label-color-blue { --label-color: #2563eb; }
  .label-color-violet { --label-color: #7c3aed; }
  .label-color-pink { --label-color: #db2777; }
  .label-color-gray { --label-color: #64748b; }
  .chip--label { border-left: 4px solid var(--label-color, var(--accent)); }
  .navigation__footer { margin-top: auto; padding-top: 18px; }
  .nav-item--button { width: 100%; background: transparent; font-size: inherit; }
  .app-view.nav-collapsed .navigation { padding-right: 8px; overflow: visible; }
  .app-view.nav-collapsed .compose-button { width: 54px; padding: 0; justify-content: center; border-radius: 18px; }
  .app-view.nav-collapsed .compose-button span, .app-view.nav-collapsed .nav-item span, .app-view.nav-collapsed .nav-section, .app-view.nav-collapsed .brand-name, .app-view.nav-collapsed .navigation__footer span { display: none; }
  .app-view.nav-collapsed .nav-item { width: 52px; padding: 0; justify-content: center; border-radius: 0 20px 20px 0; }

  .mail-toolbar { display: flex; align-items: center; flex: none; min-height: 52px; padding: 5px 12px; border-bottom: 1px solid var(--border); }
  .selection-control, .toolbar-normal, .toolbar-selection, .paging, .reading-actions { display: flex; align-items: center; }
  .selection-control { padding-left: 6px; }
  .selection-control input { width: 17px; height: 17px; }
  .toolbar-selection { gap: 2px; }
  .selection-count { min-width: 95px; margin-left: 8px; color: var(--text-soft); font-size: .85rem; }
  .mail-toolbar__spacer { flex: 1; }
  .paging-status { margin-right: 8px; color: var(--text-muted); font-size: .8rem; }
  .mail-heading-row { display: none; align-items: center; justify-content: space-between; padding: 14px 18px 8px; }
  .eyebrow { margin-bottom: 4px; color: var(--accent); font-size: .72rem; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }

  .message-list { contain: layout paint; }
  .message-row { position: relative; display: grid; grid-template-columns: 34px 34px 30px minmax(110px, 22%) minmax(180px, 1fr) 22px minmax(66px, auto); align-items: center; min-height: var(--row-height); padding: 0 12px 0 8px; border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent); color: var(--text-soft); background: var(--surface-subtle); cursor: pointer; contain: layout paint; }
  .message-row:hover, .message-row:focus-within { z-index: 1; background: var(--surface); box-shadow: 0 2px 7px rgba(31, 49, 77, .12); }
  .message-row.is-unread { color: var(--text); background: var(--surface); }
  .message-row.is-unread .row-sender, .message-row.is-unread .row-subject, .message-row.is-unread .row-time { font-weight: 740; }
  .message-row.is-selected { background: var(--accent-soft); }
  .message-row[aria-selected="true"] { background: var(--accent-soft); }
  .message-row__select { display: grid; place-items: center; }
  .message-row__select input { width: 16px; height: 16px; }
  .row-icon { width: 32px; height: 32px; }
  .row-icon .icon { width: 18px; height: 18px; }
  .row-star.is-active { color: #e8a400; }
  .row-star.is-active .icon { fill: currentColor; }
  .row-important.is-active { color: #e8a400; }
  .row-important.is-active .icon { fill: currentColor; }
  .message-row__sender, .message-row__content { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-count { color: var(--text-muted); font-size: .78rem; }
  .row-preview, .row-separator { color: var(--text-muted); }
  .row-labels { display: inline-flex; gap: 3px; margin-left: 6px; }
  .mini-label { display: inline-block; padding: 1px 5px; border-radius: 4px; color: var(--text-soft); background: color-mix(in srgb, var(--label-color, var(--accent)) 18%, var(--surface)); font-size: .68rem; }
  .row-attachment { width: 15px; height: 15px; color: var(--text-muted); }
  .row-time { justify-self: end; white-space: nowrap; font-size: .77rem; }
  .row-quick-actions { display: none; position: absolute; right: 7px; align-items: center; padding-left: 18px; background: linear-gradient(90deg, transparent, var(--surface) 18%); }
  .message-row:hover .row-quick-actions, .message-row:focus-within .row-quick-actions { display: flex; }
  .message-row:hover .row-time, .message-row:focus-within .row-time { visibility: hidden; }

  .message-skeleton { display: grid; }
  .message-skeleton > span { display: block; height: var(--row-height); border-bottom: 1px solid var(--border); background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--text) 5%, transparent) 45%, transparent 80%) 0 0 / 240% 100%; animation: shimmer 1.35s linear infinite; }
  @keyframes shimmer { to { background-position: -240% 0; } }
  .reading-skeleton { display: grid; gap: 14px; padding: 28px; }
  .reading-skeleton span { height: 18px; border-radius: 8px; background: var(--bg-soft); }
  .reading-skeleton span:first-child { width: 62%; height: 30px; }
  .reading-skeleton span:nth-child(2) { width: 38%; }
  .reading-skeleton span:last-child { width: 78%; }
  .state-card { min-height: 300px; display: grid; place-content: center; justify-items: center; gap: 9px; padding: 34px; color: var(--text-soft); text-align: center; }
  .state-card h2 { color: var(--text); }
  .state-card p { max-width: 390px; }
  .state-card--compact { min-height: 180px; padding: 20px; }
  .state-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 4px; border-radius: 17px; color: var(--accent); background: var(--accent-soft); }
  .state-icon--success { color: var(--success); background: var(--success-soft); }
  .empty-inbox-illustration { width: min(288px, 82%); height: auto; margin: -24px auto 5px; border-radius: 26px; opacity: .9; mix-blend-mode: multiply; }
  html[data-theme="dark"] .empty-inbox-illustration { opacity: .74; mix-blend-mode: screen; filter: saturate(.8) brightness(.84); }
  @media (prefers-color-scheme: dark) { html[data-theme="system"] .empty-inbox-illustration { opacity: .74; mix-blend-mode: screen; filter: saturate(.8) brightness(.84); } }
  .load-more { display: block; width: calc(100% - 24px); min-height: 40px; margin: 12px; border-radius: 10px; color: var(--accent); background: var(--surface-hover); }

  .reading-header { position: sticky; z-index: 3; top: 0; display: flex; align-items: center; min-height: 52px; padding: 5px 14px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); }
  .reading-header__back { display: none; }
  .reading-actions { gap: 2px; }
  .toolbar-divider { width: 1px; height: 24px; margin: 0 5px; background: var(--border); }
  .reading-content { padding: clamp(20px, 3vw, 36px); }
  .reading-subject-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
  .reading-subject-row h2 { font-size: clamp(1.24rem, 2vw, 1.58rem); font-weight: 560; }
  .chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .chip { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 7px; color: var(--text-soft); background: var(--surface-hover); font-size: .74rem; }
  .security-banner, .remote-image-banner, .notice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; }
  .security-banner { margin-bottom: 18px; color: var(--warning); background: var(--warning-soft); }
  .security-banner > div, .notice > div { flex: 1; }
  .security-banner p, .notice p { color: inherit; opacity: .84; font-size: .84rem; }
  .sender-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; margin-bottom: 22px; }
  .sender-meta { min-width: 0; display: grid; }
  .sender-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .recipient-details { justify-self: start; padding: 0; color: var(--text-muted); background: transparent; font-size: .78rem; }
  .sender-row time { color: var(--text-muted); font-size: .78rem; }
  .remote-image-banner { justify-content: center; margin-bottom: 16px; padding: 8px 12px; border: 1px solid var(--border); color: var(--text-soft); background: var(--surface-subtle); font-size: .82rem; }
  .message-body { min-height: 130px; overflow-wrap: anywhere; color: var(--text); font-family: Arial, Helvetica, sans-serif; font-size: .98rem; line-height: 1.64; }
  .message-body iframe { width: 100%; min-height: 320px; border: 0; color-scheme: light; background: white; }
  .message-body blockquote { margin: 1em 0; padding-left: 1em; border-left: 3px solid var(--border); color: var(--text-soft); }
  .thread-message + .thread-message { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
  .thread-message__header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
  .thread-message__header > div { min-width: 0; display: grid; }
  .thread-message__header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-message__header time { color: var(--text-muted); font-size: .76rem; }
  .avatar--thread { width: 34px; height: 34px; font-size: .76rem; }
  .plain-mail-body { white-space: pre-wrap; }
  .attachment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 24px; }
  .attachment-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 64px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); }
  .attachment-thumb { display: grid; place-items: center; width: 44px; height: 44px; overflow: hidden; border-radius: 8px; color: var(--accent); background: var(--accent-soft); }
  .attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .attachment-meta { min-width: 0; display: grid; }
  .attachment-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
  .attachment-meta span { color: var(--text-muted); font-size: .72rem; }
  .reply-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--border); }

  .page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; max-width: 1240px; margin-bottom: 28px; }
  .page-heading > div > p:last-child { margin-top: 7px; color: var(--text-soft); }
  .settings-nav { position: sticky; top: 0; align-self: start; display: grid; gap: 4px; }
  .settings-nav button { display: flex; align-items: center; gap: 11px; min-height: 43px; padding: 9px 12px; border-radius: 10px; color: var(--text-soft); background: transparent; text-align: left; }
  .settings-nav button:hover { color: var(--text); background: var(--surface-hover); }
  .settings-nav button.is-active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 700; }
  .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
  .section-heading p { margin-top: 5px; color: var(--text-soft); }
  .section-heading--compact { align-items: center; }
  .settings-card { padding: clamp(18px, 2.5vw, 26px); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-sm); }
  .settings-card > h3 { margin-bottom: 18px; }
  .form-stack { display: grid; gap: 22px; }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .form-grid--search { gap: 14px; }
  .field { display: grid; align-content: start; gap: 6px; }
  .field > span, fieldset legend { color: var(--text-soft); font-size: .82rem; font-weight: 650; }
  .field input, .field select, .field textarea { width: 100%; }
  .field--wide { grid-column: 1 / -1; }
  fieldset { padding: 0; border: 0; }
  fieldset legend { margin-bottom: 10px; }
  .segmented { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 11px; background: var(--bg-soft); }
  .segmented label { cursor: pointer; }
  .segmented input { position: absolute; opacity: 0; pointer-events: none; }
  .segmented span { display: block; min-width: 85px; padding: 8px 12px; border-radius: 8px; color: var(--text-soft); text-align: center; }
  .segmented input:checked + span { color: var(--accent-ink); background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 700; }
  .segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--focus) 66%, transparent); }
  .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
  .switch-row > span { display: grid; }
  .switch-row small { margin-top: 3px; }
  input[role="switch"] { appearance: none; position: relative; flex: none; width: 42px; height: 24px; padding: 0; border: 0; border-radius: 20px; background: var(--border-strong); transition: background var(--motion); }
  input[role="switch"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--motion); }
  input[role="switch"]:checked { background: var(--accent); }
  input[role="switch"]:checked::after { transform: translateX(18px); }
  .check-row { display: flex; align-items: center; gap: 9px; }
  .form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 4px; }
  .save-state { margin-right: auto; color: var(--success); font-size: .84rem; }
  .form-hint { color: var(--text-muted); font-size: .82rem; }
  .secret-input { position: relative; }
  .secret-input input { padding-right: 100px; }
  .secret-status { position: absolute; top: 50%; right: 11px; color: var(--success); transform: translateY(-50%); font-size: .76rem; }
  .notice { border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border)); color: var(--accent-ink); background: var(--accent-soft); }
  .notice--safe { border-color: color-mix(in srgb, var(--success) 24%, var(--border)); color: var(--success); background: var(--success-soft); }
  .loading-card:empty { min-height: 126px; border: 1px solid var(--border); border-radius: var(--radius-md); background: linear-gradient(100deg, var(--surface) 20%, var(--surface-hover) 48%, var(--surface) 76%) 0 0 / 220% 100%; animation: shimmer 1.35s linear infinite; }
  .card-list { display: grid; gap: 10px; }
  .list-card { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); }
  .list-card__icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--accent); background: var(--accent-soft); }
  .list-card__body { min-width: 0; flex: 1; display: grid; }
  .list-card__body span { color: var(--text-muted); font-size: .8rem; }
  .list-card__actions { display: flex; gap: 3px; }
  .table-list { margin-top: 16px; border-top: 1px solid var(--border); }
  .table-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; min-height: 52px; padding: 8px 2px; border-bottom: 1px solid var(--border); }
  .table-row__main { min-width: 0; display: grid; }
  .table-row__main span { color: var(--text-muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .status-pill { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 4px 8px; border-radius: 20px; color: var(--text-soft); background: var(--surface-hover); font-size: .72rem; font-weight: 650; }
  .status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .status-pill--success { color: var(--success); background: var(--success-soft); }
  .status-pill--warning { color: var(--warning); background: var(--warning-soft); }
  .status-pill--danger { color: var(--danger); background: var(--danger-soft); }
  .routing-rules { display: grid; gap: 8px; }
  .routing-rule { display: grid; grid-template-columns: 34px 34px minmax(160px, 1fr) 24px minmax(140px, .8fr) auto; align-items: center; gap: 11px; min-height: 62px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
  .routing-rule.is-fallback { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
  .routing-rule.is-dragging { opacity: .55; box-shadow: var(--shadow-md); }
  .routing-rule__pattern, .routing-rule__mailbox { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .routing-rule__pattern { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; }
  .routing-rule__arrow { color: var(--text-muted); }
  .drag-handle { display: grid; place-items: center; width: 32px; height: 40px; color: var(--text-muted); background: transparent; cursor: grab; }
  .rule-number { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; color: var(--text-soft); background: var(--surface-hover); font-size: .76rem; font-weight: 700; }
  .simulator-card { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(230px, 1fr) auto; align-items: end; gap: 16px; }
  .simulation-result { grid-column: 1 / -1; min-height: 0; color: var(--success); font-weight: 650; }
  .range-field { display: grid; gap: 8px; }
  .range-field label { display: flex; justify-content: space-between; color: var(--text-soft); }
  .range-field input { width: 100%; min-height: auto; padding: 0; accent-color: var(--accent); }
  .metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 1240px; margin-bottom: 20px; }
  .metric-card { min-height: 106px; padding: 17px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); box-shadow: var(--shadow-sm); }
  .metric-card span { color: var(--text-muted); font-size: .8rem; }
  .metric-card strong { display: block; margin-top: 9px; font-size: 1.45rem; }
  .metric-good { color: var(--success); }
  .metric-warning { color: var(--warning); }
  .campaign-list { display: grid; gap: 9px; margin-top: 16px; }
  .campaign-card { padding: 14px; border: 1px solid var(--border); border-radius: 12px; }
  .campaign-card__head, .campaign-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .campaign-card__warning { margin-top: 10px; padding: 10px 12px; border-radius: 10px; color: var(--warning); background: var(--warning-soft); font-size: .82rem; line-height: 1.45; }
  .campaign-card__foot { margin-top: 10px; color: var(--text-muted); font-size: .78rem; }
  .campaign-progress, .job-progress { height: 6px; margin-top: 12px; overflow: hidden; border-radius: 10px; background: var(--bg-soft); }
  .campaign-progress span, .job-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
  [data-progress-step="0"] > span { width: 0%; }
  [data-progress-step="5"] > span { width: 5%; }
  [data-progress-step="10"] > span { width: 10%; }
  [data-progress-step="15"] > span { width: 15%; }
  [data-progress-step="20"] > span { width: 20%; }
  [data-progress-step="25"] > span { width: 25%; }
  [data-progress-step="30"] > span { width: 30%; }
  [data-progress-step="35"] > span { width: 35%; }
  [data-progress-step="40"] > span { width: 40%; }
  [data-progress-step="45"] > span { width: 45%; }
  [data-progress-step="50"] > span { width: 50%; }
  [data-progress-step="55"] > span { width: 55%; }
  [data-progress-step="60"] > span { width: 60%; }
  [data-progress-step="65"] > span { width: 65%; }
  [data-progress-step="70"] > span { width: 70%; }
  [data-progress-step="75"] > span { width: 75%; }
  [data-progress-step="80"] > span { width: 80%; }
  [data-progress-step="85"] > span { width: 85%; }
  [data-progress-step="90"] > span { width: 90%; }
  [data-progress-step="95"] > span { width: 95%; }
  [data-progress-step="100"] > span { width: 100%; }

  .profile-menu { top: 62px; right: 14px; width: min(370px, calc(100vw - 22px)); overflow: hidden; }
  .profile-menu__header { display: flex; align-items: center; gap: 13px; padding: 19px; background: var(--surface-subtle); }
  .profile-menu__header > div { min-width: 0; display: grid; }
  .profile-menu__header span:last-child { overflow: hidden; color: var(--text-muted); text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
  .profile-menu__section { padding: 13px 11px; border-top: 1px solid var(--border); }
  .popover-label { padding: 0 8px 7px; color: var(--text-muted); font-size: .7rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
  .switch-list { display: grid; gap: 2px; }
  .switch-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 8px; border-radius: 10px; background: transparent; text-align: left; }
  .switch-item:hover { background: var(--surface-hover); }
  .switch-item__body { min-width: 0; display: grid; }
  .switch-item__body span { overflow: hidden; color: var(--text-muted); text-overflow: ellipsis; white-space: nowrap; font-size: .76rem; }
  .switch-item.is-active::after { content: "✓"; color: var(--accent); font-weight: 800; }
  .add-account-button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 7px 12px; border-radius: 10px; color: var(--accent); background: transparent; text-align: left; }
  .add-account-button:hover { background: var(--accent-soft); }
  .switch-list__empty { padding: 10px; color: var(--text-muted); text-align: center; }
  .profile-menu footer { display: flex; justify-content: space-between; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-subtle); }

  .status-center { position: fixed; z-index: 85; top: 68px; right: 0; bottom: 0; width: min(390px, 100vw); overflow: auto; border-left: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg); }
  .status-center > header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .status-list { padding: 10px; }
  .job-card { padding: 14px; border-bottom: 1px solid var(--border); }
  .job-card__head { display: flex; justify-content: space-between; gap: 10px; }
  .job-card p { margin-top: 4px; color: var(--text-soft); font-size: .82rem; }
  .job-card__foot { display: flex; justify-content: space-between; margin-top: 8px; color: var(--text-muted); font-size: .75rem; }

  .compose-window { position: fixed; z-index: 80; right: 22px; bottom: 0; display: flex; flex-direction: column; width: min(660px, calc(100vw - 28px)); height: min(720px, calc(100vh - 86px)); border: 1px solid var(--border); border-radius: 15px 15px 0 0; overflow: hidden; background: var(--surface-raised); box-shadow: var(--shadow-lg); transform-origin: bottom right; }
  .compose-window.is-minimized { width: min(360px, calc(100vw - 28px)); height: 48px; }
  .compose-window.is-maximized { inset: 4vh 5vw; width: auto; height: auto; border-radius: var(--radius-md); }
  .compose-header { display: flex; align-items: center; justify-content: space-between; flex: none; min-height: 47px; padding: 5px 8px 5px 16px; color: white; background: linear-gradient(105deg, #1c2e4a, #263f64); }
  .compose-header h2 { font-size: .9rem; }
  .compose-header > div { display: flex; }
  .compose-header .icon-button { color: #dce9fb; }
  .compose-header .icon-button:hover { color: white; background: rgba(255,255,255,.13); }
  .compose-form { min-height: 0; flex: 1; display: flex; flex-direction: column; }
  .compose-line { display: flex; align-items: center; min-height: 43px; padding: 0 14px; border-bottom: 1px solid var(--border); }
  .compose-line > label { flex: none; width: 42px; color: var(--text-muted); font-size: .8rem; }
  .compose-line > input, .compose-line > select { width: 100%; min-height: 40px; padding: 5px 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: 0; }
  .compose-line--from select { font-size: .84rem; }
  .recipients-line { gap: 5px; }
  .recipient-chips { min-width: 0; flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 4px 0; }
  .recipient-chips input { min-width: 120px; flex: 1; min-height: 32px; padding: 3px; border: 0; border-radius: 0; background: transparent; box-shadow: none; outline: 0; }
  .recipient-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 240px; padding: 4px 7px; border-radius: 16px; color: var(--text-soft); background: var(--surface-hover); font-size: .78rem; }
  .recipient-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .recipient-chip button { display: grid; place-items: center; padding: 0; color: inherit; background: transparent; }
  .editor-toolbar { display: flex; align-items: center; gap: 2px; flex: none; min-height: 39px; padding: 3px 12px; border-bottom: 1px solid var(--border); }
  .text-format em { font-family: Georgia, serif; font-size: 1.1rem; }
  .compose-editor { min-height: 130px; flex: 1; overflow: auto; padding: 17px; outline: 0; font-family: Arial, Helvetica, sans-serif; line-height: 1.55; }
  .compose-editor:empty::before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; }
  .upload-dropzone { position: absolute; inset: 48px 0 54px; z-index: -1; display: grid; place-content: center; border: 3px dashed transparent; opacity: 0; pointer-events: none; }
  .upload-dropzone.is-dragging { z-index: 5; border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 92%, transparent); opacity: 1; pointer-events: auto; }
  .dropzone-prompt { display: grid; justify-items: center; gap: 10px; font-weight: 700; }
  .compose-attachments { position: absolute; right: 12px; bottom: 58px; left: 12px; display: grid; gap: 5px; pointer-events: auto; }
  .upload-item { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-raised); box-shadow: var(--shadow-sm); }
  .upload-item__body { min-width: 0; display: grid; }
  .upload-item__body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
  .upload-item__body span { color: var(--text-muted); font-size: .7rem; }
  .upload-progress { height: 3px; margin-top: 4px; overflow: hidden; border-radius: 3px; background: var(--bg-soft); }
  .upload-progress span { display: block; height: 100%; background: var(--accent); transition: width 100ms linear; }
  .llm-suggestion { position: absolute; right: 18px; bottom: 65px; left: 18px; z-index: 6; max-height: 46%; overflow: auto; padding: 13px; border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: 13px; background: var(--surface-raised); box-shadow: var(--shadow-lg); }
  .llm-suggestion header, .llm-suggestion footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .llm-suggestion header > span { display: flex; align-items: center; gap: 7px; color: var(--accent); font-weight: 700; }
  #llm-suggestion-text { padding: 12px 2px; white-space: pre-wrap; }
  .llm-suggestion footer { justify-content: flex-end; }
  .compose-footer { display: flex; align-items: center; gap: 3px; flex: none; min-height: 55px; padding: 7px 10px; border-top: 1px solid var(--border); }
  .send-group { display: flex; margin-right: 4px; }
  .send-button, .send-options { min-height: 39px; color: var(--on-accent); background: var(--accent); }
  .send-button { display: flex; align-items: center; gap: 8px; padding: 7px 17px; border-radius: 10px 0 0 10px; font-weight: 700; }
  .send-options { display: grid; place-items: center; width: 32px; border-left: 1px solid rgba(255,255,255,.28); border-radius: 0 10px 10px 0; }
  .send-button:hover, .send-options:hover { background: var(--accent-strong); }
  .draft-status { margin-left: 8px; color: var(--text-muted); font-size: .72rem; }
  .compose-footer__spacer { flex: 1; }

  .mobile-nav { display: none; }
  .modal-backdrop { position: fixed; inset: 0; z-index: 190; background: var(--overlay); backdrop-filter: blur(3px); }
  .progress-modal { position: fixed; z-index: 200; top: 50%; left: 50%; width: min(440px, calc(100vw - 30px)); padding: 30px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-raised); box-shadow: var(--shadow-lg); text-align: center; transform: translate(-50%, -50%); }
  .progress-modal__close { position: absolute; top: 10px; right: 10px; }
  .progress-icon { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 18px; color: white; background: linear-gradient(145deg, var(--brand-b), var(--brand-a)); }
  .progress-modal h2 { font-size: 1.35rem; }
  .progress-modal > p:not(.eyebrow) { margin-top: 8px; color: var(--text-soft); }
  .progress-track { height: 8px; margin: 23px 0 8px; overflow: hidden; border-radius: 10px; background: var(--bg-soft); }
  .progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); transition: width 220ms ease; }
  .progress-track.is-indeterminate span { width: 40%; animation: indeterminate 1.25s ease-in-out infinite; }
  @keyframes indeterminate { from { transform: translateX(-120%); } to { transform: translateX(310%); } }
  .progress-detail { min-height: 21px; font-size: .82rem; }
  .progress-actions { display: flex; justify-content: center; gap: 8px; margin-top: 20px; }

  .shortcuts-dialog { width: min(650px, calc(100vw - 26px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); background: var(--surface-raised); box-shadow: var(--shadow-lg); }
  .shortcuts-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
  .shortcuts-dialog > header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border); }
  .shortcut-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px 26px; padding: 24px; }
  .shortcut-grid span { display: grid; grid-template-columns: 36px 1fr; align-items: center; color: var(--text-soft); }
  .form-dialog { width: min(650px, calc(100vw - 28px)); max-height: min(820px, calc(100vh - 30px)); padding: 0; overflow: hidden auto; border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); background: var(--surface-raised); box-shadow: var(--shadow-lg); }
  .form-dialog::backdrop, .confirm-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
  .form-dialog > header { position: sticky; z-index: 2; top: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 20px 22px; border-bottom: 1px solid var(--border); background: var(--surface-raised); }
  .form-dialog > header p { margin-top: 5px; color: var(--text-soft); }
  .form-dialog__body { padding: 22px; }
  .form-dialog__form > footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--border); background: var(--surface-subtle); }
  .confirm-dialog { width: min(430px, calc(100vw - 28px)); padding: 28px; border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); background: var(--surface-raised); box-shadow: var(--shadow-lg); text-align: center; }
  .confirm-dialog p { margin-top: 8px; color: var(--text-soft); }
  .confirm-dialog footer { display: flex; justify-content: center; gap: 8px; margin-top: 22px; }
  .confirm-dialog__icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 15px; border-radius: 16px; color: var(--accent); background: var(--accent-soft); }
  .confirm-dialog__icon.is-danger { color: var(--danger); background: var(--danger-soft); }
  .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 17px; border-radius: 10px; color: white; background: var(--danger); font-weight: 700; }
  .action-menu { width: 220px; padding: 6px; }
  .action-menu--left { left: 12px; }
  .action-menu--right { right: 12px; }
  .action-menu--top { top: 68px; }
  .action-menu--bottom { bottom: 68px; }
  .action-menu button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 40px; padding: 7px 10px; border-radius: 8px; color: var(--text-soft); background: transparent; text-align: left; }
  .action-menu button:hover { color: var(--text); background: var(--surface-hover); }
  .action-menu button .icon { width: 18px; height: 18px; }
  .action-menu hr { margin: 5px 3px; border: 0; border-top: 1px solid var(--border); }
  kbd { display: inline-grid; place-items: center; min-width: 25px; min-height: 25px; padding: 2px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; color: var(--text); background: var(--surface-subtle); font-family: var(--font-ui); font-size: .76rem; }
  .toast-region { position: fixed; z-index: 300; right: 20px; bottom: 20px; display: grid; gap: 9px; width: min(390px, calc(100vw - 28px)); pointer-events: none; }
  .toast { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 52px; padding: 10px 11px 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-raised); box-shadow: var(--shadow-lg); pointer-events: auto; animation: toast-in 200ms ease both; }
  .toast--success > .icon { color: var(--success); }
  .toast--error > .icon { color: var(--danger); }
  .toast__action { color: var(--accent); background: transparent; font-weight: 700; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
  .noscript-message { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 30px; color: var(--text); background: var(--bg); text-align: center; }
}

@layer utilities {
  .sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
  .mobile-only { display: none; }
  body[data-density="compact"] { --row-height: 38px; }
  body[data-density="spacious"] { --row-height: 57px; }
  body.is-modal-open { overflow: hidden; }
}

@layer responsive {
  @media (max-width: 1100px) {
    :root { --nav-width: 82px; }
    .topbar { grid-template-columns: 74px minmax(260px, 1fr) auto; }
    .brand-name, .navigation .compose-button span, .navigation .nav-item span, .navigation .nav-section, .navigation .navigation__footer span { display: none; }
    .navigation { padding-right: 8px; }
    .compose-button { width: 54px; padding: 0; justify-content: center; }
    .nav-item { width: 52px; padding: 0; justify-content: center; }
    .settings-layout { grid-template-columns: 180px minmax(0, 1fr); }
    .mail-split.reading-right { grid-template-columns: minmax(340px, 42%) minmax(400px, 1fr); }
    .message-row { grid-template-columns: 30px 30px minmax(105px, 30%) minmax(150px, 1fr) 18px 66px; }
    .row-important { display: none; }
  }

  @media (max-width: 820px) {
    :root { --header-height: 62px; }
    body { overflow: hidden; }
    .app-view { grid-template: var(--header-height) minmax(0, 1fr) 66px / 1fr; }
    .topbar { grid-area: 1 / 1; grid-template-columns: auto minmax(0, 1fr) auto; gap: 7px; padding: 7px 10px; }
    .topbar__brand .menu-button, .brand-name, .desktop-only { display: none !important; }
    .brand-lockup { gap: 0; }
    .brand-orbit--header { width: 36px; height: 36px; }
    .search-box { height: 45px; }
    .search-box .search-submit { width: 38px; }
    .search-box > .icon-button:last-child, .search-shortcut { display: none; }
    .profile-button { padding: 2px; }
    .profile-button__mailbox, .profile-button > .icon { display: none; }
    .navigation { display: none; }
    .main-content { grid-area: 2 / 1; border-width: 1px 0 0; border-radius: 0; }
    .mobile-nav { grid-area: 3 / 1; z-index: 45; display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px max(7px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); border-top: 1px solid var(--border); background: var(--surface); }
    .mobile-nav button { display: grid; place-items: center; align-content: center; gap: 2px; min-width: 0; border-radius: 10px; color: var(--text-muted); background: transparent; font-size: .66rem; }
    .mobile-nav button.is-active { color: var(--accent); }
    .mobile-nav .icon { width: 21px; height: 21px; }
    .mobile-compose { display: grid; place-items: center; width: 36px; height: 30px; border-radius: 11px; color: var(--accent-ink); background: var(--accent-soft); }
    .mail-toolbar { min-height: 48px; }
    .mail-heading-row { display: flex; }
    .mail-split, .mail-split.reading-right, .mail-split.reading-bottom { display: block; }
    .message-list-panel { height: 100%; border: 0; }
    .reading-placeholder { display: none; }
    .reading-pane { position: absolute; z-index: 6; inset: 0; background: var(--surface); }
    .reading-header__back { display: block; }
    .reading-content { padding: 18px 16px 32px; }
    .message-row { grid-template-columns: 30px minmax(92px, 26%) minmax(140px, 1fr) 58px; min-height: 55px; padding-right: 8px; }
    .message-row__select { display: none; }
    .row-important, .row-attachment { display: none; }
    .row-star { grid-column: 1; }
    .message-row__sender { grid-column: 2; }
    .message-row__content { grid-column: 3; }
    .row-time { grid-column: 4; }
    .row-quick-actions { display: none !important; }
    .message-row:hover .row-time { visibility: visible; }
    .mail-split.reading-off .reading-pane { display: block; }
    .settings-view, .newsletters-view { padding: 20px 14px 30px; }
    .page-heading { align-items: flex-start; margin-bottom: 20px; }
    .page-heading > .primary-button { flex: none; padding-inline: 12px; }
    .settings-layout { display: block; }
    .settings-nav { position: static; display: flex; gap: 5px; margin: 0 -14px 18px; padding: 0 14px 8px; overflow-x: auto; scrollbar-width: none; }
    .settings-nav::-webkit-scrollbar { display: none; }
    .settings-nav button { flex: none; min-height: 39px; padding: 7px 11px; }
    .settings-nav button .icon { width: 17px; height: 17px; }
    .newsletter-grid { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .compose-window { z-index: 100; inset: var(--header-height) 0 0; width: auto; height: auto; border: 0; border-radius: 0; }
    .compose-window.is-minimized { inset: auto 8px 66px auto; width: min(350px, calc(100vw - 16px)); height: 48px; border: 1px solid var(--border); border-radius: 13px; }
    .compose-window.is-maximized { inset: var(--header-height) 0 0; border-radius: 0; }
    .toast-region { right: 10px; bottom: 76px; }
    .status-center { top: 62px; bottom: 66px; }
    .mobile-only { display: inline-grid; }
    .icon-button, .icon-button--small, .row-icon { min-width: 44px; width: 44px; height: 44px; }
  }

  @media (max-width: 560px) {
    .login-card { padding: 30px 24px 28px; }
    .topbar { grid-template-columns: 38px minmax(0, 1fr) 38px; }
    .topbar__actions .status-button { display: none; }
    .search-box input { padding-inline: 4px; }
    .form-grid, .form-grid--search { grid-template-columns: 1fr; }
    .field--wide { grid-column: auto; }
    .section-heading { align-items: flex-start; }
    .settings-card { padding: 17px 14px; }
    .simulator-card { grid-template-columns: 1fr; align-items: stretch; }
    .simulation-result { grid-column: 1; }
    .routing-rule { grid-template-columns: 26px minmax(105px, 1fr) 18px minmax(95px, .8fr) auto; gap: 6px; padding-inline: 7px; }
    .routing-rule .rule-number { display: none; }
    .routing-rule__pattern { font-size: .76rem; }
    .routing-rule__mailbox { font-size: .78rem; }
    .metric-grid { gap: 8px; }
    .metric-card { min-height: 90px; padding: 13px; }
    .metric-card strong { font-size: 1.18rem; }
    .sender-row { grid-template-columns: auto minmax(0, 1fr); }
    .sender-row time { grid-column: 2; margin-top: -10px; }
    .reply-actions .secondary-button:nth-child(2) { display: none; }
    .compose-footer .icon-button:nth-of-type(2), .draft-status { display: none; }
    .shortcut-grid { grid-template-columns: 1fr; }
    .progress-actions { flex-direction: column; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  }

  @media (forced-colors: active) {
    .brand-orbit, .progress-icon { border: 1px solid ButtonText; }
    .message-row.is-selected, .nav-item.is-active { outline: 2px solid Highlight; }
  }
}
