:root {
  color-scheme: dark;
  --bg: #050706;
  --surface: #0c0f0d;
  --surface-raised: #121612;
  --line: #263026;
  --line-strong: #3a493a;
  --text: #f4f7f2;
  --muted: #98a49b;
  --green: #80d400;
  --green-deep: #4f8700;
  --gold: #ffd84d;
  --danger: #ff7b7b;
  --radius: 8px;
  --max-width: 1480px;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

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

button,
a,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  border: 0;
}

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

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid #1c231d;
  background: rgba(5, 7, 6, 0.96);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
}

.brand-main {
  font-size: 22px;
  font-weight: 900;
}

.brand-main span {
  color: var(--green);
}

.brand-sub,
.eyebrow,
.step-label,
.practice-label {
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 800;
}

.brand-sub,
.step-label {
  color: #748178;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.cost-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.cost-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(128, 212, 0, 0.7);
}

.header-link {
  padding: 10px 16px;
  border: 1px solid var(--green-deep);
  border-radius: var(--radius);
  color: var(--green);
  font-weight: 800;
  font-size: 14px;
}

.app-shell {
  width: min(var(--max-width), calc(100% - 48px));
  margin: 0 auto;
  padding: 64px 0 48px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  align-items: end;
  gap: 48px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--green);
}

.intro h1 {
  max-width: 880px;
  margin: 0;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 1.05;
  letter-spacing: 0;
}

.intro h1 span {
  color: var(--green);
}

.intro h1 .headline-accent {
  display: inline-block;
  white-space: nowrap;
}

.intro > p {
  margin: 0 0 4px;
  color: #b0bbb2;
  font-size: 17px;
  line-height: 1.8;
}

.learning-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) minmax(260px, 0.9fr);
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: #080b09;
}

.overview-metric {
  display: flex;
  min-height: 82px;
  align-items: baseline;
  gap: 8px;
  padding: 17px 20px;
  border-right: 1px solid var(--line);
}

.overview-metric span {
  align-self: flex-start;
  color: #7f8b82;
  font-size: 12px;
  font-weight: 800;
}

.overview-metric strong {
  align-self: center;
  color: var(--green);
  font-size: 23px;
  line-height: 1.2;
}

.overview-metric:last-of-type strong {
  font-size: 16px;
}

.overview-metric small {
  align-self: center;
  color: #68736a;
}

.learning-overview > p {
  align-self: center;
  margin: 0;
  padding: 17px 20px;
  color: #68736a;
  font-size: 12px;
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  min-height: 680px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--green);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.editor-panel,
.result-panel {
  min-width: 0;
  padding: clamp(24px, 3vw, 42px);
}

.result-panel {
  border-left: 1px solid var(--line);
  background: #090c0a;
}

.panel-heading,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  margin-bottom: 24px;
}

.panel-heading h2,
.result-section h3,
.practice-box h3,
.next-step h3 {
  margin: 5px 0 0;
}

.step-label {
  margin: 0;
}

.text-button,
.copy-button {
  padding: 8px 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.mode-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
  border: 0;
}

.mode-option {
  position: relative;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option span {
  display: flex;
  min-height: 80px;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080b09;
  color: #c8d0c9;
}

.mode-option small {
  color: #77827a;
  font-size: 12px;
}

.mode-option input:checked + span {
  border-color: var(--green);
  background: rgba(128, 212, 0, 0.08);
  color: var(--green);
}

.mode-option input:focus-visible + span,
button:focus-visible,
a:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(255, 216, 77, 0.65);
  outline-offset: 2px;
}

