:root {
  --paper: #f4f6f5;
  --panel: #ffffff;
  --ink: #1d2726;
  --ink-soft: #55625f;
  --line: #d6ddda;
  --teal: #0f6e6b;
  --teal-soft: #e3f0ee;
  --amber: #b7791f;
  --amber-soft: #fbf1dc;
  --red: #a63d2f;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.error { color: var(--red); }
[hidden] { display: none !important; }

label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .6rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="datetime-local"], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; font: inherit; font-size: .95rem; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
label.check { display: flex; align-items: center; gap: .5rem; font-size: .95rem; color: var(--ink); }
label.check input { width: auto; margin: 0; }

.btn { font: inherit; font-size: .9rem; font-weight: 500; padding: .5rem .9rem; border-radius: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: #0b5b58; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.quiet:hover { color: var(--ink); border-color: var(--line); }
.btn.danger { color: var(--red); }
.btn.icon { padding: .3rem .5rem; font-size: 1rem; line-height: 1; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1.75rem; }
.login-card h1 { margin-bottom: .25rem; }
.login-card .btn { width: 100%; margin-top: .5rem; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.save-state { font-size: .8rem; color: var(--ink-soft); min-width: 4.5rem; text-align: right; }
.save-state.dirty { color: var(--amber); }
.save-state.error { color: var(--red); }

/* List */
.list-main { max-width: 860px; margin: 0 auto; padding: 1.5rem 1.25rem; }
.interview-list { list-style: none; margin: 0; padding: 0; }
.interview-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.interview-list .name { font-family: var(--serif); font-size: 1.25rem; cursor: pointer; }
.interview-list .name:hover { color: var(--teal); }
.interview-list .sub { font-size: .85rem; color: var(--ink-soft); }
.interview-list .row-actions { display: flex; gap: .4rem; }

/* Dialog */
dialog { border: 1px solid var(--line); border-radius: 6px; padding: 0; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(29, 39, 38, .35); }
.dialog-form { padding: 1.5rem; }
.dialog-form h2 { margin-bottom: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

/* Interview layout */
.interview-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.5rem; padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
.side { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 4.25rem; align-self: start; max-height: calc(100vh - 5rem); overflow-y: auto; }
.side-block { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 1rem; }
.title-input { font-family: var(--serif); font-size: 1.35rem; font-weight: 500; border: none; border-bottom: 1px solid var(--line); border-radius: 0; padding: .25rem 0; margin-bottom: .75rem; }
.meta-grid label { margin-bottom: .5rem; }

.timer-block { text-align: center; }
.timer { font-family: var(--serif); font-size: 2.6rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; line-height: 1; margin: .25rem 0 .75rem; }
.timer-actions { display: flex; justify-content: center; gap: .5rem; margin-bottom: .75rem; }
.mark-row { display: flex; gap: .4rem; }
.mark-row input { margin: 0; }
.mark-list { text-align: left; margin: .5rem 0 0; padding-left: 1.2rem; font-size: .9rem; max-height: 200px; overflow-y: auto; }
.mark-list li { margin-bottom: .3rem; }
.mark-list .t { font-variant-numeric: tabular-nums; color: var(--teal); font-weight: 600; margin-right: .4rem; }
.mark-list .q { color: var(--ink-soft); font-size: .8rem; display: block; }

/* Questions */
.questions { min-width: 0; }
.section { margin-bottom: 2rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: .4rem; border-bottom: 2px solid var(--ink); margin-bottom: .5rem; }
.section-head h2 { font-size: 1.3rem; }
.section-head .count { font-size: .85rem; color: var(--ink-soft); }
.section-head input.section-title { font-family: var(--serif); font-size: 1.3rem; border: none; border-bottom: 1px dashed var(--line); border-radius: 0; padding: .1rem 0; margin: 0; }

.q { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .75rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: none; }
.q-check { padding-top: .2rem; }
.q-check input { width: 1.25rem; height: 1.25rem; margin: 0; cursor: pointer; accent-color: var(--teal); }
.q-body { min-width: 0; }
.q-text { font-family: var(--serif); font-size: 1.2rem; line-height: 1.4; margin-bottom: .5rem; }
.q.asked .q-text { color: var(--ink-soft); }
.q.priority .q-text::before { content: "★"; color: var(--amber); font-size: .9rem; margin-right: .45rem; vertical-align: .15em; }
.q-answer { min-height: 3.2rem; font-family: var(--sans); font-size: .95rem; }
.q.asked .q-answer:placeholder-shown { background: var(--teal-soft); }
.q-tools { display: flex; gap: .4rem; margin-top: .35rem; align-items: center; }
.q-tools .btn { font-size: .8rem; padding: .3rem .6rem; }
.q-tools .listening { background: var(--amber-soft); border-color: var(--amber); }
.q-status { font-size: .8rem; color: var(--ink-soft); margin-left: auto; }

/* Edit mode */
.editing .q-text { display: none; }
.editing textarea.q-edit { display: block; font-family: var(--serif); font-size: 1.15rem; margin-bottom: .4rem; }
textarea.q-edit { display: none; }
.edit-tools { display: none; gap: .3rem; margin-top: .3rem; }
.editing .edit-tools { display: flex; }
.editing .q-answer, .editing .q-tools { display: none; }
.add-q { display: none; margin-top: .5rem; }
.editing .add-q { display: inline-block; }
.add-section { display: none; margin-top: .5rem; }
.editing .add-section { display: inline-block; }

/* Toast */
.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 4px; font-size: .9rem; z-index: 20; }

@media (max-width: 900px) {
  .interview-layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .timer { font-size: 2.2rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
