/* Glance Admin — an internal editing tool, so the design work goes into
   information density and hierarchy rather than decoration. Two columns that
   read like a file browser: pick a topic, edit its phrases.

   Palette: a warm ink on paper, with a single teal accent carried from the
   Glance topic illustrations. Neutrals are biased slightly toward the accent
   so they read as chosen rather than as the browser default grey. */

:root {
  --ink:        #16211f;
  --ink-soft:   #4a5c58;
  --ink-faint:  #7d908c;
  --paper:      #f7f6f2;
  --surface:    #ffffff;
  --line:       #e0e2dc;
  --line-soft:  #eceee8;
  --accent:     #0f766e;
  --accent-ink: #ffffff;
  --accent-wash:#e2f1ef;
  --danger:     #b3261e;
  --danger-wash:#fbe9e7;
  --warn:       #8a5a00;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(22 33 31 / 6%), 0 8px 24px rgb(22 33 31 / 6%);

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", ui-serif, Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink:        #e6ebe9;
    --ink-soft:   #a3b3af;
    --ink-faint:  #6f807c;
    --paper:      #101615;
    --surface:    #182120;
    --line:       #2a3634;
    --line-soft:  #212c2b;
    --accent:     #4fd1c5;
    --accent-ink: #08211f;
    --accent-wash:#16302e;
    --danger:     #ff6b5e;
    --danger-wash:#2c1512;
    --warn:       #d9a441;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
  }
}

* { box-sizing: border-box; }

