:root {
  --green: #3f6b34;
  --orange: #e2613b;
  --navy: #1f2a5a;
  --ink: #1b1f2b;
  --muted: #6e6a62;
  --line: #e5dccd;
  --sand: #f4eee3;
  --paper: #fffdf8;
  --soft: #efe7d8;
  --serif: "Fraunces", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--sand);
  /* faint eight-point star lattice */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23c9b99c' stroke-opacity='.28'%3E%3Crect x='24' y='24' width='24' height='24'/%3E%3Crect x='24' y='24' width='24' height='24' transform='rotate(45 36 36)'/%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
main { min-width: 0; }

/* ---------- Rail ---------- */
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 32px;
  padding: 30px 22px; background: var(--navy); color: #e9e4f5;
}
.qasid { font-family: var(--serif); font-size: 46px; font-weight: 600; letter-spacing: -1px; line-height: 1; color: #fff; }
.qasid .g { color: #8fc27c; }
.qasid .o { color: #f2875f; }
.maker { margin-top: 8px; font-family: var(--serif); font-style: italic; font-size: 15px; color: #b9b6d3; }
.maker .g { color: #8fc27c; }
.maker .o { color: #f2875f; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: transparent; color: #c9c6e0; text-align: left;
  font: inherit; font-size: 15px; font-weight: 500; padding: 11px 14px; border-radius: 12px; cursor: pointer; transition: .2s;
}
.nav-item:hover { background: #ffffff10; color: #fff; }
.nav-item.active { background: var(--paper); color: var(--navy); font-weight: 700; }
.nav-item .ico { width: 18px; text-align: center; color: #f2875f; }
.nav-item em { margin-left: auto; font-style: normal; font-size: 10px; letter-spacing: .6px; text-transform: uppercase; opacity: .6; }

.meter { margin-top: auto; padding: 16px; border: 1px solid #ffffff1f; border-radius: 14px; font-size: 13px; }
.meter-top { display: flex; justify-content: space-between; color: #c9c6e0; }
.meter-top b { color: #fff; }
.bar { height: 6px; background: #ffffff1a; border-radius: 99px; margin: 10px 0 8px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8fc27c, #f2875f); border-radius: 99px; transition: width .5s; }
.meter-note { color: #9f9cbd; font-size: 12px; line-height: 1.45; }
.meter-note.bad { color: #f6a487; }
.logout { margin-top: -18px; background: none; border: 0; color: #9f9cbd; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; padding: 4px 2px; }
.logout:hover { color: #fff; }

/* ---------- Main ---------- */
main { padding: 48px clamp(16px, 5vw, 64px) 24px; max-width: 920px; width: 100%; }
.panel { display: none; animation: in .35s ease; }
.panel.active { display: block; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

.head { margin-bottom: 24px; }
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--orange); }
.head h1 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 4.6vw, 46px); line-height: 1.1; letter-spacing: -.8px; color: var(--navy); }
.head h1 em { font-weight: 400; color: var(--green); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: clamp(16px, 3vw, 26px); box-shadow: 0 1px 0 #fff inset, 0 18px 40px -28px #3a2c1266; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

/* ---------- Controls ---------- */
button { font: inherit; }
.primary { background: var(--navy); color: #fff; border: 0; border-radius: 12px; padding: 12px 22px; font-weight: 700; cursor: pointer; transition: .2s; }
.primary:hover { background: #2b3a7a; }
.primary:disabled { opacity: .55; cursor: wait; }
.text-btn { background: none; border: 0; padding: 4px 0; color: var(--orange); font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none; font-family: "Manrope", sans-serif; }
.text-btn:hover { text-decoration: underline; }
textarea, select { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; color: var(--ink); outline: none; transition: .2s; }
textarea:focus, select:focus { border-color: var(--navy); box-shadow: 0 0 0 3px #1f2a5a1a; }
textarea { resize: vertical; line-height: 1.6; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
input[type=range] { accent-color: var(--orange); margin-top: 12px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 16px 0; }
.field-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.field-top label { flex-direction: row; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- Chat ---------- */
.chat-card { display: flex; flex-direction: column; }
.messages { height: min(50vh, 440px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 2px 2px 14px; }
.empty { margin: auto; text-align: center; color: var(--muted); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; max-width: 560px; }
.chip { border: 1px solid var(--line); background: var(--sand); border-radius: 10px; padding: 9px 13px; font-size: 13.5px; cursor: pointer; color: var(--ink); transition: .2s; }
.chip:hover { border-color: var(--orange); background: #fff; }
.msg { max-width: 80%; padding: 12px 16px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; unicode-bidi: plaintext; }
.msg.user { align-self: flex-end; background: var(--navy); color: #fff; border-radius: 16px 16px 4px 16px; }
.msg.bot { align-self: flex-start; background: var(--sand); border-radius: 16px 16px 16px 4px; border-left: 3px solid var(--green); }
.msg.err { align-self: flex-start; background: #fbe3d8; color: #8a3214; border-radius: 12px; }
.msg .meta { margin-top: 8px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .2; } }
.composer { display: flex; gap: 10px; align-items: flex-end; padding-top: 14px; border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 160px; }
.send { flex: none; width: 46px; height: 46px; border-radius: 12px; border: 0; background: var(--orange); color: #fff; font-size: 20px; font-weight: 700; cursor: pointer; }
.send:disabled { opacity: .5; cursor: wait; }

.meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.meta b { color: var(--ink); font-weight: 700; }
.msg.bot .meta b { color: var(--navy); }

/* ---------- Results / recorder ---------- */
.result { margin-top: 18px; padding: 16px; background: var(--sand); border-radius: 14px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.result audio { width: 100%; }
.transcript { width: 100%; font-size: 18px; line-height: 1.6; white-space: pre-wrap; font-family: var(--serif); }
.hidden { display: none !important; }
.recorder { display: flex; align-items: center; gap: 18px; padding: 20px; border-radius: 16px; background: var(--sand); }
.mic { width: 64px; height: 64px; flex: none; border-radius: 50%; border: 0; cursor: pointer; background: var(--orange); display: grid; place-items: center; transition: .2s; box-shadow: 0 0 0 6px #e2613b22; }
.mic span { width: 16px; height: 24px; border-radius: 9px; background: #fff; }
.mic.rec { background: var(--navy); animation: pulse 1.4s infinite; }
.mic.rec span { width: 18px; height: 18px; border-radius: 4px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #1f2a5a55; } 70% { box-shadow: 0 0 0 16px #1f2a5a00; } }
#rec-label { font-weight: 700; color: var(--navy); }
.link { display: inline; color: var(--orange); font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: underline; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 10px 30px -10px #0006; z-index: 10; }
footer { margin-top: 36px; color: var(--muted); font-size: 12.5px; }
footer a { color: var(--orange); }

/* ---------- Small screens: rail becomes a top bar ---------- */
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail, main { min-width: 0; }
  .chips { max-width: 100%; }
  .chip { max-width: 100%; }
  .rail { position: static; height: auto; gap: 16px; padding: 18px 16px 12px; }
  .qasid { font-size: 34px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-item { width: auto; padding: 9px 12px; font-size: 14px; white-space: nowrap; }
  .nav-item em { display: none; }
  .meter { margin-top: 0; padding: 10px 12px; }
  main { padding-top: 28px; }
  .msg { max-width: 92%; }
}

/* ---------- Benchmark ---------- */
#bench .card + .card, #responses .card { margin-top: 18px; }
.step { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; }
.step:first-child { margin-top: 0; }
.step h3, .card-title h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 20px; color: var(--navy); }
.num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: #fff; font-size: 13px; font-weight: 700; }
.opt { font-weight: 500; color: #a39d91; font-size: 12px; }
input[type=text], input[type=password] { width: 100%; font: inherit; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; background: #fff; color: var(--ink); outline: none; }
input[type=text]:focus, input[type=password]:focus { border-color: var(--navy); box-shadow: 0 0 0 3px #1f2a5a1a; }
/* API key boxes are plain text fields shown as dots, so browsers don't offer the site login password here. */
input.secret { -webkit-text-security: disc; text-security: disc; }
input.secret:placeholder-shown { -webkit-text-security: none; text-security: none; }
.key-row { display: flex; gap: 8px; }
.key-row .ghost-btn { flex: none; padding: 9px 14px; }
.key-status { font-size: 12.5px; font-weight: 600; min-height: 1em; }
.key-status.ok { color: var(--green); }
.key-status.bad { color: #b4471f; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; margin: -4px 0 4px; }
.check input { accent-color: var(--navy); width: 16px; height: 16px; }
.small { font-size: 12.5px; line-height: 1.5; }
.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 8px; }
.model { display: flex; flex-direction: row; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 600; color: var(--ink); font-size: 13.5px; }
.model:has(input:checked) { border-color: var(--navy); background: #f1f2f8; }
.model:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.model input { accent-color: var(--navy); }
.model small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.tag { margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; padding: 3px 7px; border-radius: 6px; }
.tag.s { background: #e4efdf; color: var(--green); }
.tag.o { background: #fbe6dc; color: #b4471f; }
.custom-model { display: flex; gap: 12px; align-items: center; margin-top: 10px; max-width: 460px; }
.langs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.lang { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 8px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--muted); }
.lang.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.run-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.run-bar .hint { flex: 1; min-width: 180px; }
label.inline select { width: auto; }
.ghost-btn { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 18px; font-weight: 700; cursor: pointer; color: var(--ink); }
.progress { height: 4px; background: var(--soft); border-radius: 99px; margin-top: 14px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--orange)); transition: width .3s; }
.card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.summary { width: 100%; border-collapse: collapse; font-size: 13.5px; white-space: nowrap; }
.summary th { text-align: right; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.summary td { text-align: right; padding: 10px; border-bottom: 1px solid #f0e9dc; font-variant-numeric: tabular-nums; }
.summary th:first-child, .summary td:first-child { text-align: left; }
.summary td.best { color: var(--green); font-weight: 800; }
.summary td small { color: var(--muted); }
.prompt-card h4 { margin: 0 0 4px; font-size: 15px; font-weight: 700; unicode-bidi: plaintext; }
.prompt-card .lang-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--orange); }
.answers { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 14px; }
.answer { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.answer-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13.5px; }
.answer-body { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; max-height: 260px; overflow-y: auto; unicode-bidi: plaintext; }
.answer-body.err { color: #8a3214; }
.answer-body.wait { color: var(--muted); font-style: italic; }
.answer .meta { border-top: 1px dashed var(--line); padding-top: 8px; }
.stars { display: flex; gap: 2px; }
.stars button { border: 0; background: none; padding: 0 1px; font-size: 18px; color: #d9d0bf; cursor: pointer; line-height: 1; }
.stars button.on { color: var(--orange); }

/* Benchmark modes + audio */
.modes { display: flex; gap: 6px; margin: 22px 0 18px; padding: 5px; background: var(--soft); border-radius: 14px; width: max-content; max-width: 100%; overflow-x: auto; }
.mode { border: 0; background: none; padding: 9px 18px; border-radius: 10px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.mode small { font-weight: 600; font-size: 10px; letter-spacing: .5px; opacity: .7; }
.mode.active { background: var(--paper); color: var(--navy); box-shadow: 0 2px 8px -4px #3a2c1255; }
.mode-panel { display: none; }
.mode-panel.active { display: block; }
.mode-panel > .card + .card, .mode-panel > div > .card { margin-top: 18px; }
.answer audio { width: 100%; height: 36px; }
.unsupported { color: var(--muted); font-style: italic; font-size: 13px; }
.clip-add { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.file-btn { display: inline-flex; flex-direction: row; font-size: 15px; color: var(--ink); }
#s-record.rec { background: var(--navy); color: #fff; border-color: var(--navy); }
.clips { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.clip { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.clip audio { width: 100%; height: 34px; }
.clip-meta { display: flex; gap: 8px; align-items: center; }
.clip-meta select { width: auto; padding: 7px 10px; font-size: 13px; }
.clip input[type=text] { grid-column: 1 / -1; padding: 9px 12px; font-size: 14px; }
.clip .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; }
.ref { font-size: 12.5px; color: var(--muted); margin-top: 4px; unicode-bidi: plaintext; }
