:root {
  color-scheme: light;
  --ink: #232323;
  --muted: #746f66;
  --line: #ded7ca;
  --paper: #f8f6f1;
  --panel: #ffffff;
  --accent: #276c72;
  --green: #21815d;
  --red: #c54e58;
  --gold: #a97018;
  --shadow: 0 18px 44px rgba(54, 48, 40, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
a {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

a,
.import-button {
  display: inline-grid;
  place-items: center;
  padding: 0 14px;
}

.import-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.danger {
  color: var(--red);
}

.author-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.author-header,
.summary-strip,
.panel-title,
.form-actions,
.export-actions,
.tool-actions,
.list-tools {
  display: flex;
  align-items: center;
}

.author-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.header-user-state {
  min-height: 48px;
  padding: 7px 8px 7px 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 20px rgba(54, 48, 40, 0.06);
}

.header-user-state span,
.header-user-state strong {
  line-height: 1.1;
  white-space: nowrap;
}

.header-user-state span {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
}

.header-user-state strong {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 950;
}

.header-user-state button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 11px;
  font-size: 0.78rem;
}

.tool-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-actions button {
  padding: 0 14px;
}

.summary-strip {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.summary-strip div {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(54, 48, 40, 0.06);
}

.summary-strip strong,
.summary-strip span {
  display: block;
}

.summary-strip strong {
  margin-bottom: 4px;
  font-size: 1.8rem;
  line-height: 1;
}

.summary-strip span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.gate-panel {
  min-height: 360px;
  margin-bottom: 18px;
  padding: 28px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-panel h2 {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.08;
}

.gate-panel p {
  max-width: 460px;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.55;
}

.gate-panel button {
  min-width: 180px;
  padding: 0 18px;
}

.tool-panel {
  margin-bottom: 18px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(54, 48, 40, 0.06);
}

.tool-panel strong,
.tool-panel span {
  display: block;
}

.tool-panel strong {
  margin-bottom: 4px;
}

.tool-panel span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.45;
}

.tool-panel .user-state {
  margin-top: 6px;
  color: var(--accent);
}

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

.right-column {
  min-width: 0;
  display: grid;
  gap: 18px;
  align-content: start;
}

.editor-panel,
.preview-panel,
.list-panel,
.export-panel,
.admin-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.editor-panel {
  padding: 20px;
  display: grid;
  gap: 15px;
}

.preview-panel,
.list-panel,
.export-panel,
.admin-panel {
  padding: 18px;
}

.panel-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.45;
}

.admin-panel {
  margin-bottom: 18px;
}

.account-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 1fr) minmax(120px, 0.7fr) auto;
  gap: 10px;
  align-items: end;
}

.approval-section + .approval-section {
  margin-top: 18px;
}

.approval-section h3 {
  margin: 0 0 10px;
  font-size: 0.94rem;
}

.account-form button {
  padding: 0 14px;
}

