:root {
  color-scheme: light;
  --ink: #24172a;
  --muted: #756b7a;
  --surface: #fffaff;
  --page: #f4edf5;
  --line: #ded3df;
  --pink: #ec7ba9;
  --pink-dark: #a83768;
  --green: #468e4d;
  --green-dark: #2f6735;
  --gold: #f4c84d;
  --gray: #a7a3aa;
  --shadow: 0 16px 40px rgba(43, 20, 50, 0.11);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--page);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(236, 123, 169, 0.18), transparent 36rem),
    var(--page);
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(35, 23, 42, 0.3);
  outline-offset: 3px;
}

.topbar,
main {
  width: min(100% - 2rem, 980px);
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(1.15rem + env(safe-area-inset-top)) 0 1rem;
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 0.55rem;
}

.language-switch {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 255, 0.76);
}

.language-switch button {
  min-height: 32px;
  padding: 0.3rem 0.65rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.language-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: white;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

h1 span {
  display: block;
}

html[lang="en"] h1 span:last-child {
  font-size: 0.88em;
  white-space: nowrap;
}

.brand-byline {
  margin: 0.3rem 0 0;
  color: var(--pink-dark);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--pink-dark);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

main {
  display: grid;
  gap: 1rem;
}

.work-card,
.chart-card,
.upload-card {
  overflow: hidden;
  border: 1px solid rgba(112, 89, 119, 0.19);
  border-radius: 24px;
  background: rgba(255, 250, 255, 0.92);
  box-shadow: var(--shadow);
}

.work-card {
  padding: clamp(1.1rem, 5vw, 2rem);
}

.upload-card {
  padding: 1rem 1.1rem;
}

.upload-card .section-heading {
  padding: 0 0 0.7rem;
}

.upload-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.chart-switch-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.upload-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 14px;
  background: var(--pink-dark);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

.upload-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-picker:focus-within {
  outline: 3px solid rgba(35, 23, 42, 0.3);
  outline-offset: 3px;
}

#importStatus {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.import-review {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.import-review[hidden] { display: none; }

.grid-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.grid-fields label {
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.grid-fields input {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 0.25rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#importPreview {
  display: block;
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  image-rendering: pixelated;
  background: #302934;
}

#importPreview[hidden] { display: none; }

.import-review .legend { padding: 0; }
.import-review .small-primary { width: 100%; }
.import-review .small-primary:disabled { opacity: 0.45; }

.mode-switch {
  display: flex;
  gap: 0.55rem;
  margin: 0 0 1.35rem;
  padding: 0;
  border: 0;
}

.mode-switch legend {
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.mode-switch label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  font-weight: 800;
  cursor: pointer;
}

.mode-switch label:has(input:checked) {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.mode-switch input {
  accent-color: var(--pink);
}

.resume-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin: 0 0 1.35rem;
}

.resume-panel[hidden] {
  display: none;
}

.position-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.colour-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: #f2edf3;
  color: var(--ink);
}

.colour-swatch {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 3px;
  background: var(--pink);
}

.work-card h2 {
  white-space: pre-line;
  min-height: 1.25em;
  margin-bottom: 0.4rem;
  font-size: clamp(2rem, 9vw, 4rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.helper-text {
  min-height: 1.5em;
  margin-bottom: 1.2rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.voice-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  min-height: 76px;
  padding: 1rem 1.25rem;
  border: 0;
  border-radius: 20px;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(35, 23, 42, 0.2);
  color: white;
  font-size: 1.2rem;
  font-weight: 800;
}

.voice-button:active {
  transform: translateY(1px);
}

.voice-button[hidden],
.transcript[hidden],
.command-button[hidden] {
  display: none;
}

.voice-button[data-listening="true"] {
  background: var(--green-dark);
}

.mic-icon {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.mic-icon svg {
  width: 1.25rem;
  fill: currentColor;
}

.transcript {
  min-height: 1.4em;
  margin: 0.8rem 0 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-top: 1rem;
}

.command-button,
.secondary-button,
.small-primary,
.text-button,
.danger-button {
  min-height: 48px;
  border-radius: 14px;
  font-weight: 800;
}

.command-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-height: 72px;
  padding: 0.65rem 0.35rem;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font-size: 0.9rem;
}

.command-button.done {
  border-color: rgba(70, 142, 77, 0.35);
  background: rgba(70, 142, 77, 0.1);
  color: var(--green-dark);
}

.command-button:disabled,
.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.command-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.manual-panel {
  border-top: 1px solid var(--line);
}

.manual-panel summary {
  padding: 1rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.manual-panel form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.manual-panel label span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.manual-panel input {
  width: 100%;
  min-height: 50px;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font-size: 1.1rem;
}

.small-primary {
  grid-column: 1 / -1;
  border: 0;
  background: var(--pink-dark);
  color: white;
}

.secondary-button {
  flex: 0 0 auto;
  padding: 0.65rem 0.85rem;
  border: 0;
  background: var(--green-dark);
  color: white;
}

.chart-card {
  padding: 1.1rem 0 1rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.1rem 0.8rem;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.text-button,
.danger-button {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
}

.chart-scroller {
  overflow: auto;
  max-height: min(62vh, 790px);
  border-block: 1px solid var(--line);
  background: #302934;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 1.1rem 0.75rem;
}

.chart-toolbar button {
  min-width: 42px;
  min-height: 42px;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.chart-toolbar button:disabled {
  opacity: 0.42;
}

.chart-toolbar output {
  min-width: 4.8rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
}

#fitChartButton {
  margin-left: auto;
  color: var(--pink-dark);
}

#chartCanvas {
  display: block;
  transform-origin: top left;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 0.9rem 1.1rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.legend-swatch {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 3px;
  background: var(--pink);
}

.legend-swatch.green {
  background: var(--green);
}

.legend-swatch.completed {
  background: var(--gray);
}

.legend-swatch.active {
  background: transparent;
  border: 3px solid var(--gold);
}

.direction-note {
  margin: 0.7rem 1.1rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.settings-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0 0.25rem;
}

.social-section {
  grid-column: 1 / -1;
  margin-top: 0.75rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 250, 255, 0.72);
  text-align: center;
}

.social-section h2 {
  margin-bottom: 1rem;
  font-size: 1.15rem;
}

.privacy-section {
  max-width: 960px;
  margin: 1rem auto;
  color: var(--muted);
  font-size: 0.9rem;
}

.privacy-section details {
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.privacy-section summary {
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.privacy-section p {
  margin: 0.7rem 0;
  line-height: 1.6;
}

.social-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  justify-content: center;
  gap: 1rem;
}

.social-card {
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 0.65rem;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  text-decoration: none;
}

.social-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  object-position: center top;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

a.social-card:hover span {
  color: var(--pink-dark);
}

a.social-card:focus-visible {
  outline: 3px solid rgba(35, 23, 42, 0.3);
  outline-offset: 4px;
}

.danger-button {
  color: #9b2436;
  border-color: rgba(155, 36, 54, 0.28);
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 2rem);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  background: var(--ink);
  box-shadow: var(--shadow);
  color: white;
  font-weight: 700;
  transform: translateX(-50%);
}

.toast[hidden] {
  display: none;
}

@media (min-width: 760px) {
  main {
    grid-template-columns: minmax(330px, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
  }

  .work-card {
    position: sticky;
    top: 1rem;
  }

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

  .settings-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .topbar,
  main {
    width: min(100% - 1rem, 980px);
  }

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

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

  .secondary-button {
    width: 100%;
  }

  .settings-row {
    flex-direction: column;
  }

  .social-grid {
    gap: 0.65rem;
  }

  .social-section {
    padding: 1rem 0.7rem;
  }
}

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