/* ============================================================
   OpenMaus Bot Control — design system
   Dark "ops console" theme, fully responsive, motion-aware.
   ============================================================ */

:root {
  /* Surface */
  --bg: #0a0e1a;
  --bg-glow-1: rgba(64, 108, 255, 0.16);
  --bg-glow-2: rgba(124, 92, 255, 0.10);
  --panel: #121828;
  --panel-2: #1a2235;
  --panel-3: #232c44;
  --panel-solid: #10141f;
  --border: #25304b;
  --border-soft: #1d2740;
  --border-strong: #32415f;

  /* Text */
  --text: #e8edf7;
  --text-dim: #a9b4cc;
  --text-muted: #6d7a97;
  --text-faint: #4c5872;

  /* Brand + actions */
  --accent: #5b8cff;
  --accent-2: #7b6bff;
  --accent-gradient: linear-gradient(135deg, #5b8cff 0%, #7b6bff 100%);
  --accent-soft: rgba(91, 140, 255, 0.16);
  --accent-soft-hi: rgba(91, 140, 255, 0.26);
  --on-accent: #ffffff;

  /* Status */
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.14);
  --muted-status: #6b7a90;
  --muted-soft: rgba(107, 122, 144, 0.16);

  /* Effects */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.18);
  --shadow-2: 0 8px 30px rgba(0,0,0,.4);
  --ring: 0 0 0 3px var(--accent-soft-hi);

  /* Spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-7: 32px; --sp-8: 44px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --dur: 0.18s;
  --dur-slow: 0.28s;
  --ease: cubic-bezier(.25,.1,.25,1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 12% -12%, var(--bg-glow-1) 0%, transparent 60%),
    radial-gradient(900px 600px at 105% 0%, var(--bg-glow-2) 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.45;
}
h1,h2,h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: inherit; }
button { font: inherit; }
code { font-family: var(--font-mono); font-size: 0.9em; }

.hidden { display: none !important; }

/* ---------- Icons (inline SVG injected by JS) ---------- */
[data-icon] svg,
.ic svg,
.btn[data-icon] svg,
.brand-mark[data-icon] svg,
.search-ic svg,
.sort-ic svg,
.toast-ic svg,
.toast-close svg,
.copy-btn svg,
.icon-btn svg {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.14em;
  flex-shrink: 0;
}
.btn[data-icon] { gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 550;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: var(--border-strong); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent-gradient); border-color: transparent; color: var(--on-accent); box-shadow: 0 2px 10px rgba(91,140,255,.28); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent-gradient); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.05); }
.btn.danger { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: rgba(248,113,113,.24); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.lg { padding: 11px 20px; font-size: 15px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  min-width: 32px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--sp-4);
  padding: 12px clamp(16px, 4vw, 36px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent-gradient); color: #fff; font-size: 17px;
  box-shadow: 0 2px 8px rgba(91,140,255,.4);
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-muted); font-size: 13px; }
.topbar-search {
  max-width: 440px;
  justify-self: center;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-muted);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.topbar-search:focus-within { border-color: var(--accent); background: var(--panel-2); }
.search-ic { font-size: 15px; color: var(--text-muted); flex-shrink: 0; }
.topbar-search input {
  width: 100%;
  border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 14px;
}
.topbar-search input::placeholder { color: var(--text-faint); }

.user-area { position: relative; justify-self: end; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.user-chip:hover { border-color: var(--border-strong); background: var(--panel-2); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-gradient); color: #fff;
  font-weight: 650; font-size: 12px; letter-spacing: .03em;
  flex-shrink: 0; user-select: none;
}
.avatar.lg { width: 40px; height: 40px; font-size: 15px; }
.user-name { font-size: 13.5px; font-weight: 550; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { font-size: 12px; color: var(--text-muted); }

.user-menu {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  min-width: 240px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: var(--sp-2);
  z-index: 50;
}
.user-menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.user-menu-name { font-weight: 600; font-size: 14px; }
.user-menu-email { color: var(--text-muted); font-size: 12.5px; word-break: break-all; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text); cursor: pointer; font-size: 14px;
  text-align: left;
}
.user-menu-item:hover { background: var(--panel-2); }
.user-menu-item.danger { color: var(--bad); }

/* ---------- Layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 36px) 88px; }

.signin { display: grid; place-items: center; min-height: 70vh; }
.signin-card { max-width: 420px; text-align: center; padding: var(--sp-8) var(--sp-6); display: grid; gap: var(--sp-3); justify-items: center; }
.signin-mark { font-size: 34px; color: var(--accent); width: 64px; height: 64px; }
.signin-card h1 { font-size: 24px; }
.signin-card p { color: var(--text-dim); margin: 0; }

.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.dash-head h1 { font-size: clamp(22px, 3vw, 28px); }
.dash-subtitle { color: var(--text-dim); margin: 4px 0 0; }

.stat-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.stat {
  flex: 1 1 140px;
  max-width: 220px;
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--border-soft); border-radius: 999px; }
.seg-btn {
  padding: 6px 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 13.5px; font-weight: 550;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.toolbar-right { display: flex; align-items: center; }
.sort-label { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border: 1px solid var(--border-soft); border-radius: 999px; background: var(--panel); color: var(--text-muted); }
.sort-ic { font-size: 14px; }
.sort-label select { border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13.5px; cursor: pointer; appearance: none; }

/* ---------- Stamp grid / cards ---------- */
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: var(--sp-4); }

