/* NTUS Tolk — mobile first. Touch targets ≥ 44 px. */
:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1d2128; --muted: #5b6470; --line: #e3e6ea;
  --accent: #1f6feb; --accent-ink: #fff; --wave: #c4cbd4; --bad: #c92a2a; --warn: #b26a00; --ok: #2b8a3e;
  --radius: 10px; --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --card: #1d2128; --ink: #e8eaed; --muted: #a2a9b3; --line: #2c323b;
          --accent: #4c8dff; --wave: #4a525d; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* component display rules must never beat the hidden attribute */
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
button, .button, input, textarea { font: inherit; }
button, .button {
  min-height: var(--tap); min-width: var(--tap); padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
button.link { border: 0; background: none; color: var(--accent); padding: 0 8px; min-width: 0; }
button.link.danger { color: var(--bad); }
input, textarea { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--card); color: var(--ink); }
textarea { resize: vertical; }
.stack { display: grid; gap: 10px; }
.msg { padding: 10px 12px; border-radius: var(--radius); background: var(--card); border-left: 4px solid var(--muted); }
.msg.bad { border-color: var(--bad); } .msg.ok { border-color: var(--ok); } .msg.warn { border-color: var(--warn); }
.hint, .empty { color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }

/* ---- narrow pages (login, invite, ended) */
body.narrow { display: grid; place-items: start center; padding: max(16px, env(safe-area-inset-top)) 16px 24px; }
.card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.card form + form { margin-top: 10px; }
input.code { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- Mina förberedelser */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; }
.me { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.list { padding: 12px; display: grid; gap: 10px; max-width: 760px; margin: 0 auto; }
.review { display: flex; align-items: center; gap: 12px; padding: 14px; min-height: 64px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; }
.r-main { flex: 1; display: grid; gap: 2px; min-width: 0; }
.r-title { font-weight: 600; }
.r-sub { color: var(--muted); font-size: .9rem; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 3px 10px; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.count { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.foot { text-align: center; padding: 16px; }

/* ---- player (portrait first) */
body.player-page { padding-bottom: env(safe-area-inset-bottom); }
.player { max-width: 760px; margin: 0 auto; }
.pane-media { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: max(8px, env(safe-area-inset-top)) 10px 8px; border-bottom: 1px solid var(--line); }
.p-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.back { text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; font-size: .95rem; }
.p-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ver { color: var(--muted); font-weight: 400; font-size: .85rem; }

.stage { position: relative; display: flex; justify-content: flex-start; align-items: flex-start; }
.stage video { display: block; background: #000; border-radius: 8px; max-height: 60vh; }
.stage.mode-small video { width: 40%; aspect-ratio: 16 / 9; }
.stage.mode-large video { width: 100%; aspect-ratio: 16 / 9; }
.mode-btn { position: absolute; right: 0; top: 0; min-height: 36px; padding: 0 10px; font-size: .85rem; opacity: .92; }
.stage.mode-small .mode-btn { position: static; margin-left: 8px; }
.audio-only { padding: 10px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.mini { font-variant-numeric: tabular-nums; padding: 6px 2px; font-weight: 600; }
.mode-menu { position: absolute; right: 0; top: 40px; z-index: 5; display: grid; gap: 4px; padding: 6px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.mode-menu button { justify-content: flex-start; border: 0; }
.mode-menu button.on { color: var(--accent); font-weight: 600; }

.wave { display: block; width: 100%; height: 72px; margin-top: 8px; touch-action: none; cursor: pointer; }
.wave.slim { height: 40px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; margin: 2px 0 6px; }
.clock #time { color: var(--ink); font-weight: 600; }
.frame { color: var(--muted); font-size: .85em; }

.controls { display: grid; grid-template-columns: 1fr 1fr 1.4fr 1fr 1fr; gap: 8px; }
.controls button { font-variant-numeric: tabular-nums; font-weight: 600; padding: 0 4px; }
.controls .play { min-height: 56px; font-size: 1.3rem; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.add { width: 100%; margin-top: 8px; min-height: 48px; }

.compose { margin-top: 8px; display: grid; gap: 8px; }
.compose-time { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.c-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 92px; text-align: center; }
.compose-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* notes */
.pane-notes { padding: 4px 12px 32px; }
.pane-notes h2 { display: flex; gap: 8px; align-items: baseline; }
.status { padding: 8px 12px; border-radius: var(--radius); background: var(--card); border-left: 4px solid var(--muted); }
.status.bad { border-color: var(--bad); } .status.warn { border-color: var(--warn); }
.notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.note { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.note.resolved { opacity: .55; }
.note.resolved > .n-row > .n-main > .n-text { text-decoration: line-through; }
.n-row { display: flex; gap: 10px; align-items: flex-start; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 700; font-size: .8rem;
  display: inline-flex; align-items: center; justify-content: center; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.n-main { flex: 1; min-width: 0; }
.n-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .85rem; color: var(--muted); }
.n-time { min-height: 32px; min-width: 0; padding: 0 8px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.n-who { font-weight: 600; color: var(--ink); }
.n-ver { background: var(--line); border-radius: 6px; padding: 0 6px; }
.n-text { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; }
.n-acts { display: flex; flex-wrap: wrap; gap: 2px; margin-left: -8px; }
.replies { list-style: none; margin: 6px 0 0; padding: 0 0 0 4px; border-left: 2px solid var(--line); display: grid; gap: 6px; }
.reply { display: flex; gap: 8px; padding-left: 8px; }
.reply .avatar { width: 28px; height: 28px; font-size: .7rem; }
.r-body { flex: 1; min-width: 0; }
.reply-new { padding-left: 8px; }
.reply-form { display: flex; gap: 6px; }
.edit { display: grid; gap: 6px; margin: 4px 0; }

/* landscape: media left, notes right */
@media (orientation: landscape) and (min-width: 700px) {
  .player { max-width: none; display: grid; grid-template-columns: minmax(360px, 55%) 1fr; height: 100vh; }
  .pane-media { position: static; overflow-y: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .pane-notes { overflow-y: auto; height: 100vh; }
  .stage video { max-height: 44vh; }
  .stage.mode-large video { width: auto; max-width: 100%; aspect-ratio: 16 / 9; }
  .wave { height: 56px; } .wave.slim { height: 36px; }
  .controls .play { min-height: 48px; }
  .add { min-height: 44px; }
}

/* ---- Teckenklipp */
/* "+ Anteckning" and "Klipp": 50/50, finger-sized (Pontus 2026-10-24) */
.add-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.add-row .add { margin-top: 0; min-height: 60px; flex-direction: column; gap: 0; padding: 6px 8px; line-height: 1.2; }
.add-main { font-size: 1.08rem; font-weight: 700; white-space: nowrap; }
.add-sub { font-size: .82rem; font-weight: 500; opacity: .9; font-variant-numeric: tabular-nums; }
.clip-btn { border: 2px solid var(--accent); color: var(--accent); background: var(--card); }
body.sheet-open { overflow: hidden; }
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 640px; max-height: 100dvh; overflow-y: auto; background: var(--bg);
  border-radius: 16px 16px 0 0; padding: 12px 12px max(16px, env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.rec-orig { display: flex; gap: 8px; align-items: center; }
.rec-orig video { width: 40%; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; }
.cam-wrap { position: relative; }
.cam-wrap video, #rec-review, #v-clip, .v-orig { display: block; width: 100%; max-height: 52dvh; background: #000; border-radius: 10px; object-fit: contain; }
.mirror { transform: scaleX(-1); }
.rec-count { position: absolute; inset: 0; display: grid; place-items: center; font-size: 5rem; font-weight: 800; color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.rec-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#rec-progress { height: 100%; width: 0; background: var(--bad); }
.rec-ctrl { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.rec-go { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 700; }
.rec-done input { width: 100%; }
.small { font-size: .85rem; }
.clip-thumb { position: relative; padding: 0; min-height: 0; width: 132px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 8px;
  background: #222; margin: 4px 0; }
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-len { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.7); color: #fff; font-size: .75rem;
  padding: 0 5px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.clip-play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.4rem; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.reply .clip-thumb { width: 112px; }
.v-ctrl { display: flex; flex-wrap: wrap; gap: 8px; }
.v-ctrl .on { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.uploading { color: var(--muted); font-size: .9rem; padding: 8px 10px; }
.note.uploading { border-style: dashed; }

/* ---- touch targets ≥ 44 px everywhere (layout audit 2026-10-24) */
.back { min-height: 44px; padding-right: 12px; align-self: flex-start; }
.mode-btn { min-height: 44px; }
.n-time { min-height: 44px; }

/* ---- short portrait phones (iPhone SE …): keep the notes visible under the sticky player */
@media (orientation: portrait) and (max-height: 720px) {
  .pane-media { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .p-head { flex-direction: row; align-items: center; gap: 6px; margin-bottom: 4px; }
  .p-head .back { font-size: 0; min-width: 44px; justify-content: center; }      /* icon-only "‹" on short screens */
  .p-head .back::before { content: "‹"; font-size: 1.6rem; line-height: 1; }
  .p-title { font-size: .95rem; }
  .wave { height: 54px; margin-top: 6px; }
  .clock { margin: 0 0 4px; font-size: .85rem; }
  .controls { gap: 6px; }
  .controls button { min-height: 46px; }
  .controls .play { min-height: 50px; }
  .add-row { margin-top: 8px; gap: 8px; }
  .add-row .add { min-height: 58px; }
}

/* ---- admin "master link" view (read-only) */
.admin-tag { background: #495057; color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; }
.admin-banner { margin: 4px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--card); border-left: 4px solid #495057; font-size: .85rem; color: var(--muted); }
.admin-review { align-items: flex-start; }
.r-stats { display: grid; gap: 2px; text-align: right; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-last { font-size: .8rem; }
.warn-text { color: var(--warn); }
