:root {
  --bg-top: #f1e7d8;
  --bg-bottom: #faf8f2;
  --panel: rgba(255, 252, 246, 0.86);
  --panel-border: rgba(64, 42, 21, 0.12);
  --ink: #24170d;
  --muted: #6f5a48;
  --accent: #b14d2f;
  --accent-deep: #7d3119;
  --shadow: 0 22px 48px rgba(76, 45, 19, 0.12);
  --input-bg: rgba(255, 255, 255, 0.72);
  --timeline-bg: rgba(255, 252, 246, 0.5);
  --timeline-dot-bg: #faf8f2;
  --usage-item-bg: rgba(255, 249, 242, 0.92);
  --result-bg: rgba(255, 255, 255, 0.74);
}

[data-theme="dark"] {
  --bg-top: #1a1410;
  --bg-bottom: #0f0d0b;
  --panel: rgba(32, 26, 20, 0.92);
  --panel-border: rgba(180, 150, 120, 0.15);
  --ink: #e8ddd0;
  --muted: #a0917f;
  --accent: #d4714e;
  --accent-deep: #e8855e;
  --shadow: 0 22px 48px rgba(0, 0, 0, 0.35);
  --input-bg: rgba(40, 33, 26, 0.8);
  --timeline-bg: rgba(40, 33, 26, 0.5);
  --timeline-dot-bg: #1a1410;
  --usage-item-bg: rgba(40, 33, 26, 0.8);
  --result-bg: rgba(40, 33, 26, 0.74);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(196, 127, 76, 0.18), transparent 28%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
}

textarea,
input,
button {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h1,
.result-head h2,
.usage-card h2 {
  font-family: "Space Grotesk", sans-serif;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.94;
}

.lede {
  max-width: 760px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.steps {
  margin: 10px 0 0;
  color: var(--accent-deep);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.hero .disclaimer {
  margin-top: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.panel + .panel {
  margin-top: 18px;
}

.auth-panel {
  padding: 24px 28px;
}

.auth-panel h2 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem;
}

.auth-panel p {
  margin: 0 0 14px;
  color: var(--muted);
}

.member-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 0 4px;
  margin-top: 12px;
}

.member-info-left {
  flex: 1 1 auto;
}

.member-divider {
  border: none;
  border-top: 1px solid var(--panel-border);
  margin: 16px 0 4px;
}

.user-email {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
  color: var(--ink);
}

.user-tier,
.user-subscription {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.user-tier span {
  font-weight: 600;
  color: var(--accent-deep);
}

#sign-out-button {
  background: transparent;
  color: var(--accent-deep);
  border: 1px solid rgba(177, 77, 47, 0.35);
  box-shadow: none;
  padding: 10px 18px;
}

#sign-out-button:hover {
  background: rgba(177, 77, 47, 0.08);
}

.upgrade-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.upgrade-row button {
  flex: 1 1 220px;
}

#profile-panel {
  padding: 24px 28px 20px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.profile-header h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem;
}

.profile-summary {
  color: var(--muted);
  font-size: 0.92rem;
  flex: 1;
}

.profile-toggle-icon {
  color: var(--muted);
  font-size: 0.8rem;
  transition: transform 200ms ease;
}

#profile-panel.collapsed .profile-toggle-icon {
  transform: rotate(-90deg);
}

#profile-panel.collapsed #profile-body {
  display: none;
}

#profile-panel:not(.collapsed) .profile-summary {
  display: none;
}

.profile-hint {
  margin: 12px 0 16px;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.6;
}

#profile-form {
  padding: 0;
}

.form {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.field-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
}

.field-group legend {
  padding: 0 8px;
  color: var(--muted);
}

.plan-timeline {
  margin: -6px 2px 4px;
  padding: 18px 12px 14px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--timeline-bg);
}

.timeline-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 10px 12px 8px;
}

.timeline-track::before {
  content: "";
  position: absolute;
  top: 19px;
  left: calc(100% / 6 + 12px);
  right: calc(100% / 6 + 12px);
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(125, 49, 25, 0.18),
    rgba(125, 49, 25, 0.32),
    rgba(125, 49, 25, 0.18)
  );
  border-radius: 2px;
}

.timeline-point {
  position: relative;
  text-align: center;
  z-index: 1;
}

.timeline-point .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--timeline-dot-bg);
  border: 2px solid rgba(125, 49, 25, 0.32);
  margin: 0 auto 10px;
  transition:
    background-color 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.timeline-point .label {
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.35s ease;
}

