:root {
  --floor: #232528;
  --floor-deep: #1B1D20;
  --fleck-a: #3a3d41;
  --fleck-b: #2d3034;
  --steel: #5A5E63;
  --steel-light: #7A7E83;
  --chalk: #ECEAE3;
  --ink: #EDEBE4;
  --ink-2: #A3A6A8;
  --ink-3: #7F8387;
  --dark: #1D1F22;
  --line: #34373B;
  --missed: #6B4A47;
  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'Archivo', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: var(--body);
  color: var(--ink);
  background-color: var(--floor);
  /* gumeni pod u teretani */
  background-image:
    radial-gradient(var(--fleck-a) 1px, transparent 1.2px),
    radial-gradient(var(--fleck-b) 1px, transparent 1.2px);
  background-size: 23px 23px, 17px 17px;
  background-position: 0 0, 9px 11px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- okvir ---------- */
.shell { max-width: 1120px; margin: 0 auto; padding: env(safe-area-inset-top) 0 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 0; position: relative; }
.wordmark { font-family: var(--display); font-weight: 900; font-size: 26px; letter-spacing: .5px; }
.layout { display: block; }
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 48px; padding: 0 20px; align-items: start; }
  .layout > * { min-width: 0; }
  .side { padding-top: 40px; }
  .board section, .board .hero, .board .ranges { padding-left: 0 !important; padding-right: 0 !important; margin-left: 0 !important; margin-right: 0 !important; }
  .today { margin: 0 !important; }
  .feed { padding-left: 0 !important; padding-right: 0 !important; }
}

