/* Design tokens lifted from the Mouseion.dc.html prototype. */
:root {
  --bg: #fbf9f6;
  --surface: #ffffff;
  --sidebar: #f5f1eb;
  --sidebar-hover: #eae3d9;
  --row-hover: #f9f6f2;
  --ink: #1c1a18;
  --ink-soft: #4a423c;
  --muted: #6b645d;
  --faint: #9a928a;
  --fainter: #b3aba2;
  --border: #e4ded6;
  --border-strong: #d8d0c6;
  --border-light: #efeae3;
  --accent: #7a2b2b;
  --accent-hover: #611f1f;
  --accent-bg: #f4e9e7;
  --accent-border: #e8c9c3;
  --accent-soft: #fbf0ee;
  --folder: #e4d6c3;
  --ok: #2f6b4f;
  --warn: #8a5a12;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Libre Franklin', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
input, button, select { font-family: inherit; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* ── layout ─────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 252px; flex: none; background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 32px 20px; display: flex; flex-direction: column; gap: 36px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding-left: 8px; }
.brand-mark {
  width: 26px; height: 26px; background: var(--accent); color: var(--bg); border-radius: 3px;
  display: grid; place-items: center; font-size: 15px; font-weight: 700; letter-spacing: 0.02em;
}
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  text-align: left; background: transparent; border: none; border-radius: 6px;
  padding: 10px 12px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer;
}
.nav button:hover { background: var(--sidebar-hover); }
.nav button[aria-current='page'] { background: var(--sidebar-hover); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.signed-in-as { font-size: 12px; color: var(--muted); line-height: 1.5; }
.signed-in-as strong { color: var(--ink); font-weight: 500; display: block; }
.token-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.expired { background: var(--accent); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.screen { padding: 56px clamp(24px, 4.5vw, 64px) 96px; max-width: 1120px; width: 100%; }
.screen.detail { padding-top: 40px; }
.screen.narrow { max-width: 820px; }

h1 { margin: 0 0 8px; font-size: 30px; font-weight: 600; letter-spacing: -0.02em; }
.lede { margin: 0; font-size: 15px; color: var(--muted); max-width: 52ch; text-wrap: pretty; }

/* ── controls ───────────────────────────────────────────────────────── */

.btn {
  border-radius: 6px; font-size: 14px; cursor: pointer; padding: 12px 18px;
  border: 1px solid transparent; font-weight: 500;
}
.btn-primary { background: var(--accent); color: var(--bg); border: none; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--ink); border-color: var(--accent); }
.btn-dark { background: var(--ink); color: var(--bg); border: none; font-weight: 600; }
.btn-dark:hover { background: #3a3530; }
.btn-danger { background: transparent; border-color: var(--accent-border); color: var(--accent); font-weight: 600; }
.btn-danger:hover { background: var(--accent-soft); }
.btn-sm { padding: 10px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.input {
  width: 100%; padding: 11px 12px; font-size: 14px;
  border: 1px solid var(--border-strong); border-radius: 6px; background: var(--bg);
}
.input.sm { padding: 9px 12px; font-size: 13px; background: var(--surface); }
.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 32px; margin-bottom: 24px;
}
.card h2 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.card p { margin: 0 0 16px; font-size: 13px; color: var(--muted); max-width: 56ch; }

.chip {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 99px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.chip[aria-pressed='true'] { background: var(--sidebar-hover); color: var(--ink); border-color: var(--border-strong); }

.perm {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 4px 7px;
  border-radius: 4px; background: var(--accent-bg); color: var(--accent);
}

.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs button {
  background: transparent; border: none; padding: 0 0 12px; font-size: 14px; font-weight: 500;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--accent); }

/* ── storage list ───────────────────────────────────────────────────── */

.list-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 36px;
}
.list-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px; flex-wrap: wrap;
}
.list-toolbar .input { width: 240px; margin-bottom: 10px; }