.timeline-point .sublabel {
  font-size: 12px;
  color: rgba(111, 90, 72, 0.6);
  margin-top: 2px;
  transition: color 0.35s ease;
}

.timeline-point.reference .dot {
  background: #f6c069;
  border-color: #c98a21;
  box-shadow: 0 0 10px rgba(201, 138, 33, 0.45);
}

.timeline-point.reference .label {
  color: #8a5d19;
}

.timeline-point.current .dot {
  background: var(--accent);
  border-color: var(--accent-deep);
  box-shadow:
    0 0 0 6px rgba(177, 77, 47, 0.18),
    0 0 22px rgba(177, 77, 47, 0.6);
  animation: dot-pulse 1.8s ease-in-out infinite;
}

.timeline-point.current .label {
  color: var(--accent-deep);
}

@keyframes dot-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 6px rgba(177, 77, 47, 0.18),
      0 0 22px rgba(177, 77, 47, 0.6);
  }
  50% {
    box-shadow:
      0 0 0 10px rgba(177, 77, 47, 0.08),
      0 0 32px rgba(177, 77, 47, 0.9);
  }
}

.timeline-hint {
  margin: 6px 0 0;
  text-align: center;
  font-size: 12px;
  color: rgba(111, 90, 72, 0.75);
}

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

.field[hidden] {
  display: none;
}

.field span {
  font-weight: 600;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid rgba(90, 65, 40, 0.16);
  border-radius: 18px;
  background: var(--input-bg);
  padding: 14px 16px;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: rgba(177, 77, 47, 0.48);
  box-shadow: 0 0 0 4px rgba(177, 77, 47, 0.12);
  transform: translateY(-1px);
}

.consent-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.consent-gate[hidden] {
  display: none;
}

.consent-gate-inner {
  width: min(680px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 36px 32px;
}

.consent-gate-inner h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin: 0 0 8px;
  line-height: 1;
}

.consent-gate-inner h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  margin: 20px 0 16px;
  color: var(--accent-deep);
}

.consent-terms {
  max-height: 50vh;
  overflow-y: auto;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  margin-bottom: 20px;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--ink);
}

.consent-terms h3 {
  font-size: 1rem;
  margin: 18px 0 8px;
  color: var(--accent-deep);
}

.consent-terms h3:first-child {
  margin-top: 0;
}

.consent-terms ul {
  padding-left: 20px;
  margin: 8px 0;
}

.consent-terms li {
  margin-bottom: 6px;
}

.consent-gate-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  cursor: pointer;
  color: var(--ink);
}

.consent-gate-check input[type="checkbox"] {
  margin-top: 4px;
  flex-shrink: 0;
}

#consent-gate-button {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
}

.disclaimer {
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(177, 77, 47, 0.08);
  border: 1px solid rgba(177, 77, 47, 0.2);
  color: var(--accent-deep);
  font-size: 0.92rem;
  line-height: 1.6;
}

[data-theme="dark"] .disclaimer {
  background: rgba(212, 113, 78, 0.1);
  border-color: rgba(212, 113, 78, 0.25);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff7f2;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
  box-shadow: 0 14px 26px rgba(125, 49, 25, 0.24);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.status {
  margin: 0;
  color: var(--muted);
  min-height: 1.5em;
}

.results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 24px;
  padding: 28px;
}

.result-card,
.usage-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 22px;
  background: var(--result-bg);
  border: 1px solid rgba(90, 65, 40, 0.12);
}

.usage-card {
  grid-column: 1 / -1;
}

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

.result-head h2,
.usage-card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.result-card textarea {
  min-height: 360px;
  resize: vertical;
}

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

.usage-list div {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--usage-item-bg);
}

.usage-list dt {
  color: var(--muted);
  font-size: 0.88rem;
}

.usage-list dd {
  margin: 8px 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.08rem;
}

.site-footer {
  margin-top: 40px;
  padding: 24px 28px;
  border-top: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.site-footer p {
  margin: 0;
}

.site-footer p + p {
  margin-top: 6px;
}

.site-footer .privacy {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  font-size: 0.82rem;
  line-height: 1.7;
}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 200ms ease, background 200ms ease;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

[data-theme="dark"] .theme-toggle {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

@media (max-width: 840px) {
  .shell {
    width: min(100vw - 20px, 1120px);
    padding-top: 24px;
    padding-bottom: 36px;
  }

  .form,
  .results {
    padding: 18px;
  }

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

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

@media (max-width: 560px) {
  .usage-list {
    grid-template-columns: 1fr;
  }

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