/* Selah Stone, matching site/ and the iMun app. */
:root {
  --canvas: #131516;
  --surface: #1e2122;
  --raised: #2a2d2d;
  --outline: rgba(110, 115, 114, 0.4);
  --ink: #f0eee9;
  --secondary: #a4a6a3;
  --accent: #d8d3c7;
  --good: #5cd4ad;
  --amber: #ffba63;
  --danger: #ff7579;
  --spring: cubic-bezier(0.34, 1.36, 0.64, 1);
  --glass: rgba(30, 33, 34, 0.6);
  --glass-edge: rgba(240, 238, 233, 0.14);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); color: var(--ink); }
body { font: 400 16px/1.5 "Space Grotesk", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body.locked { overflow: hidden; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.02em; margin: 0; }
.mono, .num { font-family: "Space Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--secondary); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.boot { color: var(--secondary); text-align: center; margin-top: 30vh; }
[hidden] { display: none !important; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 1px 0 rgba(240, 238, 233, 0.08) inset, 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* Forms and buttons */
label { display: grid; gap: 6px; font-size: 14px; color: var(--secondary); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--outline); border-radius: 12px; padding: 12px 14px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 14px;
  padding: 13px 20px; background: var(--accent); color: var(--canvas);
  transition: transform .25s var(--spring), opacity .2s;
}
.btn:active { transform: scale(0.96); }
.btn:disabled, .btn.secondary:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--raised); color: var(--ink); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 117, 121, .4); }
.link { font: inherit; background: none; border: 0; color: var(--secondary); cursor: pointer; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.stack { display: grid; gap: 14px; }

/* Sign-in and 2FA */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); border-radius: 28px; padding: 32px 26px; text-align: left; }
.auth-logo { border-radius: 14px; display: block; margin-bottom: 18px; }
.auth h1 { font-size: 26px; margin-bottom: 6px; }
.auth .muted { margin: 0 0 22px; }
.code { font-family: "Space Mono", monospace; font-size: 26px; letter-spacing: .3em; text-align: center; }
.qr { background: #fff; border-radius: 14px; padding: 10px; justify-self: center; }
.secret { display: block; margin-top: 8px; word-break: break-all; font-family: "Space Mono", monospace; font-size: 13px; background: var(--surface); padding: 10px; border-radius: 10px; }
.steps { margin: 0; padding-left: 20px; color: var(--secondary); font-size: 14px; display: grid; gap: 4px; }
details summary { cursor: pointer; color: var(--secondary); font-size: 14px; }

/* App shell */
.bar {
  position: sticky; top: max(10px, env(safe-area-inset-top)); z-index: 20;
  margin: 10px 16px 0; height: 56px; padding: 0 10px; border-radius: 999px;
  display: flex; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand img { border-radius: 7px; }
.bar-title { margin-left: auto; margin-right: 10px; color: var(--secondary); font-size: 15px; }
.menu-btn {
  width: 44px; height: 44px; border: 0; border-radius: 999px; background: transparent;
  display: grid; place-content: center; gap: 4px; cursor: pointer; transition: background .2s, transform .25s var(--spring);
}
.menu-btn:hover { background: rgba(240, 238, 233, .08); }
.menu-btn:active { transform: scale(.92); }
.menu-btn span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--ink); }

