:root {
  --bg: #0f1115;
  --surface: #191c23;
  --surface-2: #22262f;
  --line: #2c313c;
  --text: #eef1f6;
  --muted: #97a0b0;
  --accent: #ff6a3d;
  --accent-2: #ffb347;
  --good: #35c98a;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, "Segoe UI", "Noto Sans Thai", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 84px;
}

header {
  padding: 20px 16px 14px;
  background: linear-gradient(135deg, #1c1f27, #14161c);
  border-bottom: 1px solid var(--line);
}
header h1 { font-size: 20px; letter-spacing: .3px; }
header h1 .fire { color: var(--accent); }
header p { color: var(--muted); font-size: 13px; margin-top: 4px; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

.tab { display: none; }
.tab.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; }

.pill {
  display: inline-block;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent-2);
  border: 1px solid var(--line);
  margin: 2px 4px 2px 0;
}

/* Day selector */
.day-select { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; }
.day-btn {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.day-btn.active { background: var(--accent); color: #1a0e08; border-color: var(--accent); font-weight: 600; }

/* Exercise */
.ex { border-bottom: 1px solid var(--line); padding: 14px 0; }
.ex:last-child { border-bottom: none; }
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ex-name { font-weight: 600; font-size: 15px; }
.ex-target { color: var(--accent-2); font-size: 12px; white-space: nowrap; }
.ex-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ex-tip { font-size: 12px; color: var(--good); margin-top: 5px; }
.ex-home { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ex-home b { color: var(--text); font-weight: 500; }
.ex-en { font-size: 12px; color: var(--muted); margin-top: 3px; letter-spacing: .2px; }
.ex-how { font-size: 13px; color: var(--text); margin-top: 6px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; line-height: 1.55; }
.ex-how b { color: var(--accent-2); }
.clip-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
}
.clip-link.inline { padding: 2px 8px; font-size: 12px; margin-top: 0; }
.clip-link:active { transform: scale(.98); }

/* Logger rows */
.log-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.log-row input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 15px;
  text-align: center;
}
.log-row input:focus { outline: none; border-color: var(--accent); }
.log-row .lbl { color: var(--muted); font-size: 12px; flex: 0 0 auto; width: 34px; }
.last { font-size: 11px; color: var(--muted); margin-top: 4px; }
.last b { color: var(--accent-2); }

.btn {
  display: block; width: 100%;
  background: var(--accent);
  color: #1a0e08;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn:active { transform: scale(.99); }

.saved-flash { color: var(--good); font-size: 13px; text-align: center; height: 18px; margin-top: 6px; }

/* Nutrition calc */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px;
  font-size: 15px;
}
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.result-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.result-box .num { font-size: 22px; font-weight: 700; color: var(--accent-2); }
.result-box .cap { font-size: 11px; color: var(--muted); margin-top: 2px; }

ul.tips { list-style: none; }
ul.tips li { padding: 7px 0 7px 22px; position: relative; font-size: 13.5px; border-bottom: 1px solid var(--line); }
ul.tips li:last-child { border-bottom: none; }
ul.tips li::before { content: "▸"; position: absolute; left: 4px; color: var(--accent); }

/* Progress */
.prog-list { margin-top: 10px; }
.prog-item { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.prog-item .date { color: var(--muted); }
.prog-item .val { color: var(--accent-2); font-weight: 600; }

/* Bottom nav */
nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}
nav button {
  flex: 1;
  background: none; border: none;
  color: var(--muted);
  font-size: 11px;
  padding: 6px 2px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
nav button .ic { font-size: 20px; }
nav button.active { color: var(--accent); }
nav button { font-size: 10.5px; }

/* Custom exercise + add box */
.badge-custom { font-size: 10px; background: var(--accent); color: #1a0e08; padding: 2px 7px; border-radius: 999px; font-weight: 700; vertical-align: middle; }
.del-ex { color: var(--muted); cursor: pointer; text-decoration: none; }
.del-ex:active { color: var(--accent); }
.add-ex-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.lbl2 { font-size: 14px; color: var(--accent-2); font-weight: 600; margin-bottom: 8px; }
.add-ex-row { display: flex; flex-direction: column; gap: 8px; }
.add-ex-row input {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); padding: 10px; font-size: 14px;
}
.add-ex-row input:focus { outline: none; border-color: var(--accent); }
.add-ex-btn { margin-top: 2px; }

/* Meals */
.meal-cat { margin-top: 14px; }
.meal-cat-title { font-size: 14px; font-weight: 700; color: var(--accent-2); margin-bottom: 4px; }
.meal-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.meal-item:last-child { border-bottom: none; }
.meal-name { flex: 1; }
.meal-macros { color: var(--muted); font-size: 12px; white-space: nowrap; }
.random-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 12px 0; }
.random-total { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); text-align: center; font-size: 15px; }
.random-total b { color: var(--accent-2); }
.random-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }
