:root,
body[data-theme="kinari"] {
  --surface-page: #f6f1e7;
  --surface-card: rgba(255, 252, 244, 0.9);
  --surface-elevated: #fffaf0;
  --surface-overlay: rgba(255, 251, 240, 0.7);

  --text-primary: #1f1d19;
  --text-secondary: #3e3323;
  --text-muted: #6f685d;
  --text-on-accent: #fffaf0;

  --accent-primary: #b98a2d;
  --accent-sacred: #a62020;

  --border-subtle: rgba(185, 138, 45, 0.34);
  --border-strong: #b98a2d;
  --focus-ring: rgba(166, 32, 32, 0.25);
  --shadow-soft: 0 18px 46px rgba(74, 56, 23, 0.09);

  --ornament-primary: #b98a2d;
  --ornament-muted: rgba(185, 138, 45, 0.24);

  --compass-face: #f6f1e7;
  --compass-line: #b98a2d;
  --compass-target: #a62020;
  --compass-current-heading: #b98a2d;

  --map-land: #e8edcf;
  --map-border: #b98a2d;
  --map-current-location: #789b3a;
  --map-target: #a62020;
  --map-connection: #b98a2d;

  /* Compatibility aliases while existing components migrate to Semantic Tokens. */
  --color-kinari: var(--surface-page);
  --color-paper: var(--surface-elevated);
  --color-card: var(--surface-card);
  --color-sumi: var(--text-primary);
  --color-muted: var(--text-muted);
  --color-shu: var(--accent-sacred);
  --color-kin: var(--accent-primary);
}

body[data-theme="sumi-kin"] {
  --surface-page: #11100d;
  --surface-card: rgba(25, 23, 18, 0.94);
  --surface-elevated: #1d1a15;
  --surface-overlay: rgba(31, 28, 22, 0.9);

  --text-primary: #f2ead7;
  --text-secondary: #d8caa8;
  --text-muted: #b7aa88;
  --text-on-accent: #15130f;

  --accent-primary: #c8a45e;
  /* Reserved for non-text ceremonial accents such as seals/markers. */
  --accent-sacred: #b13b32;

  --border-subtle: rgba(200, 164, 94, 0.34);
  --border-strong: #c8a45e;
  --focus-ring: rgba(232, 197, 122, 0.55);
  --shadow-soft: 0 18px 46px rgba(0, 0, 0, 0.34);

  --ornament-primary: #c8a45e;
  --ornament-muted: rgba(200, 164, 94, 0.2);

  --compass-face: #15130f;
  --compass-line: #c8a45e;
  --compass-target: #b13b32;
  --compass-current-heading: #e0c178;

  --map-land: #28261f;
  --map-border: #9f8248;
  --map-current-location: #91a65a;
  --map-target: #c34a40;
  --map-connection: #c8a45e;

  --color-kinari: var(--surface-page);
  --color-kinari-deep: #171510;
  --color-paper: var(--surface-elevated);
  --color-card: var(--surface-card);
  --color-sumi: var(--text-primary);
  --color-muted: var(--text-muted);
  /* Existing app.css uses --color-shu for text as well as accents.
     In sumi-kin, map that compatibility token to gold so no text becomes red. */
  --color-shu: var(--accent-primary);
  --color-shu-dark: #9f8248;
  --color-kin: var(--accent-primary);
  --color-kin-dark: #9f8248;
  --color-kin-light: #e0c178;
  --color-wakakusa: #91a65a;
  --color-wakakusa-dark: #c8a45e;
}

button:focus-visible {
  outline-color: var(--focus-ring);
}

.theme-switch-card {
  margin: 1.4rem auto 0;
  padding: 0.9rem;
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  background: var(--surface-overlay);
  box-shadow: var(--shadow-soft);
}

.theme-switch-label {
  margin-bottom: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-mincho);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
}

.theme-switch-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.theme-switch-button {
  min-height: 2.7rem;
  border: 1px solid var(--border-subtle);
  border-radius: 0.8rem;
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
}

.theme-switch-button[aria-pressed="true"] {
  border-color: var(--border-strong);
  background: var(--surface-elevated);
  box-shadow: inset 0 0 0 1px var(--ornament-muted);
}

.theme-switch-button[aria-pressed="true"]::before {
  content: '●';
  margin-right: 0.4rem;
  color: var(--accent-sacred);
  font-size: 0.72rem;
}

.theme-guidance-toggle {
  position: absolute;
  right: 0;
  min-height: 2.25rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-overlay);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