.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .45); opacity: 0; transition: opacity .3s ease; }
.scrim.show { opacity: 1; }
.drawer {
  position: fixed; z-index: 40; top: 8px; bottom: 8px; left: 8px; width: min(320px, 84vw);
  border-radius: 28px; padding: 22px 14px; display: flex; flex-direction: column; gap: 2px;
  transform: translateX(calc(-100% - 24px)); transition: transform .5s var(--spring); overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer.dragging { transition: none; }
.drawer-head { display: flex; gap: 12px; align-items: center; padding: 0 10px 14px; }
.drawer-head img { border-radius: 10px; }
.drawer-head strong { display: block; font-size: 18px; font-weight: 600; }
.drawer-head small { color: var(--secondary); font-size: 13px; }
.drawer-label { font: 11px "Space Mono", monospace; text-transform: uppercase; letter-spacing: .08em; color: var(--secondary); margin: 16px 12px 4px; }
.drawer-item {
  font: inherit; font-weight: 500; color: var(--ink); text-align: left; background: none; border: 0;
  padding: 12px; border-radius: 12px; cursor: pointer; transition: background .2s, transform .25s var(--spring);
}
.drawer-item:hover { background: rgba(240, 238, 233, .08); }
.drawer-item:active { transform: scale(.97); }
.drawer-item.active { background: var(--accent); color: var(--canvas); }
.drawer-foot { margin-top: auto; padding: 14px 12px 0; display: grid; gap: 4px; font-size: 13px; }
.drawer-foot .who { color: var(--secondary); overflow-wrap: anywhere; }
.drawer-foot .link { justify-self: start; padding: 4px 0; }

main#main { max-width: 980px; margin: 0 auto; padding: 24px 16px 80px; }
.content { display: grid; gap: 14px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 6px; }
.page-head h2 { font-size: 30px; }
.eyebrow { font: 12px "Space Mono", monospace; text-transform: uppercase; letter-spacing: .1em; color: var(--secondary); margin: 0 0 6px; }

.card { background: var(--surface); border: 1px solid rgba(110, 115, 114, .25); border-radius: 20px; padding: 20px; }
.card h3 { font-size: 18px; margin-bottom: 6px; }
.card p { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.metric { background: var(--raised); border-radius: 14px; padding: 12px 14px; }
.metric .label { font-size: 12px; color: var(--secondary); }
.metric .value { font: 500 22px "Space Mono", monospace; }
.metric .value small { font-size: 12px; color: var(--secondary); margin-left: 4px; }

.list { display: grid; gap: 8px; margin-top: 12px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--raised); border-radius: 12px; padding: 11px 14px; }
.row .num { color: var(--secondary); white-space: nowrap; font-size: 14px; }
.row.done { opacity: .6; }
.tag { font: 11px "Space Mono", monospace; padding: 3px 8px; border-radius: 999px; background: rgba(240, 238, 233, .08); color: var(--secondary); white-space: nowrap; }
.tag.good { color: var(--good); }
.tag.warn { color: var(--amber); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid rgba(110, 115, 114, .25); }
th { color: var(--secondary); font-weight: 400; font-size: 12px; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.spark { width: 100%; height: 48px; display: block; margin-top: 8px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--raised); color: var(--ink); border: 1px solid var(--glass-edge);
  padding: 12px 18px; border-radius: 14px; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; } }

/* Workout detail */
.exercise { display: grid; gap: 6px; }
.sets { display: grid; gap: 4px; padding: 0 14px; }
.set { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--secondary); }
.set .tag { margin-right: auto; }
.small { font-size: 13px; }

/* Logging and editing */
.mini { width: 84px; padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.log-set { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 14px 0; }
.log-set .num { color: var(--secondary); font-size: 13px; min-width: 52px; }
.log-set .error { flex-basis: 100%; min-height: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.editor { display: grid; gap: 8px; }
.edit-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--raised); border-radius: 12px; padding: 10px 12px; }
.edit-fields { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.edit-fields .mini { width: 64px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; }
.check input { width: 18px; height: 18px; }

/* IsAIah chat */
.chat { display: grid; gap: 14px; }
.chat-log { display: grid; gap: 10px; max-height: 60dvh; overflow-y: auto; }
.bubble { padding: 12px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 85%; }
.bubble.user { justify-self: end; background: var(--accent); color: var(--canvas); border-bottom-right-radius: 6px; }
.bubble.coach { justify-self: start; background: var(--raised); border-bottom-left-radius: 6px; }
.bubble.pending { color: var(--secondary); }
.chat-form { display: grid; gap: 10px; }
.chat-form textarea { resize: vertical; min-height: 56px; }
.chat-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
input[type=checkbox] { accent-color: var(--accent); }
