/* =========================================================
   PRIME — design tokeny. Barvy a písmo se mění tady.
   ========================================================= */
:root {
  --bg: #0b0b0b;
  --surface: #141310;
  --surface-2: #1c1a15;
  --line: #2a2620;
  --text: #f2ebdd;
  --muted: #8a8478;
  --faint: #5a554c;
  --gold: #c9a961;
  --gold-bright: #e6c77e;
  --gold-dim: rgba(201, 169, 97, 0.14);
  --warn: #d49a4a;
  --danger: #c8574b;
  --danger-dim: rgba(200, 87, 75, 0.16);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  --font-serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;

  --r: 18px;
  --r-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; max-width: 100%; }

.app { max-width: 480px; margin: 0 auto; padding: calc(var(--safe-top) + 14px) 18px calc(var(--safe-bottom) + 96px); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.32em; font-size: 13px; color: var(--gold); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px;
  font-size: 13px; color: var(--text); background: var(--surface);
}
.sos-btn { border-color: rgba(200, 87, 75, 0.5); color: #f0a299; }

/* ---------- typography ---------- */
.eyebrow { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin: 0 0 6px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0; }
.h1 { font-family: var(--font-display); font-weight: 700; font-size: 46px; letter-spacing: -0.035em; line-height: 1.05; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.h1 small { font-size: 20px; color: var(--muted); font-weight: 600; letter-spacing: 0; margin-left: 6px; }
.h2 { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -0.01em; margin: 0; }
.h3 { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 30px 0 10px; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.danger { color: var(--danger); }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-serif); font-style: italic; }
.center { text-align: center; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card + .card { margin-top: 10px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; }
.stat b { display: block; font-family: var(--font-display); font-weight: 650; font-size: 22px; letter-spacing: -0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.spark { display: block; width: 100%; height: 28px; margin-top: 10px; overflow: visible; }
.grid2 .stat b { font-size: 20px; white-space: nowrap; }
.grid3 .stat b { font-size: 18px; white-space: nowrap; }
.stat .sub { font-size: 12px; color: var(--muted); }

/* ---------- hero ---------- */
.hero { padding: 6px 0 18px; }
.hero-meta { display: flex; gap: 14px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.hero-meta b { color: var(--text); font-weight: 500; }
.bar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 16px; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 2px; transition: width .5s ease; }
.quote { font-family: var(--font-serif); font-style: italic; color: var(--muted); font-size: 15px; margin: 18px 0 4px; }

/* ---------- habit control ---------- */
.habit { padding: 14px 16px; }
.habit-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.habit-head .name { font-weight: 650; font-size: 16px; }
.habit-head .val { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.habit-head .val.on { color: var(--gold); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px;
  font-size: 13px; color: var(--muted); background: var(--surface-2);
  transition: all .15s ease;
}
.seg button.on-none { background: var(--gold); color: #0b0b0b; border-color: var(--gold); font-weight: 600; }
.seg button.on-out { border-color: var(--warn); color: var(--warn); background: rgba(212, 154, 74, 0.1); }
.seg button.on-home { border-color: var(--danger); color: #f0a299; background: var(--danger-dim); }
.seg button:active { transform: scale(0.97); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.switch { width: 52px; height: 32px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; width: 26px; height: 26px; border-radius: 50%; background: var(--text); top: 3px; left: 3px; transition: transform .2s; }
.switch.on { background: var(--gold); }
.switch.on::after { transform: translateX(20px); background: #0b0b0b; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 13px; color: var(--muted); background: var(--surface-2); }
.chip.on { border-color: var(--gold); color: var(--gold); background: var(--gold-dim); }

.week-dots { display: flex; gap: 6px; }
.week-dots i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--faint); }
.week-dots i.on { background: var(--gold); border-color: var(--gold); }

/* scale 1–5 */
.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.scale.s5 { grid-template-columns: repeat(5, 1fr); }
.scale button { border: 1px solid var(--line); border-radius: 10px; padding: 9px 0; font-size: 14px; color: var(--muted); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.scale button.on { background: var(--gold); color: #0b0b0b; border-color: var(--gold); font-weight: 600; }

/* ---------- forms ---------- */
.input, textarea.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 16px; outline: none;
}
.input:focus { border-color: var(--gold); }
textarea.input { min-height: 76px; resize: vertical; line-height: 1.4; }
.input-inline { display: flex; gap: 8px; align-items: center; }
.input-inline .input { flex: 1; }
.unit { color: var(--muted); font-size: 14px; }
.field + .field { margin-top: 12px; }
.field .label { margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 16px;
  font-size: 15px; background: var(--surface-2); color: var(--text); font-weight: 500;
}
.btn.primary { background: var(--gold); color: #0b0b0b; border-color: var(--gold); }
.btn.ghost { background: none; }
.btn.danger { color: #f0a299; border-color: rgba(200, 87, 75, 0.5); }
.btn.block { width: 100%; }
.btn:active { transform: scale(0.98); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.link { color: var(--gold); font-size: 14px; }

/* ---------- reward ---------- */
.reward { display: flex; gap: 14px; align-items: center; }
.reward .ph { width: 76px; height: 76px; border-radius: 14px; flex: none; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.reward .ph img, .photo img { width: 100%; height: 100%; object-fit: cover; }
.pill { display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--gold); color: var(--gold); }
.pill.lost { border-color: var(--danger); color: #f0a299; }
.pill.won { background: var(--gold); color: #0b0b0b; }

/* ---------- day grid ---------- */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted); position: relative; font-variant-numeric: tabular-nums;
}
.day small { font-size: 9px; letter-spacing: 0.06em; color: var(--faint); }
.day.ok { background: var(--gold-dim); border-color: rgba(201, 169, 97, 0.45); color: var(--gold-bright); }
.day.clean { background: var(--gold); border-color: var(--gold); color: #0b0b0b; }
.day.clean small { color: rgba(0,0,0,.55); }
.day.fail { background: var(--danger-dim); border-color: rgba(200, 87, 75, 0.45); color: #f0a299; }
.day.todo { border-style: dashed; }
.day.future { opacity: 0.35; }
.day.today { outline: 1.5px solid var(--text); outline-offset: 1px; }
.day .mv { position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* year heatmap */
.year { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
.year i { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); }
.year i.ok { background: rgba(201, 169, 97, 0.55); }
.year i.clean { background: var(--gold); }
.year i.fail { background: rgba(200, 87, 75, 0.6); }
.year i.blank { background: transparent; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 160px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--gold-dim); }
.chart .dot { fill: var(--muted); }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }

/* ---------- photos ---------- */
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo { position: relative; aspect-ratio: 3 / 4; border-radius: var(--r); overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.photo .cap { position: absolute; left: 10px; bottom: 10px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; background: rgba(0,0,0,.55); padding: 4px 8px; border-radius: 6px; color: var(--text); }
.photo input { display: none; }

.thumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; scrollbar-width: none; }
.thumb { flex: none; width: 58px; text-align: center; font-size: 10px; color: var(--muted); }
.thumb img { width: 58px; height: 74px; object-fit: cover; border-radius: 10px; border: 1.5px solid var(--line); margin-bottom: 3px; }
.thumb.on img { border-color: var(--gold); }
.thumb.add { height: 74px; border: 1.5px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 200; cursor: pointer; }

/* ---------- trophies ---------- */
.trophies { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.trophy { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 8px; text-align: center; }
.trophy .ico { font-size: 22px; height: 30px; display: flex; align-items: center; justify-content: center; filter: grayscale(1); opacity: .35; }
.trophy .t { font-size: 12px; margin-top: 6px; color: var(--faint); line-height: 1.25; }
.trophy.on { border-color: rgba(201, 169, 97, 0.5); background: linear-gradient(180deg, var(--gold-dim), var(--surface)); }
.trophy.on .ico { filter: none; opacity: 1; }
.trophy.on .t { color: var(--text); }

/* ---------- list ---------- */
.list > div { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list > div:last-child { border-bottom: 0; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(11, 11, 11, 0.88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(var(--safe-bottom) + 8px);
}
.tabbar nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; letter-spacing: 0.04em; color: var(--faint); padding: 4px 0; }
.tabbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tabbar button.on { color: var(--gold); }

/* ---------- sheet / modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet {
  width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(var(--safe-bottom) + 24px);
  animation: up .25s ease;
}
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* lock */
.lock { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; }
.pin-dots { display: flex; gap: 14px; }
.pin-dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--gold); }
.pin-dots i.on { background: var(--gold); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.keypad button { width: 76px; height: 76px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); font-size: 26px; font-weight: 300; }
.keypad button.empty { visibility: hidden; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 92px); transform: translateX(-50%); z-index: 70; background: var(--surface-2); border: 1px solid var(--gold); color: var(--text); padding: 10px 16px; border-radius: 99px; font-size: 14px; animation: up .25s ease; white-space: nowrap; }

/* celebrate */
.burst { animation: burst .6s ease; }
@keyframes burst { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* SOS timer */
.timer { font-family: var(--font-display); font-weight: 200; font-size: 64px; text-align: center; font-variant-numeric: tabular-nums; margin: 6px 0; }

.banner { border: 1px solid rgba(212, 154, 74, 0.5); background: rgba(212, 154, 74, 0.08); border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.datebar { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 12px; }
.datebar-title { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.datebar button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font-size: 18px; }
.datebar button:disabled { opacity: .25; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }

/* výběr data u váhy / pasu */
.date-pill { position: relative; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-size: 13px; color: var(--gold); background: var(--surface-2); cursor: pointer; }
.date-pill input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* logo v hlavičce */
.logo { display: flex; align-items: center; gap: 10px; text-align: left; }
.logo img { height: 34px; width: auto; }
.logo > span { display: flex; flex-direction: column; line-height: 1; }
.logo-word { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: 0.01em; color: var(--text); }
.logo-word b { color: var(--gold); font-weight: 800; margin-left: 1px; }
.logo-sub { font-size: 10px; letter-spacing: 0.42em; color: var(--gold); margin-top: 5px; text-transform: uppercase; opacity: .85; }

/* ---------- pozdrav, motivace, hero ---------- */
.small { font-size: 13px; }
.greet { margin: 8px 0 18px; }
.greet-title { font-family: var(--font-display); font-weight: 800; font-size: 32px; letter-spacing: -0.03em; line-height: 1.1; margin: 0; }
.greet-sub { font-size: 16px; color: var(--muted); line-height: 1.5; margin: 8px 0 0; }
.greet-sub b { color: var(--text); font-weight: 650; }
.motto { border: 1px solid rgba(201, 169, 97, 0.35); background: linear-gradient(135deg, rgba(201, 169, 97, 0.16), rgba(201, 169, 97, 0.03)); border-radius: var(--r); padding: 16px 18px; margin-bottom: 12px; }
.motto-label { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin: 0 0 6px; }
.motto-text { font-family: var(--font-display); font-weight: 650; font-size: 19px; line-height: 1.35; letter-spacing: -0.01em; margin: 0; }
.hero-card { padding: 18px; margin-bottom: 10px; }
.mini3 { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mini3 > div + div { border-left: 1px solid var(--line); padding-left: 14px; }
.mini3 span { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.mini3 b { display: block; font-family: var(--font-display); font-weight: 650; font-size: 16px; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini3.flat { margin: 0; padding: 0; border: 0; }
.mini3 b.gold { color: var(--gold); }
.mini3 b.danger { color: #f0a299; }
.btn { font-weight: 600; }
.greet-sub b.gold { color: var(--gold); }

/* =========================================================
   Responzivní rozložení — Mac / iPad / širší okna
   ========================================================= */
@media (hover: hover) {
  .seg button:hover, .chip:hover, .scale button:hover, .btn:hover, .day:not(:disabled):hover { border-color: var(--faint); }
  .tabbar button:hover { color: var(--text); }
}

@media (min-width: 900px) {
  body { padding-left: 232px; }
  .app { max-width: 1120px; padding: 40px 48px 64px; }

  /* spodní lišta → postranní menu */
  .tabbar {
    top: 0; bottom: 0; left: 0; right: auto; width: 232px;
    border-top: 0; border-right: 1px solid var(--line);
    padding: 120px 14px 24px; background: rgba(11, 11, 11, 0.6);
  }
  .tabbar nav { display: flex; flex-direction: column; gap: 4px; max-width: none; }
  .tabbar button { flex-direction: row; justify-content: flex-start; gap: 14px; font-size: 15px; font-weight: 500; letter-spacing: 0; padding: 11px 14px; border-radius: 12px; color: var(--muted); }
  .tabbar button.on { background: var(--gold-dim); color: var(--gold); }

  /* Dnes: záznam vlevo, čísla vpravo */
  .layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-areas: "entry stats" "entry more"; gap: 0 32px; align-items: start; }
  .a-stats { grid-area: stats; }
  .a-entry { grid-area: entry; }
  .a-more { grid-area: more; }
  .a-entry > :first-child { margin-top: 0; }

  /* ostatní záložky: dva sloupce */
  .split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; align-items: start; }
  .split > div > :first-child, .split .h3.first { margin-top: 0; }

  .greet-title { font-size: 40px; }
  .greet { margin-bottom: 22px; }
  .motto { margin-bottom: 26px; }
  .trophies { grid-template-columns: repeat(4, 1fr); }

  /* listy jako modální okno uprostřed */
  .overlay { align-items: center; }
  .sheet { max-width: 540px; max-height: 86vh; border-radius: 24px; border: 1px solid var(--line); }
  .sheet .grab { display: none; }
  .toast { bottom: 32px; left: calc(50% + 116px); }
}

@media (min-width: 1300px) {
  .app { max-width: 1240px; }
}
@media (min-width: 900px) {
  .photos { grid-template-columns: repeat(2, minmax(0, 220px)); }
}
