/* ============================================================
   HME Manager — workbench UI
   Zero-dependency, hand-rolled design system.
   Themes: light (default) / dark via [data-theme] with
   prefers-color-scheme fallback.
   Elevation rule: panels use hairline borders; shadows are
   reserved for floating layers (toasts, modal, segmented thumb).
   ============================================================ */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;

  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --ink: #17181c;
  --muted: #5c6674;
  --line: #e4e7ec;
  --soft-line: #eef0f4;

  /* accent = surfaces (primary buttons, rings, dots);
     accent-text = accent-colored text on light tints (>=4.5:1) */
  --accent: #0669dd;
  --accent-strong: #0353b8;
  --accent-text: #0353b8;
  --accent-soft: rgba(6, 105, 221, 0.10);
  --accent-ink: #ffffff;

  --ok: #189e6a;
  --ok-soft: rgba(24, 158, 106, 0.12);
  --warn: #a06a13;
  --warn-soft: rgba(160, 106, 19, 0.13);
  --danger: #cf3340;
  --danger-soft: rgba(207, 51, 64, 0.10);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);
  --shadow-thumb: 0 1px 2px rgba(16, 24, 40, 0.10);
}

[data-theme="dark"] {
  --bg: #0e1015;
  --panel: #161920;
  --panel-2: #1d212b;
  --ink: #e8eaf0;
  --muted: #949eb1;
  --line: #262c38;
  --soft-line: #20252f;

  --accent: #4899ff;
  --accent-strong: #77b6ff;
  --accent-text: #82bbff;
  --accent-soft: rgba(72, 153, 255, 0.14);
  --accent-ink: #081321;

  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.13);
  --warn: #e2b03a;
  --warn-soft: rgba(226, 176, 58, 0.14);
  --danger: #ff6369;
  --danger-soft: rgba(255, 99, 105, 0.13);

  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  --shadow-thumb: 0 1px 2px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0e1015;
    --panel: #161920;
    --panel-2: #1d212b;
    --ink: #e8eaf0;
    --muted: #949eb1;
    --line: #262c38;
    --soft-line: #20252f;

    --accent: #4899ff;
    --accent-strong: #77b6ff;
    --accent-text: #82bbff;
    --accent-soft: rgba(72, 153, 255, 0.14);
    --accent-ink: #081321;

    --ok: #3ecf8e;
    --ok-soft: rgba(62, 207, 142, 0.13);
    --warn: #e2b03a;
    --warn-soft: rgba(226, 176, 58, 0.14);
    --danger: #ff6369;
    --danger-soft: rgba(255, 99, 105, 0.13);

    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
    --shadow-thumb: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 13.5px; margin-bottom: 10px; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}
::selection { background: var(--accent-soft); }

/* The UA [hidden] rule only covers HTML elements; SVG needs it spelled out
   (theme toggle swaps its sun/moon icons via the hidden attribute). */
svg[hidden] { display: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- app shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: 100vh;
}