/* The `hidden` attribute is how every view on this page is switched, and the
   browser implements it as `[hidden] { display: none }` in the *user agent*
   stylesheet — which any author rule beats, whatever its specificity. So
   `.auth { display: grid }` quietly won, and signing in left the login card
   sitting above the admin UI instead of disappearing. !important is the right
   tool here precisely once: the attribute has to outrank every layout rule. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 1.6rem; margin: 0 0 .35rem; }
h2 { font-size: 1.05rem; margin: 0; }

button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.primary { background: var(--accent); color: var(--accent-ink); padding: .5rem .9rem; font-weight: 500; }
.primary:hover { filter: brightness(1.08); }
.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); padding: .5rem .9rem; }
.ghost:hover { background: var(--line-soft); color: var(--ink); }
.danger { background: var(--danger); color: #fff; padding: .5rem .9rem; font-weight: 500; }
.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.small { padding: .35rem .65rem; font-size: .85rem; }
button:disabled { opacity: .45; cursor: not-allowed; }

.muted { color: var(--ink-faint); font-size: .9rem; }
.error { color: var(--danger); background: var(--danger-wash); padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; font-weight: 600; color: var(--accent); margin: 0 0 .5rem; }

.boot { padding: 3rem; color: var(--ink-faint); }

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

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card {
  width: min(26rem, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}
.auth-note { color: var(--ink-faint); font-size: .88rem; margin: 0 0 1.5rem; }
.auth form { display: flex; flex-direction: column; gap: .9rem; }
.auth-actions { display: flex; flex-direction: column; gap: .75rem; align-items: flex-start; margin-top: .3rem; }
.auth-actions .primary { width: 100%; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; font-weight: 500; color: var(--ink-soft); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; width: 100%;
}
textarea { font-family: var(--mono); font-size: .85rem; line-height: 1.5; resize: vertical; min-height: 5rem; }

.idcard { margin-top: 1.2rem; padding: .9rem; background: var(--accent-wash); border-radius: 8px; font-size: .85rem; }
.idcard p { margin: 0 0 .5rem; }
.idcard pre { font-family: var(--mono); font-size: .75rem; margin: 0; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

/* ── shell ────────────────────────────────────────────────────────────── */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: .55rem; }
.brand-mark { font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.brand-sub { color: var(--ink-faint); font-size: .85rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.pill {
  font-family: var(--mono); font-size: .72rem; padding: .2rem .5rem;
  background: var(--accent-wash); color: var(--accent); border-radius: 999px;
}

.columns {
  display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
  gap: 1.25rem; padding: 1.25rem; align-items: start; max-width: 90rem; margin: 0 auto;
}
@media (max-width: 60rem) { .columns { grid-template-columns: minmax(0, 1fr); } }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem 1.2rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.panel-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.switch { flex-direction: row; align-items: center; gap: .45rem; font-weight: 400; color: var(--ink-faint); margin-bottom: .75rem; }
.switch input { width: auto; }

/* ── lists ────────────────────────────────────────────────────────────── */

.topic-list, .phrase-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.topic-row {
  display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: center;
  padding: .6rem .7rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
}
.topic-row:hover { background: var(--line-soft); }
.topic-row[aria-selected="true"] { background: var(--accent-wash); border-color: var(--accent); }
.topic-name { font-weight: 500; }
.topic-meta { grid-column: 1; color: var(--ink-faint); font-size: .78rem; font-family: var(--mono); }
/* Column named explicitly: with only the row pinned, auto-placement back-filled
   column 1 and the buttons came out to the left of the title they act on. */
.topic-tools { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: .3rem; }

.badge {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600;
  padding: .1rem .4rem; border-radius: 4px; margin-left: .45rem; vertical-align: 1px;
}
.badge-mine { background: var(--accent-wash); color: var(--accent); }

.phrase-row {
  display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem;
  padding: .7rem .75rem; border: 1px solid var(--line-soft); border-radius: 8px;
}
.phrase-row:hover { border-color: var(--line); }
.phrase-text { font-weight: 500; }
.phrase-translation { grid-column: 1; color: var(--ink-soft); font-size: .9rem; }
.phrase-meta { grid-column: 1; color: var(--ink-faint); font-size: .75rem; font-family: var(--mono); }
.phrase-tools { grid-column: 2; grid-row: 1 / span 3; display: flex; gap: .3rem; align-items: start; }

.readonly-note {
  background: var(--accent-wash); color: var(--ink-soft); font-size: .85rem;
  padding: .55rem .7rem; border-radius: 8px; margin: 0 0 .75rem;
}
.empty { color: var(--ink-faint); font-size: .9rem; padding: .8rem .2rem; }

/* ── dialogs ──────────────────────────────────────────────────────────── */

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  width: min(42rem, calc(100vw - 2rem)); max-height: min(85dvh, 50rem);
}
dialog::backdrop { background: rgb(10 16 15 / 45%); }
dialog form { display: flex; flex-direction: column; max-height: inherit; }
dialog h2 { padding: 1.1rem 1.25rem .75rem; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; padding: 0 1.25rem 1rem; overflow-y: auto; }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 40rem) { .fields { grid-template-columns: 1fr; } }
dialog .error { margin: 0 1.25rem 1rem; }
dialog menu {
  display: flex; justify-content: flex-end; gap: .5rem; margin: 0;
  padding: .9rem 1.25rem; border-top: 1px solid var(--line); background: var(--paper);
}
.hint { font-weight: 400; color: var(--ink-faint); font-size: .75rem; }

/* ── toast ────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; inset-block-end: 1.25rem; inset-inline-start: 50%; translate: -50% 0;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: 999px;
  font-size: .88rem; box-shadow: var(--shadow); z-index: 20; max-width: calc(100vw - 2rem);
}
.toast[data-tone="error"] { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { opacity: 0; translate: -50% .5rem; } }
}

/* ── Google sign-in ───────────────────────────────────────────────────── */

/* A rule with the word set into it, rather than a bare line: the two ways in
   are alternatives, and the divider should say so. */
.auth-or {
  display: flex; align-items: center; gap: .75rem;
  margin: 1.25rem 0 1rem; color: var(--ink-faint); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .1em;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.gsi { display: flex; justify-content: center; min-height: 2.5rem; }
.gsi-note { margin: .75rem 0 0; text-align: center; }
