:root {
  --bg: #fbf7ef;
  --card: #fffdf8;
  --text: #26362b;
  --muted: #6f776f;
  --line: #e7dfd2;
  --primary: #6f8f72;
  --primary-dark: #4f704f;
  --accent: #9a82c6;
  --danger: #a95353;
  --soft: #eef1e5;
  --shadow: 0 10px 30px rgba(38, 54, 43, 0.08);
  --page-bg: var(--bg);
  --topbar-bg: linear-gradient(180deg, var(--bg) 80%, rgba(251,247,239,0));
  --primary-text: #ffffff;
  --primary-shadow: rgba(111,143,114,.22);
  --secondary-btn-bg: #f4efe4;
  --danger-bg: #fff1ef;
  --danger-border: #efd1cc;
  --input-bg: #ffffff;
  --input-file-bg: #fffaf1;
  --details-bg: rgba(255,255,255,.48);
  --tabs-bg: rgba(251,247,239,.92);
  --thumb-bg: linear-gradient(135deg, #edf0e3, #fff5e2);
  --photo-bg: var(--soft);
  --progress-bg: #e5dfd4;
  --warn-bg: #fff8e6;
  --warn-border: #ead8a7;
}

html[data-theme="agent"] {
  color-scheme: dark;
  --bg: #0b1020;
  --card: rgba(17, 24, 39, 0.88);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --line: rgba(148, 163, 184, 0.20);
  --primary: #f59e0b;
  --primary-dark: #f59e0b;
  --accent: #2dd4bf;
  --danger: #ef4444;
  --soft: rgba(245, 158, 11, 0.16);
  --shadow: 0 24px 80px rgba(2, 6, 23, 0.42);
  --page-bg:
    radial-gradient(circle at top left, rgba(45, 212, 191, 0.14), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(245, 158, 11, 0.14), transparent 24%),
    linear-gradient(180deg, #070b16 0%, #0b1020 60%, #090d18 100%);
  --topbar-bg: rgba(9, 14, 28, 0.78);
  --primary-text: #111827;
  --primary-shadow: rgba(245, 158, 11, 0.22);
  --secondary-btn-bg: rgba(15, 23, 42, 0.72);
  --danger-bg: rgba(239, 68, 68, 0.13);
  --danger-border: rgba(239, 68, 68, 0.34);
  --input-bg: rgba(2, 6, 23, 0.42);
  --input-file-bg: rgba(15, 23, 42, 0.62);
  --details-bg: rgba(15, 23, 42, 0.62);
  --tabs-bg: rgba(9, 14, 28, 0.86);
  --thumb-bg: linear-gradient(135deg, rgba(45, 212, 191, 0.16), rgba(245, 158, 11, 0.14));
  --photo-bg: rgba(15, 23, 42, 0.62);
  --progress-bg: rgba(148, 163, 184, 0.18);
  --warn-bg: rgba(15, 23, 42, 0.88);
  --warn-border: rgba(245, 158, 11, 0.42);
}

html[data-theme="agent"] .topbar {
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

html[data-theme="agent"] .card {
  backdrop-filter: blur(10px);
}

html[data-theme="agent"] .btn.secondary,
html[data-theme="agent"] .btn.ghost,
html[data-theme="agent"] .icon-btn,
html[data-theme="agent"] input,
html[data-theme="agent"] textarea,
html[data-theme="agent"] select {
  border-color: rgba(148, 163, 184, 0.24);
}

html[data-theme="agent"] .tabs button.active {
  border: 1px solid rgba(245, 158, 11, 0.42);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--page-bg); color: var(--text); font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
#app { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: 84px; }
.topbar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 12px; background: var(--topbar-bg); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
h1 { margin: 2px 0 0; font-size: 30px; line-height: 1.05; letter-spacing: -0.04em; }
.eyebrow { color: var(--muted); font-size: 13px; }
.view { display: none; padding: 0 14px 20px; }
.view.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card.tight { padding: 12px; border-radius: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.title { font-size: 20px; font-weight: 750; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 14px; line-height: 1.45; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--soft); color: var(--primary-dark); font-weight: 650; font-size: 13px; }
.btn { border: 0; border-radius: 16px; padding: 12px 16px; background: var(--primary); color: var(--primary-text); font-weight: 750; box-shadow: 0 8px 18px var(--primary-shadow); }
.btn.secondary { background: var(--secondary-btn-bg); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--primary-dark); border: 1px solid var(--line); box-shadow: none; }
.btn.danger { background: var(--danger-bg); color: var(--danger); box-shadow: none; border: 1px solid var(--danger-border); }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 9px 12px; color: var(--text); }
.preset { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.exercise-card { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: start; }
.thumb { width: 92px; height: 92px; border-radius: 18px; background: var(--thumb-bg); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); color: var(--primary-dark); font-weight: 800; text-align: center; padding: 8px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 2px; }
.photo { flex: 0 0 120px; height: 88px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--photo-bg); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo button { position: absolute; top: 5px; right: 5px; border: 0; border-radius: 50%; background: rgba(255,255,255,.85); width: 26px; height: 26px; color: var(--danger); }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; background: var(--input-bg); color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
input[type="file"] { padding: 10px; background: var(--input-file-bg); }
input[type="checkbox"] { width: auto; }
details { border: 1px solid var(--line); border-radius: 18px; padding: 12px; background: var(--details-bg); }
summary { cursor: pointer; font-weight: 750; }
.timer-screen { min-height: calc(100vh - 168px); display: grid; align-content: center; gap: 14px; }
.hero-photo { min-height: 240px; border-radius: 28px; border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; background: var(--thumb-bg); text-align: center; padding: 20px; }
.hero-photo img { width: 100%; height: 100%; max-height: 420px; object-fit: cover; border-radius: 24px; }
.timer { font-size: 58px; font-weight: 850; letter-spacing: -0.06em; text-align: center; }
.progress { height: 9px; border-radius: 999px; background: var(--progress-bg); overflow: hidden; }
.progress > div { height: 100%; width: 0%; background: var(--primary); border-radius: inherit; transition: width .25s; }
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 4; width: min(760px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--tabs-bg); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 14px; background: transparent; padding: 10px 4px; color: var(--muted); font-weight: 700; font-size: 13px; }
.tabs button.active { background: var(--soft); color: var(--primary-dark); }
.empty { border: 1px dashed var(--line); border-radius: 18px; padding: 18px; color: var(--muted); text-align: center; }
.small { font-size: 13px; color: var(--muted); }
.warn { background: var(--warn-bg); border-color: var(--warn-border); }
@media (max-width: 480px) {
  h1 { font-size: 27px; }
  .topbar { align-items: flex-start; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .exercise-card { grid-template-columns: 78px 1fr; }
  .thumb { width: 78px; height: 78px; }
  .timer { font-size: 50px; }
}
