:root {
  --bg: #12100f;
  --panel: #1b1917;
  --panel-2: #232020;
  --line: #35302e;
  --ink: #eeeae6;
  --muted: #9c938c;
  --accent: #d4795b;
  --accent-ink: #1a1210;
  --ok: #6fae7d;
  --warn: #d9a441;
  --err: #d96a6a;
  --radius: 8px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f3ef; --panel: #fff; --panel-2: #f0ebe5; --line: #ded6cc;
    --ink: #221d1a; --muted: #6d635c; --accent-ink: #fff;
  }
}

* { box-sizing: border-box; }

/* An ID selector like `#login { display: grid }` outranks the UA stylesheet's
   [hidden] rule, so hiding a screen needs to win on specificity too. Without
   this the login card stays on screen and the app renders below it. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.screen { min-height: 100vh; }

/* --- login --- */
#login { display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(380px, 100%); }
.login-card h1 { margin: 0 0 .2rem; font-size: 1.4rem; }
.login-card label { display: block; margin: 1rem 0 0; font-size: .85rem; color: var(--muted); }
.login-card input { width: 100%; margin-top: .3rem; }
.login-card button { width: 100%; margin-top: 1.4rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* --- chrome --- */
/* Navigation lives down the left so the view names read as a list rather than
   competing with the account controls for the top bar. */
#app {
  display: grid;
  /* minmax(0,1fr) rather than 1fr: without it a wide table or <pre> in the
     workspace stretches the column and the whole page scrolls sideways. */
  grid-template-columns: 210px minmax(0, 1fr);
}

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: .8rem .7rem;
  /* align-self matters: a grid item is stretched to the row's full height by
     default, which leaves sticky nothing to stick within, and the sidebar
     scrolls away on a long queue. */
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: block; padding: .2rem .5rem; margin-bottom: 1.1rem; }

#workspace { min-width: 0; }

header {
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
  flex-wrap: wrap;
  min-height: 3.05rem;   /* holds the bar's height when nothing in it is tall */
}
.spacer { flex: 1; }
nav { display: flex; flex-direction: column; gap: .15rem; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #sidebar {
    position: static; height: auto; overflow: visible;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { margin-bottom: .6rem; }
  nav { flex-direction: row; flex-wrap: wrap; }
}

.ticket-search { display: flex; align-items: center; gap: .4rem; }
button.link.icon { display: flex; align-items: center; padding: .25rem; }
button.link.icon:hover, button.link.icon[aria-expanded="true"] { color: var(--accent); }
#ticket-search-input { width: 8.5rem; padding: .25rem .5rem; font-size: .85rem; }

main { padding: 0; }
.view { padding: 1.2rem; }

#view-queue {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 1.2rem;
  align-items: start;
}
/* The sidebar takes 210px off the usable width, so the queue's two columns run
   out of room sooner than they used to. */
@media (max-width: 1070px) {
  #view-queue { grid-template-columns: 1fr; }
}

.pane-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .8rem; border-bottom: 1px solid var(--line);
}
.pane-head.wide { display: block; border: 0; padding: 0 0 1rem; }
.pane-head h2 { margin: 0 0 .2rem; font-size: 1.1rem; }

#queue-pane, #detail-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
#detail-pane { padding: 0; }

/* Sits above the list so a rep is never reading search results while thinking
   they are looking at the queue. */
.search-banner {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  padding: .5rem .8rem; font-size: .85rem;
  background: var(--panel-2); border-bottom: 1px solid var(--line);
}
.search-banner button.link { padding: 0; }

#ticket-list { list-style: none; margin: 0; padding: 0; max-height: 74vh; overflow-y: auto; }
#ticket-list li {
  padding: .7rem .8rem; border-bottom: 1px solid var(--line); cursor: pointer;
}
#ticket-list li:hover { background: var(--panel-2); }
#ticket-list li.active { background: var(--panel-2); border-left: 3px solid var(--accent); }
#ticket-list .subject { display: block; font-weight: 600; }
#ticket-list .meta { font-size: .78rem; color: var(--muted); }

/* --- detail --- */
.detail-head { padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 0 0 .3rem; font-size: 1.15rem; }

.thread { padding: 1rem 1.2rem; max-height: 40vh; overflow-y: auto; }
.comment { border-left: 3px solid var(--line); padding: .1rem 0 .1rem .8rem; margin-bottom: 1rem; }
.comment.agent { border-left-color: var(--accent); }
.comment.internal { border-left-style: dashed; opacity: .8; }
.comment .who { font-size: .8rem; color: var(--muted); }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .2rem; }

