:root {
  --paper: #f2eee4;
  --paper-2: #e9e3d6;
  --ink: #16140f;
  --ink-2: #4a463d;
  --ink-3: #8a8476;
  --rule: #cfc7b6;
  --accent: #ff4a1c;
  --accent-ink: #ffffff;
  --sold: #6b3fa0;
  --ok: #2f8f4e;
  --warn: #d99a00;
  --err: #d23a1f;
  --display: "Instrument Serif", Georgia, serif;
  --body: "Schibsted Grotesk", "Helvetica Neue", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --rail: 300px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12110e; --paper-2: #1c1a16; --ink: #efe9dc; --ink-2: #bdb6a6; --ink-3: #7b7566;
    --rule: #34302a; --sold: #b48cf0; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #12110e; --paper-2: #1c1a16; --ink: #efe9dc; --ink-2: #bdb6a6; --ink-3: #7b7566;
  --rule: #34302a; --sold: #b48cf0; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 15px;
  line-height: 1.4; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: .07; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .05; }

.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

/* ---------- rail ---------- */
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 2px solid var(--ink);
  padding: 22px 22px 16px; display: flex; flex-direction: column; gap: 22px; background: var(--paper);
}
.brand { line-height: .85; }
.brand-mark { font-family: var(--display); font-size: 58px; font-style: italic; color: var(--accent); }
.brand-rest { font-family: var(--display); font-size: 58px; }
.brand-sub { display: block; margin-top: 8px; font: 500 11px/1.3 var(--mono); color: var(--ink-3); letter-spacing: .04em; }

.tabs { display: flex; flex-direction: column; border-top: 2px solid var(--ink); }
.tab {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 8px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--rule); padding: 9px 0; cursor: pointer;
}
.tab-name { font-family: var(--display); font-size: 25px; line-height: 1.05; transition: transform .2s ease, color .2s; }
.tab:hover .tab-name { transform: translateX(4px); }
.tab[aria-current="true"] .tab-name { color: var(--accent); font-style: italic; }
.tab-count { font: 500 11px var(--mono); color: var(--ink-3); }
.tab-new {
  font: 600 10px var(--mono); background: var(--accent); color: var(--accent-ink); border-radius: 99px;
  padding: 1px 6px; margin-left: 6px;
}
.tab.empty .tab-name { color: var(--ink-3); }

