:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #111111;
  --muted: #666666;
  --line: #d9d9d9;
  --soft: #f5f5f5;
  --soft-strong: #eeeeee;
  --danger: #8a1f11;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  width: auto;
  min-height: 44px;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  padding: 0 18px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: var(--fg);
  color: var(--bg);
}

button:disabled {
  border-color: var(--line);
  color: #999999;
  cursor: not-allowed;
}

.primary-button {
  background: var(--fg);
  color: var(--bg);
}

.primary-button:hover:not(:disabled) {
  background: #333333;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.data-status {
  max-width: 360px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
  overflow-wrap: break-word;
}

.setup-panel {
  margin: 22px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.setup-form {
  display: grid;
  grid-template-columns:
    minmax(180px, 0.9fr) minmax(300px, 1.3fr) minmax(120px, 0.55fr)
    minmax(150px, 0.6fr) auto;
  gap: 14px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.range-field {
  align-self: stretch;
}

.field span,
.meta-label,
.answer-label {
  color: var(--muted);
  font-size: 0.82rem;
}

select,
input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
}

select,
input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 220px;
  padding: 12px;
  line-height: 1.55;
  resize: vertical;
}

.range-picker {
  display: grid;
  grid-template-columns: minmax(108px, 1fr) auto minmax(108px, 1fr);
  gap: 10px;
  align-items: start;
}

.range-column {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.range-input-title {
  color: var(--muted);
  font-size: 0.78rem;
}

.range-number-input {
  min-height: 40px;
  padding: 0 10px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}

.range-dash {
  min-height: 40px;
  margin-top: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.range-current {
  color: var(--muted);
  font-size: 0.95rem;
}

.range-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.range-option {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.range-option span {
  color: var(--muted);
  font-size: 0.78rem;
}

.range-option select {
  min-height: 40px;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.project-summary {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
  overflow-wrap: break-word;
}

.sync-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.sync-panel h2 {
  margin: 0 0 5px;
  font-size: 1rem;
}

.sync-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.sync-status.is-error {
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.test-panel,
.session-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.test-panel {
  min-height: 560px;
  padding: 24px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 22px;
}

.test-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.test-meta div,
.stats div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
}

.test-meta strong,
.stats dd {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
  overflow-wrap: break-word;
}

.prompt-area {
  position: relative;
  display: grid;
  align-content: center;
  min-height: 220px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 28px 56px 28px 0;
}

.prompt-kicker {
  margin-bottom: 10px;
  color: var(--muted);
}

.prompt-number {
  width: fit-content;
  margin-bottom: 14px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  color: var(--fg);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

#promptText {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.12;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hint-trigger {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--fg);
  background: var(--bg);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

.hint-trigger[aria-expanded="true"]:not(:disabled),
.hint-trigger:hover:not(:disabled) {
  background: var(--fg);
  color: var(--bg);
}

.hint-popover {
  position: absolute;
  top: calc(50% + 30px);
  right: 0;
  z-index: 10;
  width: min(360px, calc(100vw - 64px));
  padding: 14px;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 14px 30px rgb(0 0 0 / 16%);
}

.hint-popover.is-hidden {
  display: none;
}

.hint-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hint-close {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: var(--line);
  border-radius: 50%;
  line-height: 1;
}

.hint-popover p {
  margin: 8px 0 0;
  font-size: 0.98rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.hint-example-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.answer-box {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  background: var(--soft);
}

.answer-box.is-hidden {
  border-color: var(--line);
  color: transparent;
  user-select: none;
}

.answer-box.is-hidden .answer-label,
.answer-box.is-hidden .notes-block {
  color: transparent;
}

.answer-box p {
  margin: 6px 0 0;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.notes-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.notes-block.is-empty {
  display: none;
}

.control-stack {
  display: grid;
  gap: 16px;
}

.control-section {
  display: grid;
  gap: 8px;
}

.control-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.judgment-actions,
.actions {
  display: grid;
  gap: 10px;
}

.show-answer-main {
  min-height: 52px;
  border-width: 2px;
  background: var(--bg);
  font-size: 1.05rem;
  font-weight: 700;
}

.show-answer-main:hover:not(:disabled) {
  background: var(--soft-strong);
  color: var(--fg);
}

.judgment-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 10px;
  border: 1px solid var(--fg);
  border-radius: var(--radius);
  background: var(--soft);
}

.actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.judge-button {
  min-height: 54px;
  border-width: 2px;
  background: var(--bg);
  font-size: 1.05rem;
  font-weight: 700;
}

.judge-correct:not(:disabled) {
  background: var(--fg);
  color: var(--bg);
}

.judge-fuzzy:not(:disabled) {
  background: var(--soft-strong);
}

.judge-wrong:not(:disabled) {
  background: var(--bg);
}

.utility-button {
  border-color: var(--line);
  background: var(--bg);
  color: var(--fg);
}

.utility-button:hover:not(:disabled) {
  border-color: var(--fg);
}

.end-round-button:not(:disabled) {
  border-style: dashed;
}

.session-panel {
  padding: 18px;
}

.session-panel h2 {
  margin-bottom: 14px;
  font-size: 1.15rem;
}

.stats {
  display: grid;
  gap: 10px;
  margin: 0;
}

.stats dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.stats dd {
  margin-left: 0;
}

.message {
  margin-top: 14px;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: break-word;
}

.message.is-error {
  border-color: var(--danger);
  color: var(--danger);
}

.feedback-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.feedback-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.feedback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 840px) {
  .app-shell {
    width: min(calc(100vw - 20px), 720px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .data-status {
    text-align: left;
  }

  .setup-form,
  .workspace {
    grid-template-columns: 1fr;
  }

  .setup-form > *,
  .primary-button {
    width: 100%;
  }

  .test-panel {
    min-height: 520px;
  }
}

@media (max-width: 520px) {
  .test-meta,
  .range-options,
  .judgment-actions,
  .actions,
  .feedback-actions {
    grid-template-columns: 1fr;
  }

  .sync-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-button {
    width: 100%;
  }

  .setup-panel,
  .test-panel,
  .session-panel {
    padding: 14px;
  }

  .prompt-area {
    padding-right: 0;
    padding-top: 72px;
  }

  .hint-trigger {
    top: 16px;
    transform: none;
  }

  .hint-popover {
    top: 64px;
    left: 0;
    right: 0;
    width: auto;
  }
}