/* ---------- avatar ---------- */
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 2.5px solid var(--c, var(--ink-2)); background: #3A3D42;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 38px; height: 38px; font-size: 14px; }
.me-btn { padding: 0; background: none; border: 0; border-radius: 50%; }
.me-btn .avatar { width: 38px; height: 38px; }
.menu {
  position: absolute; right: 20px; top: 64px; z-index: 5; min-width: 180px;
  background: var(--chalk); color: var(--dark); border-radius: 14px; padding: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
}
.menu p { margin: 8px 12px 6px; font-size: 13px; color: #55585C; }
.menu button { width: 100%; text-align: left; border: 0; background: none; padding: 12px; border-radius: 10px; font-weight: 600; }
.menu button:hover { background: #DEDBD2; }

/* ---------- hero ---------- */
.hero { padding: 28px 20px 0; }
.hero h1 { margin: 0; font-family: var(--display); font-weight: 900; font-size: clamp(64px, 21vw, 132px); line-height: .82; letter-spacing: -1px; }
.hero-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.hero-meta span { font-size: 14px; color: var(--ink-2); }
.nav-btns { display: flex; gap: 4px; }
.nav-btns button { width: 40px; height: 34px; border-radius: 8px; border: 1px solid #45494E; background: transparent; font-size: 17px; }
.nav-btns button:disabled { border-color: #36393D; color: #5C6064; cursor: default; }
.callout { margin: 22px 0 0; font-size: 19px; line-height: 1.35; font-weight: 500; max-width: 34ch; }

.ranges { display: flex; margin: 26px 20px 0; padding: 4px; background: var(--floor-deep); border-radius: 12px; gap: 4px; }
.ranges button { flex: 1; height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.ranges button[aria-pressed="true"] { background: var(--ink); color: var(--dark); }

/* ---------- graf ---------- */
.chart { padding: 28px 20px 0; }
.chart + .chart { padding-top: 34px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; }
.chart-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.chart-head span { font-size: 13px; color: var(--ink-2); }
.rows { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 48px; align-items: center; gap: 10px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; min-width: 0; }
.who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-family: var(--display); font-weight: 800; font-size: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.num small { font-size: 18px; color: var(--ink-3); }

.bar { position: relative; height: 52px; display: flex; align-items: center; }
.bar::before { content: ''; position: absolute; left: 0; right: 0; top: 24px; height: 4px; border-radius: 2px; background: var(--steel); }
.collar { position: relative; width: 8px; height: 18px; border-radius: 2px; background: var(--steel-light); margin-left: 10px; flex: none; }
.plates { position: relative; display: flex; gap: 2px; margin-left: 3px; align-items: center; }
.plate { width: 16px; height: 48px; border-radius: 4px; background: var(--c); }
.plate.empty { background: transparent; border: 1.5px dashed var(--steel); }
.plates.thin .plate { width: 5px; height: 34px; border-radius: 2px; }
.load { position: relative; height: 34px; border-radius: 4px; background: var(--c); margin-left: 3px; min-width: 6px; }

.days, .cells { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.days span { text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.days span.now { color: var(--ink); }
.cell { height: 30px; border-radius: 6px; border: 0; padding: 0; background: #2A2D31; }
.cell.s-done { background: var(--c); }
.cell.s-today { background: transparent; border: 1.5px dashed #8A8E93; }
.cell.s-missed { border: 1px solid var(--missed); background: repeating-linear-gradient(135deg, #3A2B2A 0 3px, var(--floor) 3px 6px); }
button.cell { cursor: pointer; }
button.cell:hover { outline: 2px solid var(--ink-2); outline-offset: 1px; }
.streak { font-size: 22px; }
.track { height: 30px; border-radius: 6px; background: #2A2D31; overflow: hidden; }
.track div { height: 100%; background: var(--c); border-radius: 6px; }
.legend { display: flex; gap: 16px; margin-top: 14px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- današnji blok ---------- */
.today { margin: 36px 12px 0; padding: 22px 18px 20px; background: var(--chalk); color: var(--dark); border-radius: 20px; }
.today h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1; }
.today p { margin: 6px 0 0; font-size: 14px; color: #55585C; }
.stepper-row { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.stepper-row label { font-size: 14px; font-weight: 600; }
.stepper { display: flex; align-items: center; border: 1.5px solid #B9B7B0; border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 44px; height: 44px; border: 0; background: transparent; font-size: 20px; color: var(--dark); }
.stepper output { width: 64px; text-align: center; font-family: var(--display); font-weight: 800; font-size: 22px; color: var(--dark); }
.big { width: 100%; height: 56px; margin-top: 16px; border-radius: 14px; border: 0; font-weight: 700; font-size: 17px; background: var(--dark); color: var(--chalk); }
.big.done { background: var(--me); color: var(--dark); }
.ghost { width: 100%; height: 52px; margin-top: 10px; border-radius: 14px; border: 2px solid var(--dark); background: transparent; color: var(--dark); font-weight: 700; font-size: 16px; }
.today :focus-visible { outline-color: var(--dark); }

/* ---------- zadnji treninzi ---------- */
.feed { padding: 34px 20px 0; }
.feed h2 { margin: 0; font-size: 17px; font-weight: 700; }
.feed ul { list-style: none; margin: 12px 0 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed .txt { flex: 1; min-width: 0; }
.feed .t1 { font-size: 15px; font-weight: 600; }
.feed .t2 { font-size: 13px; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.feed .when { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.del { width: 36px; height: 36px; border-radius: 10px; border: 1px solid #45494E; background: transparent; display: flex; align-items: center; justify-content: center; color: var(--ink-2); }
.del:hover { color: var(--ink); border-color: var(--ink-2); }
.empty { color: var(--ink-2); font-size: 15px; padding: 14px 0; }

/* ---------- dijalog ---------- */
dialog {
  border: 0; padding: 0; width: min(440px, 100%); max-width: 100%;
  background: var(--chalk); color: var(--dark); border-radius: 22px;
}
dialog::backdrop { background: rgba(10, 11, 12, .6); }
@media (max-width: 520px) {
  dialog { margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
dialog form { padding: 22px 18px 18px; }
dialog h2 { margin: 0 0 16px; font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1; }
dialog fieldset { border: 0; margin: 0; padding: 0; }
dialog legend, dialog label.lbl { font-size: 14px; font-weight: 600; margin-bottom: 8px; display: block; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; inset: 0; }
.chips span { display: inline-flex; align-items: center; height: 42px; padding: 0 16px; border-radius: 21px; border: 1.5px solid #B9B7B0; font-weight: 600; font-size: 15px; }
.chips input:checked + span { background: var(--dark); color: var(--chalk); border-color: var(--dark); }
.chips input:focus-visible + span { outline: 3px solid var(--dark); outline-offset: 2px; }
.field { margin-top: 18px; }
.field select, .field input { width: 100%; height: 48px; border-radius: 12px; border: 1.5px solid #B9B7B0; background: #fff; color: var(--dark); padding: 0 12px; font-size: 16px; }
.actions { display: flex; gap: 10px; margin-top: 20px; }
.actions .ghost, .actions .big { margin-top: 0; }
.err { color: #A3261D; font-size: 14px; margin: 12px 0 0; min-height: 1em; }

/* ---------- prijava ---------- */
.login { min-height: 100vh; max-width: 440px; margin: 0 auto; padding: 56px 24px max(40px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.login .art { position: relative; height: 230px; margin: 0 -24px; }
.login .art div { position: absolute; }
.login h1 { margin: 40px 0 0; font-family: var(--display); font-weight: 900; font-size: 96px; line-height: .85; letter-spacing: -1px; }
.login p.lead { margin: 18px 0 0; font-size: 19px; line-height: 1.4; font-weight: 500; max-width: 30ch; }
.login .spacer { flex: 1; min-height: 40px; }
.login .gbtn { display: flex; justify-content: center; min-height: 44px; }
.login .note { margin: 14px 0 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.login .err { color: #FF8A80; text-align: center; }
.devlogin { display: flex; gap: 8px; margin-top: 16px; }
.devlogin input { flex: 1; height: 44px; border-radius: 10px; border: 1px solid #45494E; background: var(--floor-deep); padding: 0 12px; }
.devlogin button { height: 44px; border-radius: 10px; border: 0; background: var(--ink); color: var(--dark); padding: 0 14px; font-weight: 700; }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--dark); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* jedini "veliki" pokret: utezi se nabacuju na šipku pri učitavanju */
@media (prefers-reduced-motion: no-preference) {
  .loadin .plate:not(.empty), .loadin .load {
    animation: slideon .45s cubic-bezier(.2, .9, .3, 1.15) both;
    animation-delay: calc(var(--i, 0) * 70ms + var(--r, 0) * 40ms);
  }
  @keyframes slideon { from { transform: translateX(60px); opacity: 0; } to { transform: none; opacity: 1; } }
}
