:root {
  --bg: #0b0c10;
  --card: #12141b;
  --history-card: #101826;
  --text: #e8eaf0;
  --muted: #a5adbd;
  --line: #2a2f3a;
  --ok: #40c463;
  --danger: #ff5c5c;
  --focus: #7aa2ff;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: radial-gradient(1200px 600px at 10% 0%, #12162a 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== Nav bar (new) ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, #0b0c10 70%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.nav-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  align-items: center;
}
.brand { display: none; }
.nav-links {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav a, .nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #151a26;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.nav a.active {
  border-color: color-mix(in srgb, var(--focus) 50%, var(--line));
  background: color-mix(in srgb, var(--focus) 18%, #151a26);
  color: var(--focus);
}
.nav a:hover, .nav button:hover {
  background: #1c2235;
  border-color: color-mix(in srgb, var(--line) 50%, var(--text) 50%);
}

/* ===== Your existing layout ===== */
.wrap { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 14px; }

header {
  padding: 12px 6px 4px 6px;
  display: grid;
  gap: 10px;
}

.topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -0.1px; }

.right {
  display:flex;
  gap:8px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap: wrap;
}

.status { font-size: 12px; color: var(--muted); min-height: 16px; }

.card {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  min-width: 0;
}

.card.history {
  background: color-mix(in srgb, var(--history-card) 88%, var(--focus) 12%);
  box-shadow: 0 10px 30px rgba(122,162,255,.15);
}

form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
}
form.stack { grid-template-columns: 1fr; }

input[type="text"], input[type="password"], input[type="search"] {
  width: 100%;
  padding: 14px 14px;
  font-size: 16px;
  color: var(--text);
  background: #0f1118;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
}
input:focus {
  border-color: color-mix(in srgb, var(--focus) 70%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}

button {
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #151a26;
  color: var(--text);
  cursor: pointer;
  min-width: 84px;
  touch-action: manipulation;
  transition: background 0.12s ease, border-color 0.12s ease;
}
button:active { transform: translateY(1px); }
button:hover:not(:disabled) {
  background: #1c2235;
  border-color: color-mix(in srgb, var(--line) 60%, var(--text) 40%);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.primary {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
  background: color-mix(in srgb, var(--ok) 14%, #151a26);
}
button.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ok) 20%, #151a26);
}

.seg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.seg {
  display:flex;
  gap:8px;
  padding: 6px;
  background: #0f1118;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
}
.seg button {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
}
.seg button.active {
  background: #151a26;
  border-color: color-mix(in srgb, var(--focus) 35%, var(--line));
}
.seg button:hover:not(.active) {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  transition: background 0.1s ease;
}
.row:first-child { border-top: none; }
.row:hover { background: color-mix(in srgb, var(--text) 2.5%, transparent); }

.chk { width: 22px; height: 22px; accent-color: var(--ok); }
.title { font-size: 16px; line-height: 1.2; word-break: break-word; }
.meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.done .title {
  color: color-mix(in srgb, var(--muted) 95%, var(--text));
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: color-mix(in srgb, var(--muted) 65%, transparent);
}

.iconbtn {
  border: 1px solid var(--line);
  background: #151a26;
  padding: 10px 12px;
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.iconbtn:hover:not(:disabled) { background: #1c2235; }
.iconbtn.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, #151a26);
}
.iconbtn.danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 18%, #151a26);
}
.iconbtn.ok {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
  background: color-mix(in srgb, var(--ok) 12%, #151a26);
}
.iconbtn.ok:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ok) 18%, #151a26);
}

.empty { padding: 18px 14px; color: var(--muted); text-align: center; }

