:root {
  color-scheme: light;
  --bg: #f7f4ed;
  --surface: #ffffff;
  --surface-soft: #fff9e8;
  --ink: #24313a;
  --muted: #66737d;
  --line: #d9e0df;
  --teal: #127c7b;
  --teal-dark: #0c5e5d;
  --mint: #dff3ee;
  --blue: #285f9f;
  --sun: #f4b63f;
  --coral: #d9634f;
  --green: #3d8b5b;
  --shadow: 0 18px 45px rgba(38, 49, 58, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(18, 124, 123, 0.10), rgba(247, 244, 237, 0) 360px),
    var(--bg);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-header {
  border-bottom: 1px solid rgba(18, 124, 123, 0.18);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.25;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.cover-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.cover-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid rgba(18, 124, 123, 0.24);
  border-radius: 999px;
  background: #eef8f5;
  color: var(--teal-dark);
  padding: 3px 10px;
  font-size: 0.84rem;
  font-weight: 900;
}

.cover-credit-note {
  max-width: 680px;
  margin: 10px 0 0;
  color: #4f6068;
  font-size: 0.88rem;
  line-height: 1.55;
}

.mode-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.app-locked .mode-switcher {
  display: none;
}

.mode-button,
.primary-button,
.secondary-button,
.quiet-button,
.danger-button {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.mode-button {
  color: var(--teal-dark);
  background: #eef8f5;
  border-color: rgba(18, 124, 123, 0.18);
}

.mode-button.active {
  color: #ffffff;
  background: var(--teal);
  box-shadow: 0 8px 18px rgba(18, 124, 123, 0.22);
}

.primary-button {
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
}

.secondary-button {
  color: var(--teal-dark);
  background: #ffffff;
  border-color: rgba(18, 124, 123, 0.34);
}

.quiet-button {
  color: var(--blue);
  background: #f3f7fc;
  border-color: #cbdbee;
}

.danger-button {
  color: #ffffff;
  background: #b84536;
  border-color: #b84536;
}

.mode-button:hover,
.primary-button:hover,
.secondary-button:hover,
.quiet-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 26px auto 56px;
}

.screen-header {
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
}

.screen-header h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2.2rem);
  line-height: 1.28;
}

.screen-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 3vw, 32px);
}

.soft-panel {
  background: var(--surface-soft);
  border: 1px solid #ead7a7;
  border-radius: var(--radius);
  padding: 18px;
}

.password-panel {
  max-width: 720px;
}