.stamp-card {
  position: relative;
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-solid) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.stamp-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.stamp-card:focus-visible { outline: none; box-shadow: var(--ring); }
.stamp-card.is-active { border-color: var(--accent); box-shadow: var(--ring); }

.card-top { display: flex; align-items: center; justify-content: space-between; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted-status);
  box-shadow: 0 0 0 3px var(--muted-soft);
}
.stamp-card[data-status="running"] .status-dot,
.stamp-card[data-status="healthy"] .status-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse-live 2.6s ease-in-out infinite; }
.stamp-card[data-status="starting"] .status-dot,
.stamp-card[data-status="creating"] .status-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); animation: pulse-live 1.4s ease-in-out infinite; }
.stamp-card[data-status="unhealthy"] .status-dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
@keyframes pulse-live { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.card-name-row { display: flex; align-items: center; gap: 8px; margin-top: -2px; }
.card-name { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-tag {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px;
}

.card-meta { display: flex; flex-direction: column; gap: 5px; color: var(--text-dim); font-size: 13px; }
.card-id { display: flex; align-items: center; gap: 6px; }
.card-id code { color: var(--text-muted); font-size: 12px; }
.copy-btn { width: 22px; height: 22px; font-size: 12px; padding: 0; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.copy-btn:hover { color: var(--text); background: var(--panel-3); }
.card-owner, .card-created { color: var(--text-faint); font-size: 12.5px; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: auto; padding-top: var(--sp-2); border-top: 1px solid var(--border-soft); }
.card-open { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 13.5px; }
.sharee-avatars { display: flex; align-items: center; }
.sharee-avatars .avatar { width: 24px; height: 24px; font-size: 10px; margin-left: -6px; border: 2px solid var(--panel-solid); }
.sharee-avatars .avatar:first-child { margin-left: 0; }
.sharee-more { font-size: 12px; color: var(--text-muted); margin-left: 6px; }

/* Popover menu (kebab) */
.menu {
  position: absolute;
  right: 8px; top: 40px;
  min-width: 190px;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  padding: 4px;
  z-index: 50;
  animation: menu-in var(--dur) var(--ease);
  display: none;
}
.menu.open { display: block; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-size: 13.5px; text-align: left;
}
.menu button:hover { background: var(--panel-2); color: var(--text); }
.menu button.danger { color: var(--bad); }
.menu button.danger:hover { background: var(--bad-soft); }

/* Skeleton */
.list-loading {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 13.5px;
  padding: 6px 2px;
}
.skeleton .sk { background: linear-gradient(90deg, var(--panel-2) 0%, var(--panel-3) 50%, var(--panel-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; height: 12px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk-line.w40 { width: 40%; } .sk-line.w70 { width: 70%; } .sk-line.w55 { width: 55%; }
.sk-foot { height: 22px; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .skeleton .sk { animation: none; } }

/* Empty state */
.empty {
  grid-column: 1 / -1;
  display: grid; justify-items: center; gap: var(--sp-3);
  text-align: center; padding: var(--sp-8) var(--sp-5);
}
.empty-ic { font-size: 40px; color: var(--accent); opacity: .8; }
.empty h3 { font-size: 17px; }
.empty p { color: var(--text-dim); margin: 0; max-width: 380px; }

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(4,6,12,.6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); z-index: 70; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100%; height: 100dvh;
  width: min(480px, 100%);
  max-width: 100%;
  background: var(--panel-solid);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  z-index: 80;
  transform: translateX(102%);
  transition: transform var(--dur-slow) var(--ease);
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-inner { display: flex; flex-direction: column; height: 100%; }
.drawer-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
}
.drawer-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-title span.text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { padding: var(--sp-4); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--sp-4); }

.dsection {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.dsection > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }

.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.detail-grid .k { color: var(--text-muted); }
.detail-grid .v { color: var(--text); word-break: break-all; display: flex; align-items: center; gap: 8px; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.status-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.stamp-url-row { display: flex; align-items: center; gap: 8px; }
.stamp-url-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--panel-2); border: 1px solid var(--border-soft); padding: 8px 10px; border-radius: var(--radius-xs); font-size: 12.5px; color: var(--text-dim); }

/* Sharees list / invite */
.sharee-list { display: flex; flex-direction: column; gap: 8px; }
.sharee-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-xs); background: var(--panel-2); }
.sharee-row .avatar { width: 26px; height: 26px; font-size: 11px; }
.sharee-row .email { flex: 1; color: var(--text-dim); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sharee-row button { flex-shrink: 0; }
.invite-row { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-row input {
  flex: 1; min-width: 180px;
  padding: 9px 12px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font-size: 14px; outline: none;
}
.invite-row input:focus { border-color: var(--accent); }
.field-error { color: var(--bad); font-size: 12.5px; }

/* Action stack for owner (buttons) */
.action-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-stack .span2 { grid-column: 1 / -1; }
.action-stack .btn { width: 100%; }
.action-stack .btn.danger-zone { color: var(--bad); border-color: var(--bad-soft); background: transparent; }
.action-stack .btn.danger-zone:hover { background: var(--bad-soft); }

/* Logs */
.log-panel pre {
  margin: 0;
  max-height: 320px; overflow: auto;
  background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-xs);
  padding: var(--sp-3); font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word;
}
.log-head-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.log-empty { color: var(--text-muted); font-size: 13px; }

/* Spinner (busy buttons / creating) */
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.lg { width: 26px; height: 26px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.busy { pointer-events: none; opacity: .75; }
.btn.busy .spinner { display: inline-block; }

/* ---------- Provisioning ---------- */
.provision { display: flex; flex-direction: column; gap: var(--sp-4); padding: var(--sp-2) var(--sp-5) var(--sp-5); }
.provision-head { display: flex; align-items: center; gap: 14px; }
.provision-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.provision-title { font-size: 15px; font-weight: 650; }
.provision-status { color: var(--text-dim); font-size: 13px; }
.provision-status code { color: var(--text-muted); }
.provision-track { height: 6px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border-soft); overflow: hidden; }
.provision-bar { height: 100%; border-radius: 999px; background: var(--accent-gradient); width: 0%; box-shadow: 0 0 8px rgba(91,140,255,.45); }
@keyframes provision-fill { from { width: 4%; } to { width: 92%; } }
.provision-steps { display: flex; flex-direction: column; gap: 6px; }
.provision-step { display: flex; align-items: center; gap: 9px; color: var(--text-muted); font-size: 13px; }
.provision-step.done { color: var(--text-dim); }
.pstep-ic { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text-muted); font-size: 11px; flex-shrink: 0; }
.provision-step.done .pstep-ic { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

.provision-card .provision-head { align-items: flex-start; }
.msg-center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-7) var(--sp-4); }
.msg-center .empty-ic { font-size: 36px; color: var(--text-faint); }
.msg-center h3 { font-size: 16px; }
.drawer-sub { color: var(--text-dim); margin: 0; max-width: 320px; }

/* ---------- Modal dialogs ---------- */
.modal {
  width: min(460px, 92vw);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
  padding: 0; box-shadow: var(--shadow-2);
  animation: modal-in var(--dur-slow) var(--ease);
}
.modal.sm { width: min(400px, 92vw); }
.modal::backdrop { background: rgba(4,6,12,.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5) var(--sp-3); border-bottom: 1px solid var(--border-soft); }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.modal-hint { margin: 0; color: var(--text-dim); font-size: 13.5px; }
.modal-text { margin: 0; color: var(--text-dim); font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: var(--sp-3) var(--sp-5) var(--sp-5); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 13px; color: var(--text-muted); font-weight: 550; }
.field input {
  padding: 10px 13px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font-size: 15px; outline: none; transition: border-color var(--dur) var(--ease);
}
.field input:focus { border-color: var(--accent); box-shadow: var(--ring); }

.url-preview { display: flex; flex-direction: column; gap: 5px; }
.url-label { font-size: 12.5px; color: var(--text-muted); }
.url-preview code { background: var(--panel-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-xs); padding: 9px 11px; font-size: 12.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 90; width: min(420px, 92vw);
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  animation: toast-in var(--dur-slow) var(--ease);
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.toast-msg { flex: 1; font-size: 14px; }
.toast-ic { font-size: 16px; }
.toast.success .toast-ic { color: var(--ok); }
.toast.error .toast-ic { color: var(--bad); }
.toast-close { font-size: 13px; color: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .topbar { grid-template-columns: auto auto; }
  .brand-sub { display: none; }
  .topbar-search { order: 3; grid-column: 1 / -1; justify-self: stretch; margin-top: 2px; }
  .user-name { display: none; }
  .dash-head { align-items: stretch; flex-direction: column; }
  .dash-head .btn.lg { align-self: stretch; }
  .stat-row .stat { flex: 1 1 100%; max-width: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .seg { justify-content: stretch; width: 100%; }
  .seg-btn { flex: 1; }
  .toolbar-right { width: 100%; }
  .sort-label { width: 100%; justify-content: space-between; }
  .drawer { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .action-stack { grid-template-columns: 1fr; }
  .action-stack .span2 { grid-column: 1; }
  .toast-host { bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .drawer, .modal, .toast { transition: none !important; }
}

/* Reduced-motion-gated barrel entry handled above; keep a11y focus visible everywhere */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