.filters { display: flex; flex-direction: column; gap: 16px; }
.f-label { font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .09em; color: var(--ink-3); margin-bottom: 6px; display: block; }
.f-note { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  border: 1px solid var(--ink); background: transparent; border-radius: 99px; padding: 3px 10px; font-size: 12.5px;
  cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover { background: var(--paper-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.search {
  width: 100%; border: 0; border-bottom: 2px solid var(--ink); background: transparent; padding: 6px 0;
  font: 500 15px var(--body); color: var(--ink); outline: none;
}
.search::placeholder { color: var(--ink-3); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; padding: 2px 0; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.rail-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid var(--rule); }
.sources-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; font: 500 12px var(--mono); }
.dots { display: inline-flex; gap: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.warning { background: var(--warn); } .dot.error { background: var(--err); }
.theme-btn { background: none; border: 1px solid var(--rule); border-radius: 50%; width: 28px; height: 28px; cursor: pointer; }

/* ---------- main ---------- */
.main { padding: 26px clamp(24px, 4vw, 64px) 80px; min-width: 0; }
.head { border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 8px; position: sticky; top: 0; background: var(--paper); z-index: 5; padding-top: 4px; }
.kicker { font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.title { font-family: var(--display); font-weight: 400; font-size: clamp(56px, 7vw, 104px); line-height: .9; margin: 4px 0 8px; letter-spacing: -.01em; }
.summary { margin: 0; color: var(--ink-2); font-size: 15px; }
.summary b { color: var(--ink); }
.jump { display: flex; gap: 2px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.jump button {
  flex: 0 0 auto; border: 0; background: none; cursor: pointer; padding: 4px 8px 2px; font: 500 12px var(--mono);
  color: var(--ink-2); border-bottom: 3px solid transparent;
}
.jump button:hover { color: var(--ink); border-bottom-color: var(--rule); }
.jump button.active { color: var(--ink); border-bottom-color: var(--accent); }
.jump button small { color: var(--ink-3); margin-left: 3px; }

.view { animation: in .35s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.month-h {
  font-family: var(--display); font-size: 40px; font-style: italic; margin: 34px 0 4px; display: flex; align-items: baseline; gap: 14px;
  scroll-margin-top: 230px;
}
.month-h small { font: 500 12px var(--mono); font-style: normal; color: var(--ink-3); }

.day { display: grid; grid-template-columns: 88px 1fr; border-top: 1px solid var(--rule); padding: 10px 0 6px; }
.day-date { position: sticky; top: 230px; align-self: start; line-height: .9; }
.day-num { font-family: var(--display); font-size: 46px; }
.day-wd { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); display: block; margin-top: 3px; }
.day.today .day-num, .day.today .day-wd { color: var(--accent); }

/* Rows adapt to the width of the day column itself (container queries), not the window. */
.day-rows { container-type: inline-size; min-width: 0; }
.row {
  display: grid; gap: 2px 14px; align-items: baseline;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-areas: "time title" ". where" ". tags";
  padding: 6px 8px; margin: 0 -8px; border-radius: 4px; transition: background .12s;
}
.r-time { grid-area: time; } .r-title { grid-area: title; } .r-where { grid-area: where; } .r-tags { grid-area: tags; }
.r-tags:empty { display: none; }
@container (min-width: 620px) {
  .row { grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "time title tags" ". where tags"; }
  .r-tags { justify-content: flex-end; align-self: center; }
}
@container (min-width: 900px) {
  .row { grid-template-columns: 52px minmax(0, 1.4fr) minmax(0, 1fr) auto; grid-template-areas: "time title where tags"; }
}
.row:hover { background: var(--paper-2); }
.r-time { font: 500 12.5px var(--mono); color: var(--ink-2); }
.r-title { font-weight: 700; font-size: 15.5px; min-width: 0; overflow-wrap: anywhere; }
.r-title a { text-decoration: none; }
.r-title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.r-sub { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.r-where { font-size: 13px; color: var(--ink-2); min-width: 0; }
.r-where b { color: var(--ink); font-weight: 600; }
.r-km { font: 500 11px var(--mono); color: var(--ink-3); margin-left: 4px; }
.r-tags { display: flex; flex-wrap: wrap; gap: 5px; max-width: 230px; }
.r-tags .tag { white-space: nowrap; }
.r-where { overflow-wrap: anywhere; }
.tag { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .05em; padding: 2px 6px; border-radius: 3px; border: 1px solid currentColor; text-decoration: none; }
.tag.new { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tag.sold { color: var(--sold); }
.tag.swap { background: var(--sold); color: #fff; border-color: var(--sold); }
.tag.free { color: var(--ok); }
.tag.genre { color: var(--ink-3); border-color: var(--rule); }
.row.cancelled .r-title, .row.cancelled .r-where { text-decoration: line-through; color: var(--ink-3); }
.row.cancelled .tag { color: var(--ink-3); }

/* ---------- cinema ---------- */
.cine-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 6px; }
.daychip { border: 1px solid var(--ink); background: transparent; border-radius: 6px; padding: 6px 12px; cursor: pointer; text-align: center; line-height: 1.05; }
.daychip b { display: block; font-family: var(--display); font-size: 26px; font-weight: 400; }
.daychip span { font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.daychip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.cine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 0 34px; }
.cinema { break-inside: avoid; border-top: 2px solid var(--ink); padding: 12px 0 18px; }
.cinema h3 { font-family: var(--display); font-weight: 400; font-size: 30px; margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.cinema h3 small { font: 500 11px var(--mono); color: var(--ink-3); }
.film { display: grid; grid-template-columns: 1fr; padding: 6px 0; border-bottom: 1px dotted var(--rule); }
.film-t { font-weight: 700; }
.film-t a { text-decoration: none; }
.film-t a:hover { text-decoration: underline; }
.film-m { font-size: 12px; color: var(--ink-3); }
.times { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.time { font: 500 12px var(--mono); padding: 1px 6px; border: 1px solid var(--rule); border-radius: 3px; text-decoration: none; }
.time.past { color: var(--ink-3); text-decoration: line-through; border-style: dashed; }
.filmcard { display: grid; grid-template-columns: 74px 1fr; gap: 16px; border-top: 1px solid var(--rule); padding: 14px 0; }
.filmcard img { width: 74px; aspect-ratio: 2/3; object-fit: cover; border-radius: 3px; background: var(--paper-2); }
.filmcard h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 28px; line-height: 1; }
.filmcard p { margin: 4px 0 8px; font-size: 13px; color: var(--ink-2); max-width: 70ch; }
.fc-cine { display: grid; grid-template-columns: 170px 1fr; gap: 8px; font-size: 13px; padding: 2px 0; align-items: baseline; }
.imdb { font: 600 11px var(--mono); background: #f5c518; color: #000; padding: 1px 4px; border-radius: 3px; margin-left: 6px; vertical-align: middle; }

/* ---------- empty + sources ---------- */
.empty-state { margin-top: 60px; max-width: 560px; }
.empty-state h2 { font-family: var(--display); font-weight: 400; font-size: 44px; line-height: 1; margin: 0 0 12px; }
.empty-state p { color: var(--ink-2); }
.sentinel { height: 1px; }
.loading { margin-top: 40px; font: 500 13px var(--mono); color: var(--ink-3); }

.sources { border: 2px solid var(--ink); background: var(--paper); color: var(--ink); border-radius: 6px; width: min(720px, 92vw); padding: 24px 28px; }
.sources::backdrop { background: rgb(0 0 0 / .35); }
.sources h2 { font-family: var(--display); font-weight: 400; font-size: 44px; margin: 0; }
.sources .close { position: absolute; right: 14px; top: 10px; background: none; border: 0; font-size: 28px; cursor: pointer; }
.muted { color: var(--ink-3); font-size: 13px; }
.src { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: start; border-top: 1px solid var(--rule); padding: 12px 0; }
.src .dot { margin-top: 6px; }
.src h4 { margin: 0; font-size: 15px; }
.src p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); }
.src .err { color: var(--err); font-family: var(--mono); font-size: 11.5px; }
.spark { display: flex; gap: 2px; align-items: flex-end; height: 26px; }
.spark i { width: 5px; background: var(--ink-3); display: block; border-radius: 1px; }
.spark i.warning { background: var(--warn); } .spark i.error { background: var(--err); }

@media (max-width: 1200px) { :root { --rail: 250px; } .tab-name { font-size: 22px; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 2px solid var(--ink); }
  .day { grid-template-columns: 60px 1fr; }
  .head { position: static; }
  .day-date { top: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
