/* Glas — velike mete (≥ 52 px), visok kontrast, svijetla i tamna tema. */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #cbd5e1;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --chip: #e2e8f0;
  --danger: #b91c1c;
  --warn-bg: #fef3c7;
  --warn-text: #78350f;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --line: #334155;
    --accent: #3b82f6;
    --chip: #334155;
    --danger: #f87171;
    --warn-bg: #422006;
    --warn-text: #fde68a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
main { max-width: 900px; margin: 0 auto; padding: 0 16px 48px; display: grid; gap: 16px; }

.bar {
  max-width: 900px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.bar h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.bar-actions { display: flex; gap: 8px; }

button, select, textarea, input { font: inherit; color: inherit; }
button {
  min-height: 52px; padding: 0 20px;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
}
button:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
button:active { transform: scale(0.98); }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.ghost { background: transparent; }
.small { min-height: 44px; padding: 0 14px; font-size: 16px; }
.danger { color: var(--danger); }

textarea {
  width: 100%; min-height: 140px; padding: 16px;
  font-size: 28px; line-height: 1.3;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  resize: vertical;
}

.phrases { display: flex; gap: 8px; align-items: flex-start; }
main > * { min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0; }
.chip { background: var(--chip); border-color: transparent; font-weight: 500; }
.chip .x { margin-left: 10px; color: var(--danger); font-weight: 700; }
.chip.add { border: 2px dashed var(--line); background: transparent; }

.suggestions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; min-height: 60px; }
.suggestions button { font-size: 22px; font-weight: 600; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestions kbd { display: block; font: 12px/1 system-ui; color: var(--muted); }
@media (max-width: 560px) {
  /* Fraze u jednom redu koji se vrti prstom, da polje za tipkanje ostane gore iznad tipkovnice. */
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip { flex-shrink: 0; }
  .suggestions { grid-template-columns: repeat(3, 1fr); }
  .suggestions button:nth-child(n+4) { display: none; }
  .suggestions kbd { display: none; }
}

.actions { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.actions .primary { font-size: 22px; min-height: 64px; }

h2 { font-size: 18px; color: var(--muted); margin: 8px 0; font-weight: 600; }
.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history button {
  width: 100%; text-align: left; padding: 12px 16px; height: auto;
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
}
.history time { color: var(--muted); font-size: 14px; flex-shrink: 0; }
.muted { color: var(--muted); }

.warning {
  max-width: 868px; margin: 0 auto 12px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn-text);
}

.big {
  position: fixed; inset: 0; z-index: 10;
  background: #000; color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 5vmin; cursor: pointer;
}
.big[hidden] { display: none; }
.big p { margin: 0; font-weight: 700; line-height: 1.1; text-align: center; overflow-wrap: anywhere; max-height: 90vh; }
.big-hint { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; color: #888; font-size: 14px; }

dialog {
  width: min(480px, calc(100vw - 32px)); border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 24px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog form { display: grid; gap: 16px; }
dialog h2 { margin: 0; color: var(--text); font-size: 22px; }
dialog label { display: grid; gap: 6px; }
dialog label.check { display: flex; gap: 12px; align-items: center; }
dialog input[type="checkbox"] { width: 28px; height: 28px; }
dialog select { min-height: 52px; padding: 0 12px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--bg); }
dialog hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
.small-print { font-size: 13px; margin: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { button:active { transform: none; } }