.password-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.context-box,
.source-note,
.decision-panel,
.class-insight {
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.context-box {
  margin: 18px 0;
  background: #f4faf7;
  border-color: #c7e0d5;
  padding: 16px;
}

.context-box.compact {
  margin: 0;
}

.context-source {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 0.84rem;
  font-weight: 900;
}

.context-box h3,
.context-box h4,
.decision-panel h3,
.class-insight h3 {
  margin: 0 0 8px;
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.context-box ul {
  margin: 0;
  padding-left: 1.15em;
}

.source-note {
  background: #eef5fb;
  border-color: #c6d8ea;
  color: #244761;
  padding: 12px 14px;
}

.decision-panel,
.class-insight {
  background: #ffffff;
  padding: 18px;
}

.class-insight {
  margin-top: 16px;
}

.meter-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.meter-row {
  display: grid;
  grid-template-columns: minmax(190px, 0.95fr) minmax(160px, 1fr) 64px;
  align-items: center;
  gap: 10px;
}

.meter-row strong,
.meter-row span {
  display: block;
}

.meter-row span {
  color: var(--muted);
  font-size: 0.86rem;
}

.meter-track {
  height: 14px;
  border-radius: 999px;
  background: #e8eeee;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--sun));
}

.meter-row b {
  color: #2d4e5d;
  text-align: right;
}

.analysis-memos {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.analysis-memos p {
  margin: 0;
  border-left: 4px solid var(--sun);
  background: #fff8e7;
  border-radius: var(--radius);
  padding: 8px 10px;
}

.notice-small-sample {
  border: 1px solid #d9d4b4;
  border-radius: var(--radius);
  background: #fffbea;
  color: #60542a;
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 0.92rem;
}

.notice-small-sample p,
.profit-note p,
.gpts-use-notice p {
  margin: 0;
}

.notice-small-sample p + p,
.profit-note p + p,
.gpts-use-notice p + p {
  margin-top: 4px;
}

.profit-note {
  border: 1px solid #cbdbee;
  border-radius: var(--radius);
  background: #f5f9fd;
  color: #2b4558;
  padding: 14px;
  margin-top: 14px;
  font-size: 0.94rem;
}

.plan-profit-note {
  background: #fffdf5;
  border-color: #ead7a7;
}

.dashboard-profit-note {
  background: #f7fbf8;
  border-color: #c7e0d5;
}

.profit-outlook {
  display: grid;
  gap: 6px;
  border: 1px solid #e2e8e6;
  border-radius: var(--radius);
  background: #fbfdfc;
  padding: 12px;
}

.profit-outlook p {
  margin: 0;
}

.student-glossary-panel {
  display: grid;
  gap: 10px;
  border: 1px solid #c9ddd7;
  border-radius: var(--radius);
  background: #f7fbf8;
  padding: 14px;
  margin: 0 0 18px;
}

.student-glossary-panel h3 {
  margin: 0;
  color: var(--teal-dark);
  font-size: 1.08rem;
}

.student-glossary-panel .note {
  margin: 4px 0 0;
}

.student-glossary-panel .glossary-details {
  margin-top: 0;
}

.student-glossary-panel .glossary-card {
  background: #ffffff;
}

.glossary-details {
  margin-top: 12px;
}

.glossary-details summary {
  color: var(--blue);
  cursor: pointer;
  font-weight: 900;
}

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

.glossary-card {
  border: 1px solid #d9e2ea;
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px;
}

.glossary-card strong {
  color: var(--teal-dark);
}

.glossary-card p {
  margin: 4px 0 0;
}

.gpts-action-panel {
  border: 1px solid #d8e2ea;
  border-radius: var(--radius);
  background: #ffffff;
  padding: 14px;
}

.gpts-use-notice {
  border: 1px solid #d9e0df;
  border-radius: var(--radius);
  background: #f7faf9;
  color: #43515b;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
  gap: 22px;
}

.lead {
  font-size: 1.08rem;
  color: #33434b;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: #e6f2fa;
  color: #1f527d;
  border: 1px solid #c7ddea;
  padding: 4px 10px;
  font-size: 0.88rem;
  font-weight: 800;
}

.tag:nth-child(2n) {
  background: #e5f4ea;
  color: #2c6744;
  border-color: #c9e4d0;
}

.tag:nth-child(3n) {
  background: #fff1cf;
  color: #7c5300;
  border-color: #efd088;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.form-block {
  display: grid;
  gap: 8px;
}

.form-block.full {
  grid-column: 1 / -1;
}

label,
.field-label {
  font-weight: 800;
}

input[type="text"],
input[type="search"],
textarea,
select {
  width: 100%;
  border: 1px solid #c8d4d3;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 126px;
  resize: vertical;
}

input[type="text"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(18, 124, 123, 0.16);
}

.note {
  color: var(--muted);
  font-size: 0.92rem;
}

.student-top {
  display: grid;
  gap: 16px;
}

.progress-wrap {
  display: grid;
  gap: 8px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--teal-dark);
  font-weight: 900;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #dbe6e3;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--sun));
}

.step-layout {
  display: grid;
  gap: 18px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.choice-card {
  position: relative;
  border: 2px solid #d7e0df;
  border-radius: var(--radius);
  background: #ffffff;
  padding: 16px;
  display: grid;
  gap: 10px;
  min-height: 100%;
}

.choice-card.selected {
  border-color: var(--teal);
  background: #f2fbf8;
  box-shadow: 0 12px 28px rgba(18, 124, 123, 0.16);
}

.choice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.choice-title {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.35;
}

.choice-badge {
  flex: 0 0 auto;
  min-width: 48px;
  border-radius: 999px;
  background: var(--sun);
  color: #3e2b00;
  padding: 4px 10px;
  text-align: center;
  font-weight: 900;
}

.choice-card ul {
  margin: 0;
  padding-left: 1.15em;
}

.choice-card li + li {
  margin-top: 4px;
}

.choice-select {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  font-weight: 900;
}

.choice-select input {
  inline-size: 20px;
  block-size: 20px;
  accent-color: var(--teal);
}

.calc-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.calc-table th,
.calc-table td,
.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.calc-table th,
.data-table th {
  color: #2f4c5e;
  background: #f3f7f6;
  font-size: 0.92rem;
}

.data-table {
  min-width: 1240px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.hint-box {
  border-left: 5px solid var(--sun);
  background: #fff8e6;
  border-radius: var(--radius);
  padding: 14px 16px;
}

.hint-box h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.hint-box ul {
  margin: 0;
  padding-left: 1.15em;
}

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

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px 12px;
  font-weight: 800;
}

.checkbox-card input {
  inline-size: 20px;
  block-size: 20px;
  accent-color: var(--teal);
}

.student-controls,
.toolbar,
.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.student-controls {
  justify-content: space-between;
  margin-top: 18px;
}

.student-controls .right-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.plan-document {
  background: #ffffff;
  border: 1px solid #d8dde1;
  border-radius: var(--radius);
  padding: clamp(18px, 3vw, 30px);
}

.plan-document h2 {
  margin: 0 0 16px;
}

.plan-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.plan-section {
  border-top: 1px solid #e5e8ea;
  padding-top: 14px;
  margin-top: 14px;
}

.plan-section h3 {
  margin: 0 0 6px;
  color: #2d4e5d;
  font-size: 1.04rem;
}

.submitted-message {
  border: 1px solid #b7dfc5;
  border-radius: var(--radius);
  background: #eef9f0;
  color: #225d35;
  padding: 14px 16px;
  font-weight: 800;
}

.dashboard-grid {
  display: grid;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 14px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.6rem;
  line-height: 1.2;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(4, minmax(120px, 0.7fr));
  gap: 10px;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(160px, 1fr) 82px;
  gap: 10px;
  align-items: center;
}

.bar-label {
  font-weight: 800;
}

.bar-track {
  min-height: 20px;
  border-radius: 999px;
  background: #e8eeee;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.bar-fill.alt {
  background: linear-gradient(90deg, var(--sun), var(--coral));
}

.bar-value {
  color: var(--muted);
  font-weight: 900;
  text-align: right;
}

.summary-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.summary-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 16px;
}

.summary-block h3 {
  margin: 0 0 12px;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-button {
  border: 1px solid #cbdbee;
  border-radius: var(--radius);
  background: #f3f7fc;
  color: var(--blue);
  padding: 8px 10px;
  font-weight: 800;
}

.tab-button.active {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.response-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.response-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.response-card h4 {
  margin: 0;
  font-size: 1rem;
}

.response-card p {
  margin: 0;
}

.small-meta {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.raw-box {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #ccd8d6;
  border-radius: var(--radius);
  background: #17212a;
  color: #eef7f4;
  padding: 14px;
  font-size: 0.86rem;
  white-space: pre-wrap;
}

.share-layout {
  display: grid;
  gap: 18px;
}

.share-reasons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.share-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 14px;
}

.empty-state {
  border: 1px dashed #aebfbd;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(420px, calc(100% - 40px));
  border-radius: var(--radius);
  background: #26313a;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(20, 31, 38, 0.45);
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(480px, 100%);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 24px;
}

.modal-card h2 {
  margin: 0 0 10px;
}

.modal-card p {
  margin: 0 0 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.noscript {
  margin: 24px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
}

@media (max-width: 900px) {
  .header-inner,
  .screen-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .header-inner {
    display: grid;
  }

  .mode-switcher {
    justify-content: flex-start;
  }

  .intro-grid,
  .choice-grid,
  .context-grid,
  .glossary-grid,
  .summary-sections,
  .response-grid,
  .share-reasons {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 640px) {
  .header-inner,
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .mode-switcher {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mode-button,
  .primary-button,
  .secondary-button,
  .quiet-button,
  .danger-button {
    width: 100%;
  }

  .form-grid,
  .checkbox-grid,
  .stats-grid,
  .filter-grid,
  .plan-meta {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .meter-row {
    grid-template-columns: 1fr;
  }

  .bar-value {
    text-align: left;
  }

  .meter-row b {
    text-align: left;
  }

  .student-controls,
  .student-controls .right-actions,
  .toolbar,
  .dashboard-actions,
  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  body * {
    visibility: hidden;
  }

  #printArea,
  #printArea * {
    visibility: visible;
  }

  #printArea {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
