/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #0d0d14;
  --bg2:      #13131f;
  --bg3:      #1c1c2e;
  --bg4:      #252538;
  --border:   #2e2e48;
  --accent:   #7c3aed;
  --accent2:  #a855f7;
  --cyan:     #06b6d4;
  --green:    #10b981;
  --yellow:   #f59e0b;
  --red:      #ef4444;
  --text:     #e2e8f0;
  --text2:    #94a3b8;
  --text3:    #64748b;
  --radius:   12px;
  --radius-s: 8px;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
  --transition: .18s ease;
}

html { font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
}

a { color: var(--accent2); text-decoration: none; }
button { cursor: pointer; border: none; background: none; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ─── Login Screen ───────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #2a1a5e 0%, var(--bg) 60%);
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 340px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 2rem; font-weight: 800; color: var(--accent2); margin-bottom: .25rem; letter-spacing: -1px; }
.login-sub  { color: var(--text2); font-size: .875rem; margin-bottom: 2rem; }
.login-box input[type=password] {
  width: 100%;
  padding: .75rem 1rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 1rem;
}
.login-box input[type=password]:focus { border-color: var(--accent); }
.login-error { color: var(--red); font-size: .8125rem; margin-top: -.5rem; margin-bottom: .75rem; }

/* ─── App Layout ─────────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent2);
  padding: 0 1.25rem 1.5rem;
  letter-spacing: -.5px;
}
.nav-section { padding: 0 .75rem; margin-bottom: .5rem; }
.nav-section-label {
  font-size: .6875rem;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .25rem .5rem;
  margin-bottom: .25rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-s);
  color: var(--text2);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(124,58,237,.2); color: var(--accent2); }
.nav-item .icon { font-size: 1rem; width: 1.25rem; text-align: center; }

.sidebar-bottom { margin-top: auto; padding: 0 .75rem; }

/* Main */
.main { flex: 1; min-width: 0; overflow-y: auto; }
.page { display: none; padding: 2rem; max-width: 900px; margin: 0 auto; }
.page.active { display: block; }

/* ─── Common Components ───────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.5px; }
.page-sub   { color: var(--text2); font-size: .875rem; margin-top: .125rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-s);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost { color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-sm { padding: .3rem .7rem; font-size: .8125rem; }
.btn-icon { padding: .4rem; border-radius: var(--radius-s); }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: .125rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-high   { background: rgba(239,68,68,.15);  color: var(--red); }
.badge-medium { background: rgba(245,158,11,.15); color: var(--yellow); }
.badge-low    { background: rgba(16,185,129,.15); color: var(--green); }
.badge-habit  { background: rgba(6,182,212,.15);  color: var(--cyan); }
.badge-once   { background: rgba(124,58,237,.15); color: var(--accent2); }
.badge-project{ background: rgba(245,158,11,.15); color: var(--yellow); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9375rem; }

/* ─── Forms / Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5vh;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 520px;
  max-width: calc(100vw - 2rem);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: translateY(-16px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .625rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: .375rem;
}
.form-control {
  width: 100%;
  padding: .625rem .875rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ─── TODAY VIEW ─────────────────────────────────────────────────────────── */
.today-greeting {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -.5px;
  margin-bottom: .25rem;
}
.today-date { color: var(--text2); font-size: .9375rem; margin-bottom: 1.5rem; }