.quick-practice {
  display: grid;
  gap: 12px;
  margin: 0 0 22px;
  padding: 17px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.quick-practice h3 {
  margin: 4px 0 0;
  font-size: 16px;
}

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

.scenario-list button {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #050706;
  color: #aeb8b0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.scenario-list button:hover,
.scenario-list button.is-active {
  border-color: var(--green);
  background: rgba(128, 212, 0, 0.08);
  color: var(--green);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 9px;
}

.field > span {
  color: #89958d;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #050706;
  color: var(--text);
}

.field select {
  min-height: 48px;
  padding: 0 14px;
}

.essay-field {
  margin-top: 20px;
}

.field textarea {
  min-height: 270px;
  resize: vertical;
  padding: 18px;
  line-height: 1.7;
}

.field textarea::placeholder {
  color: #59635b;
}

.editor-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 9px 0 20px;
  color: #6f7b72;
  font-size: 12px;
}

.editor-meta p {
  margin: 0;
}

.editor-meta strong {
  color: var(--green);
}

.honeypot {
  position: absolute;
  left: -9999px;
}

.primary-button,
.primary-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 0 20px;
  border-radius: var(--radius);
  background: var(--green);
  color: #081000;
  cursor: pointer;
  font-weight: 900;
}

.primary-button {
  width: 100%;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.privacy-note {
  margin: 13px 0 0;
  color: #657067;
  font-size: 12px;
  line-height: 1.6;
}

.result-badge {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #7f8b82;
  font-size: 12px;
  font-weight: 800;
}

.result-badge.is-demo {
  border-color: #715f12;
  color: var(--gold);
}

.result-badge.is-live {
  border-color: var(--green-deep);
  color: var(--green);
}

.empty-state,
.loading-state,
.error-state {
  min-height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

[hidden] {
  display: none !important;
}

.empty-mark {
  display: grid;
  width: 78px;
  height: 78px;
  margin-bottom: 20px;
  place-items: center;
  border: 1px solid var(--green-deep);
  color: var(--green);
  font-size: 26px;
  font-weight: 900;
}

.empty-state h3,
.loading-state h3,
.error-state h3 {
  margin: 0 0 10px;
  font-size: 22px;
}

.empty-state p,
.loading-state p,
.error-state p {
  max-width: 480px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.empty-state ul {
  display: flex;
  gap: 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.empty-state li {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #849087;
  font-size: 12px;
}

.loader {
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  border: 3px solid #263026;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.score-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.score-block {
  display: grid;
  gap: 6px;
}

.score-block > span {
  color: #7f8b82;
  font-size: 12px;
  font-weight: 800;
}

.score-block strong {
  color: var(--green);
  font-size: 38px;
  line-height: 1;
}

.score-block small {
  margin-left: 4px;
  color: #788279;
  font-size: 14px;
}

.score-row > p {
  margin: 0;
  color: #b4bdb6;
  line-height: 1.7;
}

.result-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.result-tabs button {
  min-height: 46px;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #77827a;
  cursor: pointer;
  font-weight: 800;
}

.result-tabs button[aria-selected="true"] {
  border-color: var(--green);
  color: var(--green);
}

.result-section,
.practice-box {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.corrected-text {
  margin: 18px 0 0;
  white-space: pre-wrap;
  color: #e8ede9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.85;
}

.result-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
}

.source-comparison {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.source-comparison summary {
  color: #8e9a90;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.source-comparison p {
  margin: 12px 0 0;
  white-space: pre-wrap;
  color: #8f9a91;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.75;
}

.strengths-section {
  margin-top: 12px;
}

.strengths-section ul,
.learning-list {
  margin: 14px 0 0;
  padding-left: 22px;
  color: #b0bbb2;
  line-height: 1.7;
}

.issue-list {
  display: grid;
  gap: 10px;
}

.issue-item {
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: var(--surface);
}

.issue-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.issue-change {
  color: #dfe5e0;
  font-weight: 800;
}

.issue-change del {
  margin-right: 8px;
  color: #cf8888;
}

.issue-change ins {
  color: var(--green);
  text-decoration: none;
}

.issue-category {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.issue-item p {
  margin: 0;
  color: #9ca79e;
  line-height: 1.65;
}

.practice-box {
  margin-top: 12px;
  border-color: #5f5114;
}

.practice-label {
  margin: 0;
  color: var(--gold);
}

.practice-box h3 {
  margin-top: 12px;
  line-height: 1.5;
}

.practice-box > p:not(.practice-label):not(.answer) {
  color: var(--muted);
}

.secondary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.answer {
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--green);
  line-height: 1.65;
}

.next-step {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  margin-top: 18px;
  padding: 22px;
  border-left: 4px solid var(--green);
  background: #111611;
}

.next-step h3 {
  font-size: 18px;
}

.next-step p:not(.eyebrow) {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.next-actions {
  display: flex;
  gap: 8px;
}

.primary-link {
  min-height: 42px;
  padding: 0 16px;
  white-space: nowrap;
}

.error-state h3 {
  color: var(--danger);
}

.trust-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
  border: 1px solid var(--line);
}

.trust-strip div {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 24px;
}

.trust-strip div + div {
  border-left: 1px solid var(--line);
}

.trust-strip strong {
  color: var(--green);
  font-size: 24px;
}

.trust-strip span {
  color: #859087;
  font-size: 13px;
}

footer {
  display: flex;
  justify-content: space-between;
  width: min(var(--max-width), calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 40px;
  border-top: 1px solid #171c18;
  color: #59635b;
  font-size: 12px;
}

footer p {
  margin: 0;
}

.line-chatbot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(310px, calc(100vw - 32px));
  padding: 11px 16px 11px 11px;
  border: 1px solid rgba(128, 212, 0, 0.5);
  border-radius: 18px;
  background: rgba(8, 11, 9, 0.95);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.58), 0 0 26px rgba(128, 212, 0, 0.16);
  backdrop-filter: blur(18px);
  color: var(--text);
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.line-chatbot:hover {
  transform: translateY(-3px);
  border-color: var(--green);
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.64), 0 0 34px rgba(128, 212, 0, 0.24);
}

.line-chatbot-mark {
  display: grid;
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  background: var(--green);
  color: #050705;
  font-size: 10px;
  font-weight: 900;
}

.line-chatbot-copy {
  min-width: 0;
}

.line-chatbot-copy strong,
.line-chatbot-copy small {
  display: block;
}

.line-chatbot-copy strong {
  color: var(--green);
  font-size: 13px;
}

.line-chatbot-copy small {
  margin-top: 1px;
  color: #d2d8d3;
  font-size: 12px;
}

@media (max-width: 1050px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .intro > p {
    max-width: 760px;
  }

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

  .learning-overview {
    grid-template-columns: repeat(3, 1fr);
  }

  .learning-overview > p {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

  .result-panel {
    min-height: 620px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .site-header {
    min-height: 62px;
    padding: 10px 16px;
  }

  .brand-sub,
  .cost-status {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }

  .header-link {
    padding: 8px 10px;
  }

  .app-shell,
  footer {
    width: min(100% - 24px, var(--max-width));
  }

  .app-shell {
    padding-top: 36px;
  }

  .intro h1 {
    font-size: 38px;
  }

  .intro > p {
    font-size: 15px;
  }

  .editor-panel,
  .result-panel {
    padding: 22px 16px;
  }

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

  .mode-option span {
    min-height: 62px;
  }

  .field-grid,
  .score-row,
  .next-step {
    grid-template-columns: 1fr;
  }

  .overview-metric {
    min-height: 74px;
    padding: 14px 10px;
  }

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

  .overview-metric:nth-child(2) {
    border-right: 0;
  }

  .overview-metric:nth-child(3) {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .overview-metric strong {
    font-size: 19px;
  }

  .overview-metric:last-of-type {
    border-right: 0;
  }

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

  .field textarea {
    min-height: 230px;
  }

  .empty-state ul {
    flex-wrap: wrap;
    justify-content: center;
  }

  .score-row {
    gap: 14px;
  }

  .next-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .trust-strip {
    grid-template-columns: 1fr;
  }

  .trust-strip div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  footer {
    display: grid;
    gap: 10px;
  }

  .line-chatbot {
    right: 12px;
    bottom: 12px;
    width: 56px;
    height: 56px;
    padding: 7px;
    border-radius: 16px;
  }

  .line-chatbot-mark {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .line-chatbot-copy {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
