:root {
  --bg: #0b0d10;
  --panel: #14171c;
  --panel-2: #1a1e24;
  --line: #262b33;
  --text: #e6e9ee;
  --dim: #8b94a3;
  --accent: #6ea8fe;
  --good: #4ade80;
  --bad: #f87171;
  --wait: #fbbf24;
  --radius: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #f0f2f5;
    --line: #dfe3e8;
    --text: #14171c;
    --dim: #5f6875;
    --accent: #1f6feb;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

code, pre { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 13px; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--panel);
}

.brand { font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand .mark { color: var(--accent); }
.brand.big { font-size: 20px; justify-content: center; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--dim); text-decoration: none; padding: 8px 10px;
  border-radius: 8px; font-size: 14px;
}
.sidebar nav a:hover { background: var(--panel-2); color: var(--text); }
.sidebar nav a.active { background: var(--panel-2); color: var(--text); font-weight: 550; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.who { display: flex; align-items: center; gap: 10px; }
.who img { width: 30px; height: 30px; border-radius: 50%; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text strong { font-size: 13px; font-weight: 550; }
.who-text span { font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
.subscription-note { font-size: 11px; color: var(--dim); line-height: 1.4; border-top: 1px solid var(--line); padding-top: 10px; }
.build-tag { font-size: 11px; color: var(--dim); font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); opacity: 0.7; }

.content { flex: 1; padding: 26px 30px 60px; max-width: 1180px; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 14px; margin: 0 0 14px; font-weight: 600; letter-spacing: 0.01em; }
.sub { color: var(--dim); font-size: 13px; margin: 4px 0 0; }

.period { display: flex; gap: 4px; }
.period a {
  color: var(--dim); text-decoration: none; font-size: 13px;
  padding: 5px 11px; border-radius: 7px; border: 1px solid var(--line);
}
.period a.on { color: var(--text); background: var(--panel-2); border-color: var(--accent); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 5px;
}
.card-label { font-size: 12px; color: var(--dim); }
.card-value { font-size: 26px; font-weight: 620; letter-spacing: -0.02em; }
.card-foot { font-size: 11px; color: var(--dim); }
.card-foot.bad { color: var(--bad); }
.card.accent .card-value { color: var(--accent); }
.card.good .card-value { color: var(--good); }

.savings {
  background: linear-gradient(90deg, rgba(74,222,128,0.10), transparent);
  border: 1px solid var(--line); border-left: 3px solid var(--good);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; font-size: 14px;
}
.savings strong { color: var(--good); }

/* ---------- panels ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--dim); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
.right { text-align: right; }
.dim { color: var(--dim); }
tr.revoked { opacity: 0.5; }

.model {
  font-family: ui-monospace, monospace; font-size: 12px;
  background: var(--panel-2); padding: 2px 7px; border-radius: 5px;
}

.pill { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.pill.ok { background: rgba(74,222,128,0.14); color: var(--good); }
.pill.bad { background: rgba(248,113,113,0.14); color: var(--bad); }
.pill.wait { background: rgba(251,191,36,0.14); color: var(--wait); }

.empty { color: var(--dim); font-size: 13px; margin: 6px 0; }
.fineprint { color: var(--dim); font-size: 12px; line-height: 1.6; margin-top: 20px; }

/* ---------- chart ---------- */
.chart {
  display: flex; align-items: flex-end; gap: 3px;
  height: 130px; padding-top: 10px; overflow-x: auto;
}
/* max-width keeps a single day from rendering as one page-wide slab. */
.bar-wrap { flex: 1; min-width: 12px; max-width: 60px; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 5px; }
.bar { width: 100%; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; opacity: 0.75; transition: opacity .15s; }
.bar-wrap:hover .bar { opacity: 1; }
.bar-label { font-size: 10px; color: var(--dim); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > span { font-size: 12px; color: var(--dim); }

input[type=text], input[type=number], textarea, select {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font: inherit; font-size: 14px; width: 100%;
}
textarea { resize: vertical; font-family: inherit; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  font: inherit; font-size: 14px; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); padding: 9px 15px;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #08101f; font-weight: 550; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); font-size: 12px; padding: 5px 11px; }
button.wide { width: 100%; }
button.link { background: none; border: none; color: var(--dim); padding: 0; font-size: 13px; text-align: left; }
button.link:hover { color: var(--text); }

.row-form { display: flex; gap: 9px; }
.row-form input { flex: 1; }
.row-form input[type=number] { flex: 0 0 120px; }

.alert { padding: 10px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 13px; }
.alert.error { background: rgba(248,113,113,0.12); color: var(--bad); border: 1px solid rgba(248,113,113,0.3); }
.alert.warn { background: rgba(251,191,36,0.10); color: var(--wait); border: 1px solid rgba(251,191,36,0.28); }

.secret { margin-top: 14px; }
.secret-row { display: flex; gap: 9px; align-items: center; }
.secret-row code {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  padding: 10px 12px; border-radius: 8px; overflow-x: auto; white-space: nowrap;
}

pre {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 13px; overflow-x: auto; margin: 0 0 12px;
}

.hidden { display: none !important; }

/* ---------- playground ---------- */
.pg { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .pg { grid-template-columns: 1fr; } .shell { flex-direction: column; } .sidebar { width: 100%; flex: none; } }

.pg-output { min-height: 420px; }
.pg-output-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.meta { font-size: 12px; color: var(--dim); }
.hint { font-size: 12px; color: var(--dim); margin: 10px 0 0; }

.answer { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.6; max-height: 62vh; overflow-y: auto; }
.status { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 9px; padding: 10px 0; }
.spinner {
  width: 13px; height: 13px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.media img, .media video { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.media .dl { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--accent); }

/* ---------- panel headers and small actions ---------- */
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel-head h2 { margin-bottom: 14px; }
button.small { font-size: 12px; padding: 5px 11px; }
.small-link { font-size: 12px; color: var(--accent); text-decoration: none; }
.small-link:hover { text-decoration: underline; }

/* ---------- playground: dialogue ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 62vh; overflow-y: auto; padding-right: 4px; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.msg.user { background: var(--panel-2); }
.msg.error { border-color: rgba(248,113,113,0.4); }
.msg-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px;
}
.msg.error .msg-head { color: var(--bad); }
.msg-meta { text-transform: none; letter-spacing: 0; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; line-height: 1.6; }
.session { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--dim); }

/* ---------- playground: reference images ---------- */
.file-drop {
  display: block; text-align: center; cursor: pointer;
  border: 1px dashed var(--line); border-radius: 8px; padding: 12px;
  font-size: 13px; color: var(--dim);
}
.file-drop:hover { border-color: var(--accent); color: var(--text); }
.refs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ref { position: relative; width: 60px; height: 60px; }
.ref img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.ref-remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px;
  padding: 0; line-height: 1; border-radius: 50%;
  background: var(--panel); color: var(--dim); font-size: 14px;
}
.ref-remove:hover { color: var(--bad); border-color: var(--bad); }

/* ---------- gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.shot {
  margin: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.shot img, .shot video { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--bg); }
.shot-gone {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 16px; font-size: 12px; color: var(--dim); background: var(--panel-2);
}
.shot figcaption { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.shot-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 11px; }
.shot-prompt {
  margin: 0; font-size: 12px; line-height: 1.5; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.shot-foot { font-size: 11px; }
.shot-foot a { color: var(--accent); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 34px; width: 100%; max-width: 400px; text-align: center;
}
.login-lede { color: var(--dim); font-size: 13px; line-height: 1.6; margin: 14px 0 22px; }
.login-note { color: var(--dim); font-size: 11.5px; line-height: 1.6; margin: 18px 0 0; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px; border-radius: 8px;
  background: #fff; color: #1f1f1f; font-weight: 550; font-size: 14px;
  text-decoration: none; border: 1px solid var(--line);
}
.google-btn:hover { filter: brightness(0.96); }
