:root {
  --bg: #eef2fb;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #fff;
  --line: rgba(20, 30, 60, .12);
  --text: #1c1c1e;
  --muted: #5b6475;
  --blue: #0a84ff;
  --orange: #ff9500;
  --orange-text: #b35f00;
  --shadow: 0 10px 30px rgba(20, 30, 70, .10);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14;
    --surface: rgba(28, 31, 42, .82);
    --surface-solid: #1a1d27;
    --line: rgba(255, 255, 255, .12);
    --text: #f2f3f7;
    --muted: #a3aabb;
    --orange-text: #ffb340;
    --shadow: 0 10px 30px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d14; --surface: rgba(28, 31, 42, .82); --surface-solid: #1a1d27; --line: rgba(255, 255, 255, .12);
  --text: #f2f3f7; --muted: #a3aabb; --orange-text: #ffb340; --shadow: 0 10px 30px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(60rem 30rem at 10% -10%, rgba(10, 132, 255, .14), transparent 60%),
                    radial-gradient(50rem 30rem at 100% 0%, rgba(255, 149, 0, .12), transparent 60%);
  background-attachment: fixed;
  min-height: 100vh;
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px 6px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 9px; box-shadow: var(--shadow); }
.brand-name { font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; vertical-align: 2px; margin-left: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: #fff; background: var(--orange); }
.top-actions { display: flex; gap: 8px; }

.btn {
  font: inherit; font-weight: 600; font-size: 14px; color: var(--text); cursor: pointer;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
}
.btn:hover { border-color: var(--blue); }
.btn:focus-visible, .switch button:focus-visible, .chip:focus-visible, .mini:focus-visible { outline: 3px solid rgba(10, 132, 255, .45); outline-offset: 2px; }
.count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--blue); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }

.intro { padding: 4px 24px 10px; display: flex; gap: 8px 24px; align-items: center; flex-wrap: wrap; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px 18px; flex-wrap: wrap; font-weight: 600; font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 7px; }
.steps b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 12px; }
.note { margin: 0; color: var(--muted); font-size: 13px; max-width: 70ch; }

.switch { display: none; }

.panes { display: grid; grid-template-columns: minmax(360px, 2fr) 3fr; gap: 16px; padding: 6px 24px 24px; height: calc(100vh - 128px); min-height: 620px; }
.pane { display: flex; flex-direction: column; min-width: 0; border-radius: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 13px; min-height: 44px; }
.pane-title { color: var(--muted); font-weight: 600; }
.pane-tools { display: flex; align-items: center; gap: 10px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.tag-blue { background: rgba(10, 132, 255, .14); color: var(--blue); }
.tag-orange { background: rgba(255, 149, 0, .16); color: var(--orange-text); }
.mini { color: var(--muted); font-size: 12px; text-decoration: none; white-space: nowrap; }
.mini:hover { color: var(--blue); }
.chip { font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px 10px; border-radius: 999px; border: 0; background: var(--orange); color: #1c1c1e; }
.pane iframe { flex: 1; width: 100%; border: 0; background: var(--bg); }
.pane.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--orange), var(--shadow); } 100% { box-shadow: 0 0 0 0 transparent, var(--shadow); } }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 600;
}
.toast button { margin-left: 10px; }

dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 12, 20, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg-head h2 { margin: 0; font-size: 18px; }
dialog .note { margin: 6px 0 14px; }
.mail { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.mail summary { cursor: pointer; padding: 10px 12px; list-style: none; }
.mail summary::-webkit-details-marker { display: none; }
.mail-subj { font-weight: 600; display: block; }
.mail-meta { color: var(--muted); font-size: 12px; }
.mail pre { margin: 0; padding: 10px 12px 14px; border-top: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.empty { color: var(--muted); }

@media (max-width: 1000px) {
  .top { padding: 12px 16px 4px; }
  .intro { padding: 4px 16px 8px; }
  .brand-sub, .steps { display: none; }
  .switch { display: flex; gap: 4px; margin: 4px 16px 10px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
  .switch button { flex: 1; font: inherit; font-weight: 600; font-size: 14px; padding: 9px 6px; border: 0; border-radius: 9px; background: transparent; color: var(--text); cursor: pointer; position: relative; min-height: 40px; }
  .switch button[aria-pressed="true"] { background: var(--blue); color: #fff; }
  .dot { position: absolute; top: 7px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
  .panes { display: block; padding: 0 16px 16px; height: auto; min-height: 0; }
  .pane { height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 520px; }
  body[data-view="portal"] #pane-admin, body[data-view="admin"] #pane-portal { display: none; }
}
@media (max-width: 420px) {
  .top-actions .btn { padding: 8px 10px; }
  .mini { display: none; }
}

.idle { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 20, .55); }
.idle[hidden] { display: none; }
.idle-card { max-width: 420px; padding: 22px; border-radius: 18px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: center; }
.idle-title { margin: 0 0 6px; font-weight: 700; font-size: 18px; }
.idle-card .note { margin: 0 auto 16px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