.today-progress {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.progress-label { font-size: .8125rem; color: var(--text2); white-space: nowrap; }
.progress-bar   { flex: 1; height: 6px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.progress-fill  { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 3px; transition: width .4s ease; }
.progress-pct   { font-size: .8125rem; font-weight: 600; color: var(--accent2); white-space: nowrap; }

.today-section { margin-bottom: 1.5rem; }
.today-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.today-section-title { font-size: .9375rem; font-weight: 600; }

/* Task items */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem .875rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  margin-bottom: .5rem;
  transition: all var(--transition);
  cursor: pointer;
}
.task-item:hover { border-color: var(--accent); background: var(--bg3); }
.task-item.done { opacity: .5; }
.task-item.done .task-title { text-decoration: line-through; }

.task-checkbox {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: .125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.task-item.done .task-checkbox { background: var(--green); border-color: var(--green); }
.task-checkbox::after { content: ''; display: none; width: .375rem; height: .375rem; background: #fff; border-radius: 50%; }
.task-item.done .task-checkbox::after { display: block; }

.task-info { flex: 1; min-width: 0; }
.task-title { font-size: .9375rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta  { display: flex; align-items: center; gap: .5rem; margin-top: .25rem; flex-wrap: wrap; }
.task-meta .meta-item { font-size: .75rem; color: var(--text3); }
.task-actions { display: flex; gap: .25rem; opacity: 0; transition: opacity var(--transition); align-items: center; }
.task-item:hover .task-actions { opacity: 1; }
/* スマホ: 常時表示 */
@media (hover: none) { .task-actions { opacity: 1; } }

/* 習慣が今日完了済み → strikethrough なしでチェック状態を示す */
.task-item.habit-checked { background: rgba(16,185,129,.06); border-color: rgba(16,185,129,.3); }
.task-item.habit-checked .task-checkbox {
  background: var(--green); border-color: var(--green);
}
.task-item.habit-checked .task-checkbox::after { display: block; }
.task-item.habit-checked .task-title { color: var(--text2); }

/* 運動カテゴリの特別スタイル */
.exercise-task {
  border-color: rgba(249,115,22,.35);
  background: linear-gradient(135deg, rgba(249,115,22,.06) 0%, var(--bg2) 100%);
}
.exercise-task:hover {
  border-color: rgba(249,115,22,.7);
  background: linear-gradient(135deg, rgba(249,115,22,.1) 0%, var(--bg3) 100%);
}
.exercise-task .task-checkbox {
  border-color: rgba(249,115,22,.5);
}
.exercise-task.done .task-checkbox {
  background: #f97316;
  border-color: #f97316;
}
.exercise-log-btn {
  background: rgba(249,115,22,.15);
  color: #f97316;
  border: 1px solid rgba(249,115,22,.3);
  font-size: .75rem;
  padding: .25rem .6rem;
  border-radius: var(--radius-s);
  white-space: nowrap;
  transition: all var(--transition);
}
.exercise-log-btn:hover {
  background: rgba(249,115,22,.3);
}

/* ─── TASKS VIEW ─────────────────────────────────────────────────────────── */
.tasks-toolbar {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.tasks-filter {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}
.filter-btn {
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text2);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.filter-btn:hover { background: var(--bg3); color: var(--text); }
.filter-btn.active { background: rgba(124,58,237,.2); border-color: var(--accent); color: var(--accent2); }

.project-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ─── WORKOUT VIEW ───────────────────────────────────────────────────────── */
.workout-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
}
.stat-value { font-size: 2rem; font-weight: 800; letter-spacing: -1px; color: var(--accent2); }
.stat-label { font-size: .8125rem; color: var(--text2); margin-top: .125rem; }
.stat-sub   { font-size: .75rem; color: var(--text3); }

.workout-calendar {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.cal-title { font-weight: 600; }
.cal-nav   { display: flex; gap: .375rem; }
.cal-grid  { display: grid; grid-template-columns: repeat(7, 1fr); gap: .375rem; }
.cal-day-label {
  text-align: center;
  font-size: .6875rem;
  font-weight: 600;
  color: var(--text3);
  padding: .25rem 0;
  letter-spacing: .05em;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8125rem;
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
}
.cal-day:hover     { background: var(--bg4); }
.cal-day.has-workout { background: rgba(124,58,237,.3); color: var(--accent2); font-weight: 600; }
.cal-day.today      { outline: 2px solid var(--accent); }
.cal-day.other-month { opacity: .3; }

.workout-list { display: flex; flex-direction: column; gap: .5rem; }
.workout-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .875rem 1.125rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  transition: all var(--transition);
  cursor: pointer;
}
.workout-item:hover { border-color: var(--accent); }
.workout-date-badge {
  text-align: center;
  min-width: 42px;
}
.workout-date-day   { font-size: 1.25rem; font-weight: 700; line-height: 1; }
.workout-date-month { font-size: .6875rem; color: var(--text3); }
.workout-info { flex: 1; }
.workout-name { font-weight: 600; font-size: .9375rem; }
.workout-meta { font-size: .8125rem; color: var(--text2); margin-top: .125rem; }

/* Exercise log in workout modal */
.exercise-list { display: flex; flex-direction: column; gap: .625rem; margin-bottom: .625rem; }
.exercise-row {
  display: grid;
  grid-template-columns: 1fr 60px 60px 70px auto;
  gap: .5rem;
  align-items: center;
}
.ex-header { font-size: .6875rem; color: var(--text3); font-weight: 600; letter-spacing: .05em; }

/* ─── STATS VIEW ─────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.heatmap-wrap { overflow-x: auto; }
.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 3px;
  min-width: max-content;
}
.hm-cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--bg4);
}
.hm-cell[data-level="1"] { background: rgba(124,58,237,.3); }
.hm-cell[data-level="2"] { background: rgba(124,58,237,.6); }
.hm-cell[data-level="3"] { background: var(--accent); }

.achievement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.achievement {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: .875rem;
  text-align: center;
  transition: all var(--transition);
}
.achievement.earned { border-color: var(--yellow); background: rgba(245,158,11,.06); }
.achievement.locked { opacity: .4; }
.achievement .ach-icon { font-size: 1.75rem; margin-bottom: .375rem; }
.achievement .ach-name { font-size: .75rem; font-weight: 600; }
.achievement .ach-desc { font-size: .6875rem; color: var(--text3); margin-top: .125rem; }

.habit-streak-list { display: flex; flex-direction: column; gap: .625rem; }
.habit-streak-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1rem;
  background: var(--bg3);
  border-radius: var(--radius-s);
}
.habit-streak-name { flex: 1; font-size: .875rem; }
.habit-streak-days { font-size: 1.125rem; font-weight: 700; color: var(--cyan); }
.habit-streak-unit { font-size: .75rem; color: var(--text3); }

/* ─── Quick Add ──────────────────────────────────────────────────────────── */
.quick-add-wrap {
  margin-bottom: 1rem;
}
.quick-add {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem .875rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  cursor: text;
  transition: border-color var(--transition);
}
.quick-add:focus-within { border-color: var(--accent); }
.quick-add input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  min-width: 0;
}
.quick-add input::placeholder { color: var(--text3); }

/* クイック追加トグル */
.qa-type {
  padding: .25rem .625rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text3);
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition);
}
.qa-type:hover { color: var(--text); background: var(--bg3); }
.qa-type.active { background: rgba(124,58,237,.2); border-color: var(--accent); color: var(--accent2); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 200;
}
.toast {
  padding: .75rem 1.125rem;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  font-size: .875rem;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }
.toast-action-btn {
  margin-left: .5rem;
  padding: .125rem .5rem;
  border-radius: var(--radius-s);
  font-size: .75rem;
  font-weight: 600;
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  cursor: pointer;
  transition: background var(--transition);
}
.toast-action-btn:hover { background: rgba(255,255,255,.25); }

/* ─── Category ───────────────────────────────────────────────────────────── */
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .125rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--cat-color) 15%, transparent);
  color: var(--cat-color);
}

