:root {
  --bg: #f4f5f3; --surface: #ffffff; --surface-2: #fafbf9;
  --text: #2b2f2d; --muted: #6b716d; --border: #e3e6e1;
  --accent: #5f8d6b; --accent-weak: #e7efe8; --danger: #b4694f; --danger-weak: #f4e7e2;
  --shadow: 0 1px 2px rgba(20,30,24,.04), 0 4px 16px rgba(20,30,24,.05);
  --radius: 14px; --radius-sm: 9px;
}
html[data-theme="dark"] {
  --bg: #15181b; --surface: #1d2125; --surface-2: #20252a;
  --text: #d9ddd8; --muted: #8b938c; --border: #2c333a;
  --accent: #82ab8b; --accent-weak: #243029; --danger: #cf8a73; --danger-weak: #33241f;
  --shadow: 0 1px 2px rgba(0,0,0,.2), 0 6px 20px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased; font-size: 15px;
}
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.field { margin-bottom: 14px; }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; font-weight: 550; transition: filter .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.subtle { background: var(--accent-weak); color: var(--accent); }
.btn.danger { background: var(--danger-weak); color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hidden { display: none !important; }

/* Login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.login-card p { margin: 0 0 22px; }

/* App shell */
.topbar {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  padding: 12px 20px; display: flex; align-items: center; gap: 16px;
}
.topbar .brand { font-weight: 650; letter-spacing: -.01em; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--accent); } .dot.bad { background: var(--danger); }
.status-pill { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.iconbtn { background: transparent; border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; color: var(--text); }

.container { max-width: 980px; margin: 0 auto; padding: 22px 20px 60px; }
.tabs { display: flex; gap: 4px; margin-bottom: 22px; flex-wrap: wrap; }
.tab { background: transparent; border: none; color: var(--muted); padding: 9px 14px; border-radius: 9px; font-weight: 550; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.card h3 { font-size: 14px; margin: 0 0 10px; font-weight: 600; }

.bm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.bm-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 15px; cursor: pointer; background: var(--surface-2); transition: border-color .15s, transform .05s; }
.bm-card:hover { border-color: var(--accent); }
.bm-card:active { transform: scale(.995); }
.bm-card .num { font-weight: 600; font-size: 15px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 100px; background: var(--accent-weak); color: var(--accent); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 550; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td .row { gap: 6px; }
code.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }

textarea.prompt { min-height: 420px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.55; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; z-index: 100; max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumb a { cursor: pointer; }
.skill-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.skill-item .name { font-weight: 550; }
.spin { display:inline-block; width:14px; height:14px; border:2px solid var(--border); border-top-color: var(--accent); border-radius:50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (max-width: 560px) {
  .container { padding: 16px 14px 50px; } .topbar { padding: 10px 14px; gap: 10px; }
  th.hide-sm, td.hide-sm { display: none; }
}
