:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg2: #0f172a;
  --card: rgba(255,255,255,.075);
  --card2: rgba(255,255,255,.105);
  --line: rgba(255,255,255,.12);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted2: #cbd5e1;
  --accent: #38bdf8;
  --accent2: #22c55e;
  --danger: #fb7185;
  --warn: #fbbf24;
  --shadow: 0 20px 60px rgba(0,0,0,.35);
  --radius: 24px;
  --radius2: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  background:
    radial-gradient(circle at top left, rgba(56,189,248,.23), transparent 30rem),
    radial-gradient(circle at 80% 10%, rgba(34,197,94,.12), transparent 25rem),
    linear-gradient(180deg, #07111f 0%, #0f172a 48%, #020617 100%);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }

.app-shell { width: min(100%, 760px); margin: 0 auto; min-height: 100vh; padding: 18px 16px 110px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 20; padding: 12px 0 10px; backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo { width: 43px; height: 43px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, #38bdf8, #22c55e); color: #020617; font-weight: 900; box-shadow: var(--shadow); }
.brand-title { font-size: 17px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; }

h1 { margin: 18px 0 8px; font-size: 34px; line-height: 1.02; letter-spacing: -.05em; }
h2 { margin: 0 0 12px; font-size: 22px; letter-spacing: -.03em; }
h3 { margin: 0 0 8px; font-size: 17px; letter-spacing: -.02em; }
p { color: var(--muted2); line-height: 1.45; }
.small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.muted { color: var(--muted); }
.strong { color: var(--text); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; backdrop-filter: blur(20px); }
.card + .card { margin-top: 12px; }
.soft { background: rgba(255,255,255,.055); }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hero { padding: 20px; overflow: hidden; position: relative; }
.hero:after { content: ""; position: absolute; right: -80px; top: -80px; width: 180px; height: 180px; background: radial-gradient(circle, rgba(56,189,248,.28), transparent 65%); }
.hero p { margin: 10px 0 0; max-width: 34rem; }

.btn { border: 0; border-radius: 16px; padding: 12px 14px; background: rgba(255,255,255,.1); color: var(--text); font-weight: 750; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s ease, background .12s ease, border-color .12s ease; border: 1px solid rgba(255,255,255,.10); }
.btn:active { transform: scale(.985); }
.btn.primary { background: linear-gradient(135deg, #38bdf8, #22c55e); color: #020617; border-color: transparent; }
.btn.ghost { background: rgba(255,255,255,.055); }
.btn.danger { background: rgba(251,113,133,.12); color: #fecdd3; border-color: rgba(251,113,133,.35); }
.btn.warn { background: rgba(251,191,36,.12); color: #fde68a; border-color: rgba(251,191,36,.30); }
.btn.small-btn { min-height: 36px; padding: 8px 10px; border-radius: 13px; font-size: 13px; }
.btn.full { width: 100%; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }

.input, select, textarea { width: 100%; border: 1px solid rgba(255,255,255,.12); background: rgba(2,6,23,.35); color: var(--text); border-radius: 16px; padding: 12px 13px; outline: none; min-height: 46px; }
.input:focus, select:focus, textarea:focus { border-color: rgba(56,189,248,.8); box-shadow: 0 0 0 4px rgba(56,189,248,.12); }
textarea { min-height: 86px; resize: vertical; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-grid .wide { grid-column: 1 / -1; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.07); color: var(--muted2); border-radius: 999px; padding: 8px 10px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.pill.active { color: #020617; border-color: transparent; background: linear-gradient(135deg, #38bdf8, #22c55e); }
.pill.green { color: #bbf7d0; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.26); }
.pill.blue { color: #bae6fd; background: rgba(56,189,248,.12); border-color: rgba(56,189,248,.26); }
.pill.yellow { color: #fde68a; background: rgba(251,191,36,.10); border-color: rgba(251,191,36,.24); }

.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: rgba(255,255,255,.06); border: 1px solid var(--line); padding: 5px; border-radius: 18px; }
.segment button { border: 0; border-radius: 13px; min-height: 40px; background: transparent; color: var(--muted); font-weight: 750; }
.segment button.active { background: rgba(255,255,255,.12); color: var(--text); }

.list { display: grid; gap: 12px; margin-top: 14px; }
.item-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.item-title { font-weight: 850; font-size: 17px; letter-spacing: -.02em; }
.item-meta { color: var(--muted); font-size: 12px; margin-top: 5px; }
.statline { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.stat { padding: 10px; border-radius: 16px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); }
.stat b { display: block; font-size: 15px; }
.stat span { color: var(--muted); font-size: 11px; }

.exercise { position: relative; }
.exercise-main { display: grid; gap: 12px; }
.exercise-name-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.exercise-name { font-size: 18px; font-weight: 900; letter-spacing: -.03em; }
.exercise-data { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.exercise-data .mini { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); border-radius: 15px; padding: 9px; }
.exercise-data span { color: var(--muted); font-size: 11px; display: block; }
.exercise-data b { font-size: 16px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.72); backdrop-filter: blur(16px); z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 14px; }
.modal { width: min(100%, 720px); max-height: min(88vh, 760px); overflow: auto; background: #0f172a; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); padding: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.modal-title { font-size: 20px; font-weight: 900; letter-spacing: -.03em; }
.modal-actions { position: sticky; bottom: -16px; background: linear-gradient(180deg, rgba(15,23,42,0), #0f172a 22%); padding-top: 18px; display: flex; gap: 8px; margin-top: 12px; }

.library-grid { display: grid; gap: 8px; margin-top: 12px; }
.library-item { text-align: left; width: 100%; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.055); color: var(--text); padding: 13px; border-radius: 17px; }
.library-item b { display: block; }
.library-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; background: rgba(15,23,42,.95); border: 1px solid rgba(255,255,255,.15); color: var(--text); padding: 12px 14px; border-radius: 999px; box-shadow: var(--shadow); max-width: calc(100% - 28px); font-size: 13px; }

.lock-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; }
.lock-card { width: min(100%, 440px); }
.lock-logo { width: 68px; height: 68px; border-radius: 24px; background: linear-gradient(135deg, #38bdf8, #22c55e); color: #020617; font-size: 24px; font-weight: 950; display: grid; place-items: center; margin-bottom: 16px; }
.notice { border: 1px solid rgba(56,189,248,.24); background: rgba(56,189,248,.09); color: #dbeafe; border-radius: 18px; padding: 12px; font-size: 13px; line-height: 1.45; }
.notice.warnish { border-color: rgba(251,191,36,.25); background: rgba(251,191,36,.08); color: #fef3c7; }

.empty { text-align: center; padding: 28px 18px; }
.empty .emoji { font-size: 34px; margin-bottom: 8px; }

.footer-nav { position: fixed; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px), 720px); z-index: 40; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: rgba(2,6,23,.70); backdrop-filter: blur(18px); border: 1px solid rgba(255,255,255,.12); border-radius: 24px; padding: 8px; box-shadow: var(--shadow); }
.footer-nav button { border: 0; border-radius: 17px; min-height: 48px; background: transparent; color: var(--muted); font-weight: 800; }
.footer-nav button.active { background: rgba(255,255,255,.12); color: var(--text); }

@media (max-width: 520px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 30px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr 1fr; }
  .form-grid .wide-sm { grid-column: 1 / -1; }
  .exercise-data { grid-template-columns: repeat(3, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
  .top-actions .hide-sm { display: none; }
}