body[data-theme="sumi-kin"] {
  color: var(--text-primary);
  background:
    radial-gradient(circle at 50% -16%, rgba(200, 164, 94, 0.12), transparent 27rem),
    linear-gradient(180deg, #17140f 0%, var(--surface-page) 58%, #0b0a08 100%);
}

body[data-theme="sumi-kin"]::before {
  background:
    radial-gradient(circle at 38% 34%, rgba(224, 193, 120, 0.55), transparent 52%),
    linear-gradient(145deg, #7d632f, #2a2112);
  opacity: 0.16;
}

body[data-theme="sumi-kin"]::after {
  opacity: 0.26;
  filter: sepia(1) saturate(0.65) brightness(1.35);
}

body[data-theme="sumi-kin"] .brand-mark,
body[data-theme="sumi-kin"] .guidance-target-label {
  color: var(--text-primary);
}

/* The reference design does not use red as a text color.
   Gold is used for small labels; primary information stays warm off-white. */
body[data-theme="sumi-kin"] .eyebrow,
body[data-theme="sumi-kin"] .section-kicker,
body[data-theme="sumi-kin"] .guidance-state {
  color: var(--accent-primary);
}

body[data-theme="sumi-kin"] .hero-emphasis,
body[data-theme="sumi-kin"] .heading-shu,
body[data-theme="sumi-kin"] .turn-instruction {
  color: var(--text-primary);
}

body[data-theme="sumi-kin"] .target-card {
  border-color: var(--border-strong);
  background: linear-gradient(145deg, rgba(31, 28, 22, 0.98), rgba(18, 16, 13, 0.94));
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(224, 193, 120, 0.08);
}

/* In sumi-kin, the reference visual uses gold as the primary action color.
   Pair it with dark text for both contrast and theme consistency. */
body[data-theme="sumi-kin"] .primary-button {
  border-color: #e0c178;
  background: linear-gradient(145deg, #e6cd8a 0%, #c8a45e 58%, #a98240 100%);
  color: var(--text-on-accent);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 243, 205, 0.28);
}

body[data-theme="sumi-kin"] .primary-button:hover {
  background: linear-gradient(145deg, #dcc17a 0%, #bc974f 60%, #977438 100%);
}

body[data-theme="sumi-kin"] .primary-button:active {
  background: linear-gradient(145deg, #cdb06c 0%, #ad8846 60%, #866530 100%);
}

body[data-theme="sumi-kin"] .primary-button .button-arrow {
  color: var(--text-on-accent);
}

body[data-theme="sumi-kin"] .theme-switch-button[aria-pressed="true"]::before {
  color: var(--accent-primary);
}

body[data-theme="sumi-kin"] .secondary-button {
  border-color: var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px rgba(224, 193, 120, 0.08);
}

body[data-theme="sumi-kin"] .privacy-card {
  border-color: var(--border-subtle);
  background: var(--surface-overlay);
}

body[data-theme="sumi-kin"] .privacy-card p {
  color: var(--text-secondary);
}

body[data-theme="sumi-kin"] .text-button {
  color: var(--text-muted);
}

/* Guidance stats must read as information, not as a disabled control. */
body[data-theme="sumi-kin"] .direction-stats {
  border-color: var(--border-strong);
  background: linear-gradient(145deg, rgba(31, 28, 22, 0.98), rgba(18, 16, 13, 0.96));
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(224, 193, 120, 0.08);
}

body[data-theme="sumi-kin"] .direction-stats div + div::before {
  background: linear-gradient(180deg, transparent, rgba(200, 164, 94, 0.62), transparent);
}

body[data-theme="sumi-kin"] .direction-stats span {
  color: var(--text-secondary);
}

body[data-theme="sumi-kin"] .direction-stats strong {
  color: var(--text-primary);
}

/* Compass / Map tabs stay legible in both selected and unselected states. */
body[data-theme="sumi-kin"] .guidance-mode-switch {
  border-color: var(--border-strong);
  background: var(--surface-elevated);
  box-shadow: inset 0 0 0 1px rgba(224, 193, 120, 0.08);
}

body[data-theme="sumi-kin"] .guidance-mode-button {
  color: var(--text-secondary);
}

body[data-theme="sumi-kin"] .guidance-mode-button[aria-pressed="true"] {
  background: linear-gradient(145deg, #e6cd8a 0%, #c8a45e 58%, #a98240 100%);
  color: var(--text-on-accent);
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.24),
    inset 0 0 0 1px rgba(255, 243, 205, 0.24);
}

body[data-theme="sumi-kin"] .guidance-mode-button:focus-visible {
  outline-color: var(--focus-ring);
}
