/* Owner panel. Builds on the site's tokens in /styles.css. */
body.admin { background: var(--ink); }
body.admin #voxels, body.admin .scrim { display: none; }

.btn-small-ghost { min-height: 38px; padding: 0 14px; font-size: 0.9rem; }

/* Auth */
.auth {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card {
  width: min(420px, 100%);
  padding: 30px 28px;
  background: var(--ink-raised);
  border: 1px solid var(--ink-line);
  border-radius: 12px;
}
.auth-card .wordmark { font-size: 1.4rem; }
.auth-title { font-family: var(--body); font-weight: 600; font-size: 1.5rem; margin: 10px 0 20px; letter-spacing: 0; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 18px; }
.auth-tabs button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--ink-line);
  background: none;
  color: var(--muted);
  font: 600 0.9rem var(--body);
  cursor: pointer;
}
.auth-tabs button[aria-selected="true"] { background: var(--text); color: var(--ink); border-color: var(--text); }
.auth-form { display: grid; gap: 8px; }
.auth-form label { font-size: 0.88rem; font-weight: 500; color: #CDD2EA; margin-top: 4px; }
.auth-form input {
  min-height: 46px;
  padding: 0 13px;
  font: 400 1rem var(--body);
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--ink-line);
  border-radius: 6px;
}
.auth-form input:focus { outline: none; border-color: var(--text); }
.auth-form .btn { margin-top: 12px; }
.auth-help { font-size: 0.88rem; color: var(--muted); }
.auth-or { text-align: center; color: var(--muted); font-size: 0.88rem; margin: 16px 0 10px; }
.auth-google #google-btn { display: flex; justify-content: center; }
.auth-error { color: var(--red); font-size: 0.92rem; margin-top: 14px; min-height: 1.4em; }

/* Dashboard frame */
.dash-head {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px 28px;
  padding: 14px var(--gutter);
  background: rgba(10, 12, 28, 0.94);
  border-bottom: 1px solid var(--ink-line);
}
.dash-head .wordmark { font-size: 1.35rem; margin: 0; }
.dash-head .wordmark span { font-family: var(--body); font-weight: 500; font-size: 0.95rem; color: var(--muted); letter-spacing: 0; }
.dash-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.dash-nav button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 0.95rem var(--body);
  cursor: pointer;
}
.dash-nav button:hover { color: var(--text); }
.dash-nav button[aria-current="page"] { background: var(--ink-raised); color: var(--text); }
.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  line-height: 20px;
  text-align: center;
}
.dash-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.view { padding: 26px var(--gutter) 60px; max-width: 86rem; }
.view-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.view-top h1 { font-family: var(--body); font-weight: 600; font-size: 1.6rem; letter-spacing: -0.01em; }

.range { display: inline-flex; border: 1px solid var(--ink-line); border-radius: 8px; padding: 3px; gap: 3px; }
.range button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font: 600 0.88rem var(--body);
  cursor: pointer;
}
.range button[aria-pressed="true"] { background: var(--text); color: var(--ink); }

/* Stat tiles: number first, label under it */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.tile {
  padding: 16px 18px;
  background: var(--ink-raised);
  border: 1px solid var(--ink-line);
  border-radius: 10px;
}
.tile-value { font-size: 2rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { margin-top: 4px; font-size: 0.88rem; color: var(--muted); }

.panel {
  padding: 18px 20px;
  background: var(--ink-raised);
  border: 1px solid var(--ink-line);
  border-radius: 10px;
}
.panel-title { font-family: var(--body); font-weight: 600; font-size: 1rem; letter-spacing: 0; margin-bottom: 12px; }
.panel-empty { color: var(--muted); font-size: 0.92rem; }

/* Bar chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid line { stroke: rgba(233, 236, 248, 0.08); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font: 11px var(--body); }
.chart .bar { fill: var(--blue); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.is-hover { fill: #7FAEFF; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  padding: 8px 10px;
  background: var(--ink);
  border: 1px solid var(--ink-line);
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  white-space: nowrap;
  transform: translate(-50%, -100%);
}
.chart-tip strong { display: block; }

/* Ranked lists */
.lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.rank li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 0.92rem; }
.rank .r-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .r-n { font-variant-numeric: tabular-nums; color: #CDD2EA; }
.rank .r-bar { grid-column: 1 / -1; height: 6px; background: rgba(233, 236, 248, 0.06); border-radius: 3px; overflow: hidden; }
.rank .r-bar i { display: block; height: 100%; background: var(--blue); border-radius: 0 3px 3px 0; }

/* Live chat */
.live {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 12px;
  height: calc(100svh - 190px);
  min-height: 420px;
}
.conv-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  background: var(--ink-raised);
  border: 1px solid var(--ink-line);
  border-radius: 10px;
}
.conv-list button {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  text-align: left;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.conv-list button:hover, .conv-list button[aria-current="true"] { background: var(--ink); }
.conv-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 0.95rem; }
.conv-top time { font-weight: 400; font-size: 0.78rem; color: var(--muted); }
.conv-empty { padding: 12px; }
.conv-sub { font-size: 0.82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-unread { color: var(--text); font-weight: 600; }
.conv-unread .conv-top::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); align-self: center; }
.thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--ink-raised);
  border: 1px solid var(--ink-line);
  border-radius: 10px;
  overflow: hidden;
}
.thread-head { padding: 14px 16px; border-bottom: 1px solid var(--ink-line); font-weight: 600; }
.thread-head small { display: block; font-weight: 400; color: var(--muted); font-size: 0.84rem; }
.thread-head a { color: var(--text); }
.thread-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.thread-log .msg-user { align-self: flex-start; background: var(--ink); color: var(--text); border: 1px solid var(--ink-line); }
.thread-log .msg-owner { align-self: flex-end; background: var(--text); color: var(--ink); }
.thread-log time { display: block; font-size: 0.72rem; opacity: 0.65; margin-top: 3px; }
.thread-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--ink-line); }
.thread-form input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: 0 13px;
  font: 400 1rem var(--body);
  color: var(--text);
  background: var(--ink);
  border: 1px solid var(--ink-line);
  border-radius: 6px;
}
.thread-form input:focus { outline: none; border-color: var(--text); }

/* Messages and AI log */
.card-list { display: grid; gap: 12px; }
.item {
  padding: 16px 18px;
  background: var(--ink-raised);
  border: 1px solid var(--ink-line);
  border-radius: 10px;
}
.item-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; }
.item-top strong { font-size: 1rem; }
.item-meta { font-size: 0.84rem; color: var(--muted); }
.item-body { margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: #DADDF0; }
.item-answer { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--ink-line); color: var(--muted); font-size: 0.92rem; white-space: pre-wrap; }
.item a { color: var(--text); }
.item.is-new { border-color: var(--green); }

@media (max-width: 760px) {
  .live { grid-template-columns: 1fr; height: auto; }
  .conv-list { max-height: 260px; }
  .thread { height: 70svh; }
  .dash-actions { margin-left: 0; }
}
