@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Instrument+Sans:wght@400;500;600;700&display=swap');

:root,
[data-theme='light'] {
  color-scheme: light;

  --bg: oklch(97% 0.008 250);
  --surface: oklch(99% 0.004 250);
  --surface-2: oklch(96% 0.01 250);
  --ink: oklch(18% 0.01 255);
  --ink-soft: oklch(38% 0.024 255);
  --muted: oklch(52% 0.02 255);
  --line: oklch(88% 0.012 250);
  --line-strong: oklch(78% 0.018 250);
  --accent: oklch(18% 0.01 255);
  --accent-soft: oklch(92% 0.008 250);
  --accent-ink: oklch(99% 0.004 250);
  --focus: oklch(55% 0.14 250);
  --danger: oklch(52% 0.18 20);
  --danger-soft: oklch(95% 0.03 20);
}

[data-theme='dark'] {
  color-scheme: dark;

  --bg: oklch(16% 0.018 255);
  --surface: oklch(20% 0.02 255);
  --surface-2: oklch(24% 0.022 255);
  --ink: oklch(94% 0.01 250);
  --ink-soft: oklch(82% 0.014 250);
  --muted: oklch(68% 0.016 250);
  --line: oklch(30% 0.02 255);
  --line-strong: oklch(40% 0.024 255);
  --accent: oklch(94% 0.01 250);
  --accent-soft: oklch(28% 0.02 255);
  --accent-ink: oklch(16% 0.018 255);
  --focus: oklch(70% 0.12 250);
  --danger: oklch(70% 0.16 20);
  --danger-soft: oklch(28% 0.05 20);
}

:root {
  --font-sans: 'Instrument Sans', ui-sans-serif, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --text: var(--ink-soft);
  --text-strong: var(--ink);
  --text-muted: var(--muted);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --canvas-padding: clamp(var(--space-4), 2vw, var(--space-6));
  --toolbar-height: 2.375rem;
  --word-size: clamp(2rem, 6vw, 3.25rem);
  --word-leading: 1.2;
  --word-lines: 2;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  transition: background-color 180ms var(--ease-out), color 180ms var(--ease-out);
}

button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 var(--canvas-padding) var(--canvas-padding);
}

.topbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  padding: var(--canvas-padding) 0;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text-strong);
  line-height: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

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

.lang-select-wrap {
  position: relative;
}

.lang-select {
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  padding: 0 var(--space-4);
  padding-right: calc(var(--space-4) + 0.75rem);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-strong);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0;
  appearance: none;
  cursor: pointer;
  transition:
    border-color 140ms var(--ease-out),
    background-color 140ms var(--ease-out),
    color 140ms var(--ease-out);
}

.lang-select:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lang-select:active {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.lang-select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.lang-select-wrap::after {
  content: '';
  position: absolute;
  top: 50%;
  right: var(--space-3);
  width: 0.35rem;
  height: 0.35rem;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  padding: 0 var(--space-4);
  font-weight: 600;
  border-radius: 0;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  text-decoration: none;
  transition:
    background-color 140ms var(--ease-out),
    border-color 140ms var(--ease-out),
    color 140ms var(--ease-out),
    transform 120ms var(--ease-out);
}

.topbar .toolbar-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.theme-toggle {
  width: var(--toolbar-height);
  min-width: var(--toolbar-height);
  height: var(--toolbar-height);
  padding: 0;
  flex-shrink: 0;
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text-strong);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle:active {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.theme-toggle svg {
  display: block;
  flex-shrink: 0;
}

.theme-toggle svg[hidden] {
  display: none;
}

.shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-4) 0;
  text-align: center;
}

.word-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-inline: clamp(var(--space-4), 4vw, var(--space-10));
  min-height: calc(var(--word-lines) * var(--word-leading) * var(--word-size));
}

.word-display {
  margin: 0;
  width: 100%;
  max-width: 100%;
  font-family: var(--font-mono);
  font-size: var(--word-size);
  font-weight: 600;
  line-height: var(--word-leading);
  letter-spacing: -0.02em;
  color: var(--text-strong);
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: auto;
}

.actions {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  max-width: 24rem;
}

.primary-btn,
.secondary-btn {
  border-radius: 0;
  border: 1px solid transparent;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  transition:
    background-color 140ms var(--ease-out),
    border-color 140ms var(--ease-out),
    color 140ms var(--ease-out),
    filter 140ms var(--ease-out);
}

.primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.secondary-btn {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.secondary-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.secondary-btn:active {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text-strong);
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.site-footer {
  flex-shrink: 0;
  padding-top: var(--space-4);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  :root {
    --word-lines: 3;
    --word-size: clamp(1.75rem, 7.5vw, 2.25rem);
    --canvas-padding: var(--space-4);
  }

  .brand-mark {
    font-size: 1.35rem;
  }

  .shell {
    gap: var(--space-5);
    padding: var(--space-3) 0;
  }

  .word-stage {
    flex: 1;
    min-height: 0;
    padding-inline: var(--space-2);
  }

  .site-footer {
    padding-top: var(--space-3);
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: none;
  }

  .actions .primary-btn,
  .actions .secondary-btn {
    display: flex;
    width: 100%;
    justify-content: center;
  }
}
