/* Cluemaster Studio: a chat app. Opaque, plain. Uses the site's variables from style.css. */
:root { --bg: #0b0d18; --surface: #11141f; --surface-2: #171b2a; --border: #232840; --txt: #e9ecf8; --dim: #8e96b3; --blue: #6c9bff; --red: #ff9f8f; --sand: #d7c9a0; }
html, body.app { height: 100%; }
body.app { margin: 0; background: var(--bg); color: var(--txt); display: flex; flex-direction: column; overflow: hidden; font-size: 16px; }
body.app::before, body.app::after { display: none; }

/* top bar */
.appbar { flex: none; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(14px, 3vw, 28px); border-bottom: 1px solid var(--border); background: var(--bg); }
.appbar-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.appbar a { text-decoration: none; }
.home { color: var(--dim); font-size: .9rem; }
.slash { color: var(--border); }
.title { color: var(--txt); font-weight: 600; letter-spacing: .005em; white-space: nowrap; }
.app-tools { display: flex; align-items: center; gap: 10px; }
.model-chip { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .76rem; color: var(--dim); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* controls */
button { font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid var(--border); color: var(--txt); background: var(--surface); padding: 8px 16px; transition: border-color .15s, background .15s; }
button:hover:not(:disabled) { border-color: #3a4270; background: var(--surface-2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #25356a; border-color: #34498f; }
button.primary:hover:not(:disabled) { background: #2e4286; }
button.small { padding: 5px 12px; font-size: .82rem; }
button.icon { padding: 6px 10px; }
input[type=text], input[type=password], textarea, select { font: inherit; color: var(--txt); background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; width: 100%; box-sizing: border-box; }
:focus-visible { outline: 2px solid rgba(108, 155, 255, .6); outline-offset: 2px; }

/* workspace */
.studio-app { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); padding: 0; max-width: none; width: 100%; text-align: left; }
.board-side { border-right: 1px solid var(--border); background: var(--bg); overflow-y: auto; padding: 18px 18px 24px; }
.board-side > summary { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-head h2 { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin: 0; font-weight: 600; }
.side-actions { display: flex; gap: 6px; }
.hint { color: var(--dim); font-size: .8rem; margin: 8px 0 14px; }
.side-sec { margin-bottom: 16px; }
.side-sec h3 { display: flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 600; margin: 0 0 8px; color: var(--txt); }
.side-sec .count { margin-left: auto; color: var(--dim); font-weight: 400; font-size: .8rem; }
.dot, i.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--dim); font-style: normal; flex: none; }
.dot.mine { background: var(--blue); } .dot.opponent { background: var(--red); } .dot.neutral { background: var(--sand); } .dot.assassin { background: #05060d; box-shadow: 0 0 0 1.5px #8a90a8; }
.side-sec ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.side-sec li { cursor: pointer; padding: 5px 10px; border-radius: 8px; font-size: .9rem; background: var(--surface); border: 1px solid var(--border); }
.side-sec li:hover { background: var(--surface-2); }
.side-sec.mine li { border-color: #2b4a8a; } .side-sec.opponent li { border-color: #7a4a42; } .side-sec.neutral li { border-color: #6b6347; } .side-sec.assassin li { border-color: #5a6078; }
.side-sec li.struck { text-decoration: line-through; opacity: .38; }
.empty-hint { color: var(--dim); font-size: .85rem; }

/* chat */
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 28px clamp(14px, 4vw, 40px) 8px; display: flex; flex-direction: column; min-height: 0; }
.chat-log:empty { align-items: center; justify-content: center; }
.chat-log:empty::before { content: "Cluemaster Studio"; font-family: var(--serif); font-size: clamp(1.8rem, 4vw, 2.6rem); color: var(--txt); }
.chat-log:empty::after { content: "Set up a board, then ask for a clue."; color: var(--dim); margin-top: 8px; }
.msg { width: min(760px, 100%); margin: 0 auto 20px; display: flex; flex-direction: column; gap: 6px; }
.msg.you { align-items: flex-end; }
.msg.you .who { display: none; }
.msg.you .bubble { background: var(--surface-2); border-radius: 18px; padding: 10px 16px; max-width: 85%; }
.msg.bot .who { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.bubble { line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg.bot .bubble { padding: 0; }
.msg.warn .flag { color: #ffb59f; }
.msg-stats { color: var(--dim); font-size: .74rem; margin-top: 8px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.flag { display: block; margin-top: 8px; color: #ffb59f; font-size: .85rem; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--dim); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.clue-card { white-space: normal; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.clue-card.rejected { border-color: #7a4a42; }
.clue-rejected-flag { color: #ffb59f; font-size: .78rem; margin-bottom: 8px; }
.clue-extra { color: var(--dim); font-size: .84rem; white-space: pre-wrap; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.clue-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.clue-word { font-family: var(--serif); font-size: 2.1rem; line-height: 1.1; color: #fff; }
.clue-number { color: var(--blue); }
.clue-targets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.target-chip { border: 1px solid #2b4a8a; background: #16233f; border-radius: 8px; padding: 3px 10px; font-size: .86rem; }
.clue-reasoning { color: #c3cbe6; margin-top: 10px; font-size: .9rem; }

/* composer */
.composer { flex: none; width: min(760px, 100%); margin: 0 auto; padding: 8px clamp(14px, 4vw, 40px) 18px; box-sizing: border-box; }
.chips { display: flex; gap: 8px; margin-bottom: 10px; }
.chip { padding: 6px 14px; font-size: .86rem; background: var(--surface); }
.chat-form { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 6px 6px 6px 18px; }
.chat-form:focus-within { border-color: #3a4270; }
.chat-form input { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 0; outline: none; }
.send { width: 38px; height: 38px; padding: 0; border-radius: 50%; background: var(--txt); color: #0b0d18; border: 0; font-size: 1.15rem; line-height: 1; }
.send:hover:not(:disabled) { background: #fff; }

/* dialogs */
dialog { color: var(--txt); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 0; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(3, 4, 10, .8); }
#settings-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100svh - 24px); }
#setup-dialog { width: min(680px, calc(100vw - 24px)); max-height: calc(100svh - 24px); }
dialog form { display: flex; flex-direction: column; max-height: calc(100svh - 24px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.dialog-body { padding: 8px 20px 18px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.setup-hint { color: var(--dim); font-size: .88rem; margin: 12px 0 14px; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-head { display: flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 600; }
.field textarea { min-height: 130px; resize: vertical; background: var(--bg); line-height: 1.6; }
.field.mine textarea:focus { border-color: var(--blue); } .field.opponent textarea:focus { border-color: var(--red); } .field.neutral textarea:focus { border-color: var(--sand); } .field.assassin textarea:focus { border-color: #8a90a8; }
.setting { margin-top: 16px; }
.setting label { display: block; font-size: .84rem; color: var(--dim); margin-bottom: 6px; }
.setting .help { color: var(--dim); font-size: .8rem; margin-top: 6px; line-height: 1.5; }
.setting .help a { color: var(--blue); }
.row-check { display: flex; align-items: center; gap: 10px; }
.row-check input { width: auto; }
.row-check label { margin: 0; }
.status { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--dim); margin-top: 8px; }
.status .led { width: 8px; height: 8px; border-radius: 50%; background: #666; }
.status.ok .led { background: #7fe3b4; } .status.bad .led { background: var(--red); } .status.checking .led { background: var(--blue); }
.banner { margin-top: 18px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; color: var(--dim); font-size: .82rem; }
pre.cmd { white-space: pre-wrap; word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: .78rem; margin: 8px 0; user-select: all; }
#ollama-check { margin-top: 10px; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

/* phones and narrow windows: the board sits above the chat and can be collapsed */
@media (max-width: 860px) {
  .studio-app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .board-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 38svh; padding: 10px 14px; }
  .board-side > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; font-weight: 600; font-size: .9rem; padding: 4px 0; }
  .board-side > summary::-webkit-details-marker { display: none; }
  .board-side > summary::after { content: "\2212"; color: var(--dim); }
  .board-side:not([open]) > summary::after { content: "+"; }
  .side-head h2, .hint { display: none; }
  .side-head { justify-content: flex-end; margin-top: 6px; }
  .side-sec { margin-bottom: 10px; }
  .model-chip { max-width: 40vw; }
  .home, .slash { display: none; }
}
@media (max-width: 560px) {
  .setup-grid { grid-template-columns: 1fr; }
  .field textarea { min-height: 84px; }
  .clue-word { font-size: 1.8rem; }
}

/* dialogs stay centred: the site's reset zeroes the default auto margins */
dialog[open] { position: fixed; inset: 0; margin: auto; }

/* board setup */
.words-label { display: block; font-size: .84rem; color: var(--dim); margin: 14px 0 6px; }
#words-input { min-height: 84px; resize: vertical; line-height: 1.5; }
.key-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 8px; font-size: .84rem; color: var(--dim); flex-wrap: wrap; }
.key-counts { display: flex; align-items: center; gap: 14px; }
.key-counts span { display: inline-flex; align-items: center; gap: 6px; color: var(--txt); font-variant-numeric: tabular-nums; }
.key-counts .todo { color: var(--sand); }
.key-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; min-height: 60px; }
.key-grid:empty::before { content: "The board appears here."; grid-column: 1 / -1; color: var(--dim); font-size: .88rem; padding: 14px 0; }
.key-cell { border-radius: 10px; padding: 12px 4px; min-height: 48px; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; word-break: break-word; line-height: 1.2; border: 1px dashed #3a4270; background: var(--bg); color: var(--txt); }
.key-cell.mine { background: #16233f; border: 1px solid #2b4a8a; }
.key-cell.opponent { background: #3a1f1f; border: 1px solid #7a4a42; }
.key-cell.neutral { background: #2b281c; border: 1px solid #6b6347; }
.key-cell.assassin { background: #000; border: 1px solid #8a90a8; }
.key-cell:hover { filter: brightness(1.25); }
@media (max-width: 560px) { .key-cell { font-size: .68rem; padding: 10px 2px; } .key-grid { gap: 6px; } }

/* visual board */
.studio-app { grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); }
.board-visual { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.vcell { padding: 0; min-height: 52px; border-radius: 10px; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; line-height: 1.15; word-break: break-word; border: 1px solid var(--border); background: var(--surface); color: var(--txt); display: flex; align-items: center; justify-content: center; text-align: center; }
.vcell.mine { background: #16233f; border-color: #2b4a8a; }
.vcell.opponent { background: #3a1f1f; border-color: #7a4a42; }
.vcell.neutral { background: #2b281c; border-color: #6b6347; }
.vcell.assassin { background: #000; border-color: #8a90a8; }
.vcell:hover { filter: brightness(1.3); }
.vcell.struck { opacity: .32; text-decoration: line-through; }
.board-left { display: flex; gap: 16px; margin-top: 12px; color: var(--txt); font-size: .86rem; font-variant-numeric: tabular-nums; }
.board-left span { display: inline-flex; align-items: center; gap: 6px; }
.cat-lists { display: none; }
.board-empty { display: none; padding: 24px 0; }
.board-empty p { color: var(--dim); margin: 0 0 12px; }
body.no-board .board-empty { display: block; }
body.no-board .board-left, body.no-board .hint, body.no-board #swap-btn { display: none; }

/* chat empty state */
.chat-log:empty::before, .chat-log:empty::after { content: none; }
.empty { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; flex: 1; padding: 24px; }
.empty h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0; max-width: none; }
.empty p { color: var(--dim); margin: 0 0 8px; max-width: 34ch; }
.chat-main:not(:has(.msg)) .empty { display: flex; }
.chat-main:not(:has(.msg)) .chat-log { flex: 0; padding: 0; }
body.no-board .composer { display: none; }

/* setup grid: always on screen, editable */
.key-cell { position: relative; padding: 0; border-radius: 10px; min-height: 52px; background: var(--bg); border: 1px dashed #3a4270; }
.key-cell.mine { background: #16233f; border: 1px solid #2b4a8a; } .key-cell.opponent { background: #3a1f1f; border: 1px solid #7a4a42; }
.key-cell.neutral { background: #2b281c; border: 1px solid #6b6347; } .key-cell.assassin { background: #000; border: 1px solid #8a90a8; }
.key-cell input { width: 100%; height: 100%; min-height: 50px; border: 0; background: transparent; text-align: center; text-transform: uppercase; font-size: .74rem; letter-spacing: .04em; padding: 6px 14px 6px 6px; border-radius: 10px; }
.key-cell input::placeholder { text-transform: none; letter-spacing: 0; color: var(--dim); font-size: .7rem; }
.dot-btn { position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; min-width: 0; padding: 0; border-radius: 50%; border: 1px solid #5a6078; background: transparent; }
.key-cell.mine .dot-btn { background: var(--blue); border-color: var(--blue); } .key-cell.opponent .dot-btn { background: var(--red); border-color: var(--red); }
.key-cell.neutral .dot-btn { background: var(--sand); border-color: var(--sand); } .key-cell.assassin .dot-btn { background: #05060d; border-color: #c5cadb; }
.key-grid:empty::before { content: none; }
.legend { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.legend .dot { margin-left: 8px; }
.legend .dot:first-child { margin-left: 0; }
@media (max-width: 860px) {
  .studio-app { grid-template-columns: 1fr; }
  .board-side { max-height: 46svh; }
  .vcell { min-height: 40px; font-size: .62rem; }
  .board-visual { gap: 4px; }
}

.field-count { margin-left: auto; color: var(--dim); font-weight: 400; font-variant-numeric: tabular-nums; }
.setup-total { color: var(--dim); font-size: .84rem; margin-top: 12px; text-align: right; min-height: 1.2em; }
.vcell.blank { border: 1px dashed #2a2f4a; background: transparent; pointer-events: none; }

:root { color-scheme: dark; }

.account-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
#account-text { color: var(--txt); font-weight: 600; }
#account-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-link { display: inline-block; padding: 8px 16px; border-radius: 999px; background: #25356a; border: 1px solid #34498f; color: var(--txt); text-decoration: none; font-size: .9rem; }
.btn-link:hover { background: #2e4286; }
button.danger { color: #ff9f8f; border-color: #7a4a42; }
.btn-link[hidden], #account-actions[hidden] { display: none; }

.vcell { word-break: normal; overflow-wrap: normal; hyphens: none; }
.vcell.long { font-size: .62rem; letter-spacing: 0; }
.vcell.xlong { font-size: .52rem; letter-spacing: 0; }

.send.stop { font-size: .8rem; background: #ff9f8f; }
.send.stop:hover:not(:disabled) { background: #ffb5a8; }