.category-filter-bar {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.cat-filter-btn {
  padding: .3rem .75rem;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text2);
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  transition: all var(--transition);
}
.cat-filter-btn:hover { background: var(--bg3); color: var(--text); }
.cat-filter-btn.active {
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 20%, transparent);
  border-color: var(--cat-color, var(--accent));
  color: var(--cat-color, var(--accent2));
}

.cat-manage-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .25rem;
  border-bottom: 1px solid var(--border);
}
.cat-manage-item:last-child { border-bottom: none; }
.cat-icon-preview {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-s);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.cat-manage-name { flex: 1; font-size: .9375rem; font-weight: 500; }

/* ─── Inline Exercise Section ────────────────────────────────────────────── */
#task-exercise-section {
  margin-top: .25rem;
  padding: 1rem 1.125rem;
  background: linear-gradient(135deg, rgba(249,115,22,.07) 0%, rgba(249,115,22,.03) 100%);
  border: 1px solid rgba(249,115,22,.3);
  border-radius: var(--radius-s);
  animation: fadeSlideIn .2s ease;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.exercise-inline-header {
  display: flex;
  align-items: baseline;
  gap: .625rem;
  margin-bottom: .875rem;
  font-weight: 600;
  font-size: .9375rem;
  color: #f97316;
}
.exercise-inline-sub {
  font-size: .75rem;
  font-weight: 400;
  color: var(--text3);
}

/* ─── Repeat Type UI ─────────────────────────────────────────────────────── */
.repeat-type-tabs {
  display: flex;
  gap: .375rem;
  margin-bottom: .75rem;
}
.repeat-tab {
  padding: .375rem .875rem;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text2);
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  transition: all var(--transition);
}
.repeat-tab:hover { background: var(--bg3); color: var(--text); }
.repeat-tab.active { background: rgba(124,58,237,.2); border-color: var(--accent); color: var(--accent2); }

.day-picker {
  display: flex;
  gap: .375rem;
  margin-bottom: .75rem;
  flex-wrap: wrap;
}
.day-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text2);
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  transition: all var(--transition);
}
.day-btn:hover { background: var(--bg3); }
.day-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  #app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    flex-direction: row;
    padding: .5rem;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 50;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .sidebar-logo, .nav-section-label, .sidebar-bottom { display: none; }
  .nav-section { display: flex; padding: 0; }
  .nav-item { flex-direction: column; gap: .25rem; padding: .5rem .875rem; font-size: .6875rem; border-radius: var(--radius-s); }
  .nav-item .icon { font-size: 1.25rem; }
  .main { padding-bottom: 70px; }
  .page { padding: 1.25rem 1rem; }
  .workout-stats { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .exercise-row { grid-template-columns: 1fr 50px 50px 60px auto; }
}