.ai-panel { padding: 1rem 1.2rem; border-top: 1px solid var(--line); background: var(--panel-2); }
.ai-panel h3 { margin: 0 0 .6rem; font-size: .95rem; }

.question { margin-bottom: 1rem; }
.question .q { font-weight: 600; }
.question .why { font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.question .opts { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .35rem; }
.question .opts button { font-size: .8rem; padding: .2rem .6rem; }

textarea {
  width: 100%; min-height: 200px; resize: vertical;
  font: inherit; line-height: 1.55;
}
input, select, textarea {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: .5rem .6rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; cursor: pointer; padding: .45rem .9rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel-2); color: var(--ink);
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; color: var(--muted); padding: .2rem .4rem; }
button.link:hover { color: var(--ink); }
.tab {
  background: none; border: none; color: var(--muted);
  text-align: left; padding: .45rem .5rem; border-radius: 6px;
  border-left: 2px solid transparent;
}
.tab:hover { color: var(--ink); background: var(--panel-2); }
/* Down the left the accent reads as a marker beside the name, not an
   underline beneath it. */
.tab.active {
  color: var(--ink); background: var(--panel-2);
  border-left-color: var(--accent); font-weight: 600;
}

@media (max-width: 760px) {
  .tab { border-left: 0; border-bottom: 2px solid transparent; }
  .tab.active { border-left: 0; border-bottom-color: var(--accent); }
}

.actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .8rem; }
.actions label { font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: .3rem; }

.badge {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  padding: .2rem .5rem; border-radius: 999px; border: 1px solid var(--line);
}
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.ok { color: var(--ok); border-color: var(--ok); }

.muted { color: var(--muted); }
.error { color: var(--err); }
.empty { padding: 3rem 1.2rem; text-align: center; color: var(--muted); }

.pattern, .audit-row, .membership-row {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.1rem; margin-bottom: .7rem;
}

.membership-row { cursor: pointer; }
.membership-row:hover, .membership-row:focus-visible {
  border-color: var(--accent); outline: none;
}
.membership-head {
  display: flex; align-items: baseline; gap: .6rem; justify-content: space-between;
}
.membership-row .subject { font-weight: 600; }
.membership-row .small { font-size: .8rem; margin-top: .3rem; }
/* The guest's own wording, set apart so it is not mistaken for the console's. */
.quote {
  white-space: pre-wrap; overflow-wrap: anywhere;
  border-left: 2px solid var(--line); padding: .1rem 0 .1rem .6rem; margin-top: .45rem;
}
/* What a guest named — the film and cinema a schedule check needs. */
.asked-about { display: flex; flex-wrap: wrap; gap: .4rem; margin: .45rem 0 .1rem; }
.chip {
  font-size: .78rem; padding: .12rem .5rem; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.chip-missing { color: var(--warn); border-color: var(--warn); }

/* The console answers film questions with nobody reading them first. Whether
   that is switched on is not a detail to bury in a settings page. */
.autoreply {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-top: .6rem; padding: .5rem .8rem;
  border: 1px solid var(--line); border-left: 3px solid var(--muted);
  border-radius: var(--radius); background: var(--panel);
  font-size: .85rem;
}
.autoreply.live { border-left-color: var(--warn); }
.autoreply.live .autoreply-label { color: var(--warn); font-weight: 600; }
.autoreply-label { color: var(--muted); }
.head-badges { display: flex; gap: .4rem; flex-shrink: 0; }
.badge.badge-bot { color: var(--warn); border-color: var(--warn); }
.badge.conf-high { color: var(--ok); border-color: var(--ok); }
.badge.conf-medium { color: var(--warn); border-color: var(--warn); }
.badge.conf-low { color: var(--muted); }
.pattern h3 { margin: 0 0 .3rem; font-size: 1rem; }
.pattern pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--panel-2); padding: .7rem; border-radius: 6px; }
.audit-row { display: grid; grid-template-columns: 165px 130px 150px 1fr; gap: .6rem; font-size: .85rem; padding: .5rem .8rem; }
@media (max-width: 760px) { .audit-row { grid-template-columns: 1fr; } }

dialog {
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem; width: min(380px, 92vw);
}
dialog::backdrop { background: rgb(0 0 0 / .55); }
dialog h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
dialog label { display: block; margin-bottom: .8rem; font-size: .85rem; color: var(--muted); }
dialog input { width: 100%; margin-top: .3rem; }

.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem 1.1rem; z-index: 20; max-width: min(560px, 92vw);
}
.toast.err { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); }