.account-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.account-row {
  min-height: 58px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.account-row.pending {
  grid-template-columns: 1fr auto auto auto;
}

.account-row input {
  min-width: 160px;
  min-height: 38px;
  border-radius: 12px;
}

.account-row select {
  width: 128px;
  min-height: 38px;
  border-radius: 12px;
}

.account-row strong,
.account-row small {
  display: block;
}

.account-row strong {
  margin-bottom: 3px;
}

.account-row small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.account-row button {
  min-height: 38px;
  padding: 0 11px;
}

.account-row button.danger {
  color: var(--red);
}

.account-row button.primary {
  color: #fff;
}

.panel-title button {
  padding: 0 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

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

.answer-field {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.answer-field legend {
  grid-column: 1 / -1;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.answer-field label {
  position: relative;
  min-height: 56px;
  display: grid;
}

.answer-field input {
  position: absolute;
  opacity: 0;
}

.answer-field span {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--muted);
  font-size: 1.6rem;
  font-weight: 950;
}

.answer-field input:checked + span {
  border-color: var(--accent);
  background: #e6f2f1;
  color: var(--accent);
}

.form-issues {
  min-height: 24px;
  color: var(--red);
  font-size: 0.82rem;
  font-weight: 750;
  line-height: 1.45;
}

.form-actions,
.export-actions {
  gap: 8px;
}

.form-actions button,
.export-actions button {
  flex: 1;
  padding: 0 12px;
}

#previewAnswerBadge {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  background: #e6f2f1;
  color: var(--accent);
  font-weight: 900;
}

#previewAnswerBadge.false {
  background: #fae8ea;
  color: var(--red);
}

.app-preview-frame {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.app-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.app-preview-header span,
.app-preview-score span {
  display: block;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

.app-preview-header strong {
  display: block;
  margin-top: 3px;
  font-size: 1.7rem;
  line-height: 1.05;
  font-weight: 950;
}

.app-preview-score {
  min-width: 74px;
  padding: 9px 11px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.app-preview-score span {
  color: var(--muted);
  font-size: 0.68rem;
}

.app-preview-score strong {
  margin-top: 2px;
  font-size: 0.9rem;
}

.preview-card {
  min-height: 238px;
  padding: 20px;
  border: 1px solid rgba(35, 35, 35, 0.1);
  border-radius: 26px;
  background: #fff;
}

.preview-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

#previewCategory {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  background: #e6f2f1;
  color: var(--accent);
  font-weight: 900;
}

.preview-star {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(35, 35, 35, 0.12);
  border-radius: 16px;
  background: #fff;
  color: var(--gold);
  font-size: 1.7rem;
  font-weight: 900;
  line-height: 1;
}

#previewStatement {
  margin: 26px 0 0;
  font-size: clamp(1.55rem, 3vw, 2rem);
  line-height: 1.45;
  font-weight: 950;
  word-break: keep-all;
}

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

.preview-answer-button {
  min-height: 108px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 24px;
  color: #fff;
  opacity: 0.74;
}

.preview-answer-button.active {
  opacity: 1;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.34);
}

.preview-answer-button strong {
  display: block;
  font-size: 3.4rem;
  line-height: 0.95;
  font-weight: 950;
}

.preview-answer-button span {
  display: block;
  margin-top: 2px;
  font-weight: 900;
}

.answer-o {
  background: var(--green);
}

.answer-x {
  background: var(--red);
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.keyword-list span {
  padding: 6px 9px;
  border-radius: 999px;
  background: #f1eee7;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.preview-explanation {
  margin-top: 12px;
  padding: 15px;
  border: 1px solid rgba(35, 35, 35, 0.1);
  border-radius: 22px;
  background: #fff;
}

.preview-explanation > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.preview-explanation strong {
  color: var(--ink);
}

.preview-explanation > div span {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 850;
}

.preview-explanation p {
  margin-bottom: 12px;
  color: var(--ink);
  line-height: 1.6;
}

.list-tools {
  gap: 8px;
  margin-bottom: 12px;
}

.list-tools input {
  flex: 1.4;
}

.list-tools select {
  flex: 1;
}

.question-list {
  display: grid;
  gap: 9px;
  max-height: clamp(260px, 38vh, 520px);
  overflow: auto;
  padding-right: 4px;
}

.empty-list {
  min-height: 132px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fffdf8;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
}

.question-row {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.question-row.active {
  border-color: var(--accent);
  background: #f1f9f8;
}

.question-row strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  line-height: 1.35;
}

.question-row span,
.question-row small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.question-row em {
  font-style: normal;
  color: var(--red);
  font-weight: 900;
}

.export-panel {
  grid-column: 1 / -1;
}

.export-scope {
  margin-bottom: 10px;
}

.export-scope + .export-scope {
  margin-top: 10px;
}

#exportOutput {
  min-height: 280px;
  margin-bottom: 10px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
}

.helper-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

@media (max-width: 900px) {
  .author-shell {
    padding: 14px;
  }

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

  .header-user-state {
    width: 100%;
    justify-content: space-between;
  }

  .tool-actions {
    width: 100%;
  }

  .tool-actions a,
  .tool-actions .import-button,
  .tool-actions button {
    flex: 1;
  }

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

  .account-form {
    grid-template-columns: 1fr;
  }

  .tool-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .export-panel {
    grid-column: auto;
  }

  .right-column {
    gap: 14px;
  }
}

@media (max-width: 560px) {
  .summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-strip div {
    padding: 12px 8px;
  }

  .summary-strip strong,
  .summary-strip span {
    text-align: center;
  }

  .form-actions,
  .export-actions,
  .tool-actions,
  .list-tools {
    display: grid;
  }
}