.footer {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.linkbtn {
  background: transparent;
  border: 1px solid var(--line);
  padding: 10px 12px;
  min-height: 44px;
  min-width: 44px;
  border-radius: 14px;
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.linkbtn:hover {
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border-color: color-mix(in srgb, var(--line) 60%, var(--text) 40%);
}

.hidden { display: none !important; }

.toolbar {
  display:flex;
  gap:8px;
  align-items:center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.pill { font-size: 12px; color: var(--muted); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--focus) 35%, var(--line));
  background: color-mix(in srgb, var(--focus) 15%, #151a26);
  color: var(--focus);
}
.badge.ok {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
  background: color-mix(in srgb, var(--ok) 15%, #151a26);
  color: var(--ok);
}
.badge.muted {
  border-color: var(--line);
  background: #151a26;
  color: var(--muted);
}
.badge.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 12%, #151a26);
  color: var(--danger);
}
.badge.focus {
  border-color: color-mix(in srgb, var(--focus) 35%, var(--line));
  background: color-mix(in srgb, var(--focus) 15%, #151a26);
  color: var(--focus);
}

/* ===== Task action bar ===== */
.task-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ===== Select / Textarea ===== */
select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #0f1118;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  width: 100%;
  cursor: pointer;
  outline: none;
}
select:focus {
  border-color: color-mix(in srgb, var(--focus) 70%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
textarea {
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #0f1118;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  width: 100%;
  resize: vertical;
  min-height: 72px;
  outline: none;
}
textarea:focus {
  border-color: color-mix(in srgb, var(--focus) 70%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
input[type="time"],
input[type="date"],
input[type="datetime-local"],
input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #0f1118;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
}
input[type="time"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="number"]:focus {
  border-color: color-mix(in srgb, var(--focus) 70%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}

/* ===== Form label rows ===== */
.form-field {
  display: grid;
  gap: 6px;
}
.form-field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== Collapsible create-form ===== */
.create-form {
  overflow: hidden;
  transition: max-height 0.28s ease;
}
.create-form.collapsed { max-height: 0; border-width: 0; box-shadow: none; }
.create-form.open { max-height: 1200px; }

/* ===== Power optimizer ===== */
.optimizer-grid {
  display: grid;
  gap: 10px;
  padding: 12px;
}
.optimizer-card {
  background: #0d0f17;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 6px;
}
.optimizer-card.best {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
  background: color-mix(in srgb, var(--ok) 5%, #0d0f17);
}
.optimizer-price {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.optimizer-time {
  font-size: 12px;
  color: var(--muted);
}

/* ===== Dinner page ===== */
.dinner-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
}
@media (min-width: 480px) {
  .dinner-grid { grid-template-columns: repeat(2, 1fr); }
}
.dinner-card {
  background: #0d0f17;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.dinner-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.dinner-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.dinner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.dinner-actions button {
  font-size: 13px;
  padding: 8px 12px;
  min-width: 0;
  min-height: 40px;
}

/* ===== Checkbox row ===== */
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.check-row label {
  font-size: 14px;
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--ok);
  cursor: pointer;
  flex-shrink: 0;
}

/* ===== Row layout helpers ===== */
.row.full { grid-template-columns: 1fr; align-items: start; }
.row-split { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row-body  { flex: 1; min-width: 0; }
.row-btns  { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sel-auto  { width: auto !important; min-width: 130px; }
.sub-fields { display: grid; gap: 10px; }
.create-form form.stack { padding: 14px; gap: 12px; }

/* ===== Token display ===== */
.token-prefix { font-family: ui-monospace, 'SF Mono', monospace; font-size: 12px; color: var(--muted); }
.token-new-banner {
  font-size: 12px; font-weight: 700; color: var(--ok);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px;
}
.token-value-box {
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 11px;
  background: #0d0f17;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  word-break: break-all;
  color: var(--focus);
}

/* ===== Logs ===== */
.log-container {
  height: 60vh;
  overflow-x: auto;
  overflow-y: auto;
  background: #0f1118;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.8;
  padding: 14px;
  white-space: pre;
  word-break: normal;
  border-top: 1px solid var(--line);
  min-width: 0;
}

/* ===== Dinner planned list ===== */
.plan-list { display: grid; gap: 10px; }
.plan-date {
  font-size: 11px; font-weight: 700; color: var(--focus);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.plan-notes {
  font-size: 12px; color: var(--muted);
  border-left: 2px solid var(--line); padding-left: 8px;
}
.plan-ingredients { font-size: 12px; color: var(--muted); }

/* ===== Power chart ===== */
.chart-body { padding: 12px 12px 0; }
.chart-canvas { width: 100%; height: auto; display: block; touch-action: none; }
.chart-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.section-head { padding: 6px 4px 0; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.2px; }
.section-head .meta { margin: 4px 0 0; }



/* ===== Fix: ensure native controls are dark-styled everywhere (iOS/Safari friendly) ===== */
input, select, textarea, button {
  -webkit-tap-highlight-color: transparent;
}

select, textarea, input[type="time"], input[type="date"], input[type="datetime-local"], input[type="number"] {
  background-color: #0f1118 !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
}

/* keep selects readable + consistent */
select {
  appearance: none;
  -webkit-appearance: none;
}

/* ===== Temps hero ===== */
.temp-hero { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; flex-shrink: 0; }

/* ===== Push notifications button ===== */
.push-btn {
  display: block;
  width: fit-content;
  margin: 0 auto;
  font-size: 13px;
  min-width: 0;
  padding: 8px 14px;
  color: var(--muted);
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
  background: transparent;
}
.push-btn:hover:not(:disabled) {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 4%, transparent);
}

/* ===== Shopping store header ===== */
.store-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  border-top: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
}
.store-header:first-child { border-top: none; }

/* ===== Task assignment pills ===== */
.asgn-pills {
  display: inline-flex;
  gap: 4px;
  background: #0f1118;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}
.asgn-pill {
  min-width: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s ease;
}
.asgn-pill.on {
  background: #151a26;
  border-color: color-mix(in srgb, var(--focus) 35%, var(--line));
  color: var(--text);
}
.asgn-pill:hover:not(.on) {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent);
}

/* ===== Power optimizer grid ===== */
.optimizer-grid { grid-template-columns: 1fr; }
@media (min-width: 520px) { .optimizer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 760px) { .optimizer-grid { grid-template-columns: repeat(3, 1fr); } }