.row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 16px 32px; text-align: left; width: 100%; background: transparent; border: none;
  border-bottom: 1px solid var(--border-light); padding: 22px 8px; cursor: pointer;
}
.row:hover { background: var(--sidebar); }
.row-main { flex: 1 1 240px; min-width: 0; display: flex; align-items: center; gap: 16px; }
.row-name {
  font-size: 16px; font-weight: 500; margin-bottom: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-sub { font-size: 13px; color: var(--muted); }
.row-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.row-meta .muted { font-size: 13px; color: var(--muted); white-space: nowrap; }
.row-meta .faint { font-size: 13px; color: var(--faint); white-space: nowrap; }

.folder-icon {
  flex: none; width: 26px; height: 21px; background: var(--folder);
  border-radius: 2px 4px 4px 4px; position: relative; display: block;
}
.folder-icon::before {
  content: ''; position: absolute; top: -5px; left: 0; width: 12px; height: 5px;
  background: var(--folder); border-radius: 2px 2px 0 0; display: block;
}

.empty { padding: 64px 8px; text-align: center; }
.empty-title { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.empty-body { font-size: 14px; color: var(--muted); }
.note { margin-top: 20px; font-size: 12px; color: var(--faint); padding-left: 8px; }

/* ── detail ─────────────────────────────────────────────────────────── */

.back {
  background: transparent; border: none; padding: 0; font-size: 13px;
  color: var(--muted); cursor: pointer; margin-bottom: 24px;
}
.back:hover { color: var(--accent); }

.detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 32px; margin-bottom: 8px; flex-wrap: wrap;
}
.detail-badges { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail-actions { flex: 0 1 300px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.detail-actions .hint { font-size: 12px; color: var(--muted); max-width: 30ch; text-wrap: pretty; }

.status-pill {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; padding: 5px 9px;
  border-radius: 4px; background: var(--accent-bg); color: var(--accent);
}
.status-pill.deactivated { background: var(--sidebar-hover); color: var(--muted); }


.grant-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--border-light); flex-wrap: wrap;
}

/* ── token screen ───────────────────────────────────────────────────── */

.token-box { background: var(--ink); border-radius: 8px; padding: 16px 18px; margin-bottom: 14px; }
.token-box code {
  font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: #f0eae2; word-break: break-all; display: block;
}
.token-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.warn-text { font-size: 12px; color: var(--faint); }
.link-btn {
  background: transparent; border: none; padding: 0; font-size: 12px;
  color: var(--muted); cursor: pointer; text-decoration: underline;
}
.link-btn:hover { color: var(--accent); }
.id-chip {
  font-family: var(--mono); font-size: 13px; background: var(--sidebar);
  border: 1px solid var(--border); border-radius: 6px; padding: 11px 14px;
}

/* ── sign in ────────────────────────────────────────────────────────── */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 48px; }
.signin-card { width: 100%; max-width: 460px; text-align: center; }
.signin-card .brand-mark { width: 34px; height: 34px; font-size: 19px; margin: 0 auto 26px; }
.signin-card h1 { font-size: 26px; margin-bottom: 12px; }
.signin-card p { margin: 0 0 32px; font-size: 15px; color: var(--muted); line-height: 1.6; text-wrap: pretty; }

.alert {
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  border-radius: 10px; padding: 24px; text-align: left;
}
.alert-title { font-size: 15px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
.alert p { margin: 0 0 16px; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.alert-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.alert-code { font-family: var(--mono); font-size: 12px; color: var(--faint); }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 99px; animation: spin 0.7s linear infinite; display: inline-block;
}
.busy { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; }
.busy span:last-child { font-size: 14px; color: var(--muted); }

/* ── modal ──────────────────────────────────────────────────────────── */

.backdrop {
  position: fixed; inset: 0; background: rgba(28, 26, 24, 0.42);
  display: grid; place-items: center; padding: 32px; z-index: 40;
}
.modal {
  width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 36px; animation: rise 0.18s ease-out;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 8px; }
.modal-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.modal-close {
  background: transparent; border: none; font-size: 20px; color: var(--faint);
  cursor: pointer; line-height: 1; padding: 2px 6px;
}
.modal-close:hover { color: var(--ink); }
.modal p.lede { margin: 0 0 28px; font-size: 14px; }

.callout {
  background: var(--accent-bg); border: 1px solid var(--accent-border); border-radius: 8px;
  padding: 14px 16px; margin-bottom: 24px; font-size: 13px; color: var(--accent); line-height: 1.55;
}
.snippet { background: var(--ink); border-radius: 8px; padding: 20px; margin-bottom: 14px; }
.snippet pre {
  margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: #f0eae2; white-space: pre-wrap; word-break: break-all;
}

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--sidebar); padding: 12px 20px; border-radius: 99px;
  font-size: 13px; font-weight: 500; z-index: 60; animation: rise 0.18s ease-out;
  box-shadow: 0 6px 24px rgba(28, 26, 24, 0.18);
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; gap: 20px; padding: 16px 20px; }
  .sidebar-foot { margin-top: 0; margin-left: auto; }
  .nav { flex-direction: row; }
  .screen { padding: 32px 20px 64px; }
}