/* ---------- sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 12px 14px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-logo { display: grid; place-items: center; flex: none; }
.brand-logo img { display: block; border-radius: 10px; }
.brand-meta { display: grid; line-height: 1.3; min-width: 0; }
.brand-name { font-size: 14.5px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.brand-name:hover { text-decoration: none; color: var(--accent-text); }
.brand-author { font-size: 12px; color: var(--muted); }
.brand-author:hover { color: var(--accent-text); text-decoration: none; }

.nav { display: grid; gap: 3px; }
.nav-item {
  display: flex; align-items: center; justify-content: flex-start; gap: 11px;
  min-height: 38px; padding: 0 12px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-item:hover { background: var(--panel-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-ico { display: grid; place-items: center; flex: none; }
.nav-ico svg { width: 18px; height: 18px; }

.sidebar-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  background: var(--panel-2);
}
.session-indicator {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--muted); background: var(--panel);
  border: 1px solid var(--soft-line);
}
.session-indicator svg { width: 17px; height: 17px; }
.session-indicator.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.session-indicator.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.session-indicator.bad { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.sidebar-status-copy { display: grid; gap: 1px; min-width: 0; }
.mini-status { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
.mini-refresh {
  display: block; width: 100%;
  border: none; background: none; padding: 0; min-height: 0;
  font: inherit; font-size: 11.5px; color: var(--muted);
  text-align: left; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mini-refresh:hover { color: var(--accent-text); }
.mini-refresh.ok { color: var(--ok); }
.mini-refresh.warn { color: var(--warn); }
.mini-refresh.bad { color: var(--danger); }

/* ---------- workspace ---------- */
.workspace { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 58px; padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar h1 { font-size: 15.5px; }
.view-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 34px; min-height: 34px; padding: 0;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.logout-btn { width: auto; padding: 0 10px; display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 12.5px; }
.logout-label { font-weight: 500; }

.view-scroll { flex: 1; overflow-y: auto; padding: 20px 24px 32px; }
.view { max-width: 1440px; margin: 0 auto; }

/* ---------- controls ---------- */
button {
  font: inherit; font-size: 13px; font-weight: 500;
  min-height: 34px; padding: 0 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink);
  cursor: pointer;
  transition: background 0.13s ease, border-color 0.13s ease, color 0.13s ease;
}
button:hover { background: var(--panel-2); border-color: color-mix(in srgb, var(--muted) 42%, var(--line)); }
button:not(:disabled):active { background: var(--soft-line); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
button.primary:hover { background: var(--accent-strong); }
button.primary:not(:disabled):active { background: var(--accent-strong); }
button.danger { background: transparent; border-color: transparent; color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: transparent; }
.alias-action-icon { width: 15px; height: 15px; flex: none; }

input, select, textarea {
  font: inherit; font-size: 13px;
  min-height: 34px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink);
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }
textarea { font-family: var(--font-mono); font-size: 12px; line-height: 1.55; resize: vertical; }
#importCurl { width: 100%; min-height: 150px; }
.inline-control { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.inline-control input[type="checkbox"] { min-height: 0; accent-color: var(--accent); width: 15px; height: 15px; }
label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label > input { color: var(--ink); font-weight: 400; }

/* ---------- shared layout bits ---------- */
.view-actions { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.empty-state {
  padding: 44px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-state small { font-size: 12px; }

/* ---------- aliases ---------- */
.alias-toolbar input[type="search"] { flex: 1; max-width: 420px; }
.create-form {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.create-form input { flex: 1; min-width: 180px; }

.result-tabs {
  display: inline-flex; gap: 2px;
  padding: 3px;
  margin-bottom: 12px;
  background: var(--panel-2);
  border-radius: 10px;
}
.tab-button {
  min-height: 28px; padding: 0 14px;
  border: none; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 600;
}
.tab-button:hover { background: transparent; color: var(--ink); }
.tab-button:not(:disabled):active { background: transparent; }
.tab-button.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-thumb); }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 230px);
}
table { width: 100%; min-width: 780px; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-top: 1px solid var(--soft-line); vertical-align: middle; }
tbody tr:first-child td { border-top: none; }
tbody tr:hover { background: var(--panel-2); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on { color: var(--ok); background: var(--ok-soft); }
.badge.off { color: var(--muted); background: var(--panel-2); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.row-actions button { min-height: 28px; padding: 0 10px; font-size: 12px; }
.hme-cell { display: flex; align-items: center; gap: 8px; }
.copy-btn {
  width: 26px; min-height: 26px; padding: 0; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--soft-line); border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.copy-btn:hover { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.copy-btn svg { width: 13px; height: 13px; }
.created-cell { color: var(--muted); font-size: 12px; white-space: nowrap; }

.code, pre.code {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  background: var(--panel-2);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
}
.alias-source { max-height: calc(100vh - 260px); }

/* ---------- inbox ---------- */
.inbox-toolbar select { max-width: 300px; flex: 1; }
.inbox-grid {
  display: grid;
  grid-template-columns: minmax(290px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.mail-list {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 200px);
}
.mail-list .empty-state { border: none; border-radius: 0; background: transparent; }
.mail-item {
  display: grid; justify-content: stretch; gap: 3px;
  text-align: left;
  min-height: auto;
  padding: 12px 15px;
  border: none; border-bottom: 1px solid var(--soft-line); border-radius: 0;
  background: transparent;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.12s ease;
}
.mail-item:hover { background: var(--panel-2); border-color: var(--soft-line); }
.mail-item:not(:disabled):active { background: var(--panel-2); }
.mail-item.active { background: var(--accent-soft); }
.mail-item-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.mail-from {
  font-size: 13px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-item.unread .mail-from { font-weight: 700; }
.mail-item.unread .mail-from::before {
  content: ""; display: inline-block;
  width: 8px; height: 8px; margin-right: 7px;
  border-radius: 50%; background: var(--accent);
}
.mail-date { font-size: 11px; color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.mail-subject {
  font-size: 13px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mail-item.unread .mail-subject { font-weight: 700; }
.mail-snippet {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.load-more {
  border: none; border-top: 1px solid var(--soft-line); border-radius: 0;
  background: transparent; color: var(--muted);
  min-height: 42px; font-size: 12.5px;
}
.load-more:hover { background: var(--panel-2); color: var(--accent-text); border-color: var(--soft-line); }

.mail-reader { min-height: 340px; }
.mail-head {
  display: grid; gap: 10px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--soft-line);
}
.mail-head-subject { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }
.mail-meta { display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.mail-meta dt { color: var(--muted); font-weight: 600; }
.mail-meta dd { margin: 0; overflow-wrap: anywhere; }
.code-chip {
  justify-self: start;
  min-height: 36px; padding: 0 15px;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.code-chip strong { font-size: 15.5px; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; }
.code-chip:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.code-chip:not(:disabled):active { background: var(--accent-strong); color: var(--accent-ink); }
.mail-attachments { font-size: 12px; color: var(--muted); }
.mail-html {
  width: 100%; min-height: 420px;
  border: 1px solid var(--soft-line); border-radius: var(--radius-sm);
  background: #ffffff;
}
.mail-text {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.65;
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 500px; overflow: auto; margin: 0;
}

/* ---------- API builder ---------- */
.method-badge { display: none; }
.builder-grid {
  display: grid;
  grid-template-columns: minmax(290px, 370px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.endpoint-field { display: grid; gap: 8px; }
.field-label { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.endpoint-list { display: grid; gap: 3px; }
.endpoint-row {
  display: grid;
  grid-template-columns: 52px minmax(0, auto) 1fr;
  align-items: center; gap: 8px;
  min-height: 36px; padding: 0 10px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  font-size: 12.5px; font-weight: 400;
}
.endpoint-row:hover { background: var(--panel-2); border-color: transparent; }
.endpoint-row.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.endpoint-method { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; color: var(--muted); }
.endpoint-row.active .endpoint-method { color: var(--accent-text); }
.endpoint-name { font-weight: 600; white-space: nowrap; }
.endpoint-path {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: right;
}
.stack-lg { display: grid; gap: 18px; }
.request-editor { width: 100%; min-height: 190px; }
.request-actions { margin-top: 10px; }
.path-param-row { margin-bottom: 10px; }
.path-param-row select { width: 100%; max-width: 460px; }
.response-kind {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 8px; padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--muted); background: var(--panel-2);
  vertical-align: 2px;
}
.response-kind::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.response-kind.actual { color: var(--ok); background: var(--ok-soft); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.compact-pre { max-height: 130px; }
.response-json {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  background: var(--panel-2);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  overflow: auto;
  max-height: 380px;
  white-space: pre-wrap; overflow-wrap: anywhere;
  margin: 0;
}
/* Dashed = "not sent yet": the example must never read as a real result. */
.example-output { border-style: dashed; }

/* ---------- session view ---------- */
.session-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.session-grid {
  display: grid; grid-template-columns: 112px 1fr;
  gap: 7px 14px;
  margin: 0;
  font-size: 13px;
}
.session-grid dt { color: var(--muted); font-weight: 600; }
.session-grid dd { margin: 0; overflow-wrap: anywhere; }
.auto-refresh-info {
  font-size: 12.5px; color: var(--muted);
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.auto-refresh-row { margin-bottom: 12px; }
.auto-refresh-actions { margin-top: 12px; }
.import-card { display: grid; gap: 12px; }
.import-steps { padding-left: 20px; display: grid; gap: 5px; margin: 0 0 4px; }
#importResult { max-height: 200px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 10000;
  display: grid; gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 14px;
  border-radius: 11px;
  font-size: 13px; line-height: 1.45;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow-wrap: anywhere;
  animation: toast-in 0.18s ease-out;
}
.toast::before {
  content: "";
  width: 8px; height: 8px; flex: none;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.toast.ok::before { background: var(--ok); }
.toast.warn::before { background: var(--warn); }
.toast.bad::before { background: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.22s ease, transform 0.22s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- API key modal ---------- */
#apiKeyModal {
  position: fixed; inset: 0; z-index: 20000;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(9, 12, 18, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#apiKeyModal.hidden { display: none; }
.modal-box {
  width: min(400px, 100%);
  display: grid; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 26px;
}
.modal-box h2 { font-size: 16px; }
.modal-box p { margin: 0; color: var(--muted); font-size: 13px; }
.modal-box input { width: 100%; }
.modal-box button { width: 100%; background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.modal-box button:hover { background: var(--accent-strong); }
.modal-error { display: none; color: var(--danger); font-size: 12.5px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .sidebar {
    flex-direction: row; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-right: none; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
    overflow: visible;
  }
  .brand-meta { display: none; }
  .nav { display: flex; flex: 1; gap: 2px; overflow-x: auto; }
  .nav-item { min-height: 42px; padding: 0 11px; white-space: nowrap; }
  .nav-item span:last-child { display: none; }
  .sidebar-foot { margin: 0; padding: 6px; background: transparent; border: none; }
  .sidebar-status-copy { display: none; }
  .workspace { overflow: visible; }
  .topbar { position: static; }
  .view-scroll { padding: 14px 14px 28px; overflow: visible; }
  .logout-label { display: none; }
  .logout-btn { width: 40px; padding: 0; }
  .icon-btn { width: 40px; min-height: 40px; }
  .builder-grid, .inbox-grid, .session-cols { grid-template-columns: 1fr; }
  .mail-list { max-height: 46vh; }
  .inbox-toolbar select { max-width: none; min-height: 42px; flex: 1 1 100%; }
  .inbox-toolbar .spacer { display: none; }
  .table-wrap { max-height: none; }
  .alias-toolbar input[type="search"] { max-width: none; flex: 1 1 100%; min-height: 40px; }
  .alias-action-label { display: none; }
  .view-actions button { min-width: 42px; min-height: 40px; }
  .row-actions button { min-height: 36px; padding: 0 12px; }
  .copy-btn { width: 34px; min-height: 34px; }
  .tab-button { min-height: 36px; }
}
