:root {
  color-scheme: light;
  --ink: #101217;
  --muted: #6f6a60;
  --paper: #f7f2e8;
  --paper-deep: #eee7da;
  --coral: #ff5c4d;
  --coral-dark: #e7473b;
  --lime: #e8f45c;
  --white: #fffdf8;
  --border: rgba(16, 18, 23, 0.14);
  --shadow: 0 18px 50px rgba(45, 38, 27, 0.13);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 280px;
  background: var(--paper);
  color: var(--ink);
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 54px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-mark {
  width: 13px;
  height: 13px;
  background: var(--coral);
  border-radius: 4px 9px 5px 8px;
  transform: rotate(-8deg);
}

.progress {
  min-width: 84px;
  margin: 0;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--lime);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.menu-button,
.close-button {
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
}

.menu-button {
  justify-self: end;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 16px;
  background: var(--coral);
  box-shadow: 0 7px 0 rgba(190, 55, 44, 0.16);
}

.menu-button span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 2px 0;
  border-radius: 99px;
  background: var(--ink);
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: clamp(22px, 4vh, 44px);
  min-height: 0;
  padding: clamp(18px, 3.5vh, 38px) 6px;
  text-align: center;
}

.word-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90px;
}

.eyebrow {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: clamp(0.72rem, 2.7vw, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.word {
  max-width: 1120px;
  margin: 0;
  font-family: "Manrope", "DM Sans", sans-serif;
  font-size: clamp(2.35rem, 10vw, 6.5rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -0.065em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.word--placeholder {
  max-width: 430px;
  color: var(--muted);
  font-size: clamp(1.65rem, 7vw, 3.2rem);
  line-height: 1.04;
  letter-spacing: -0.05em;
}

.stage.is-hidden .word {
  display: none;
}

.stage.is-hidden .eyebrow {
  color: var(--ink);
  font-size: clamp(1.8rem, 8vw, 4.8rem);
  line-height: 1;
  letter-spacing: -0.055em;
  text-transform: none;
}

.hidden-hint {
  max-width: 300px;
  margin: 18px 0 0;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.4;
}

.timer {
  width: min(100%, 430px);
  padding: 14px 16px 15px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.7);
  transition: border-color 160ms ease, background 160ms ease;
}

.timer.is-running {
  border-color: var(--ink);
  background: var(--white);
}

.timer.is-finished {
  border-color: var(--coral);
  background: #fff0e9;
}

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

.timer-status {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.timer-limit-button {
  padding: 7px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--lime);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
}

.timer-display {
  display: block;
  margin: 5px 0 3px;
  font-family: "Manrope", "DM Sans", sans-serif;
  font-size: clamp(2.75rem, 13vw, 4rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.06em;
}

.timer.is-finished .timer-display,
.timer.is-finished .timer-status {
  color: var(--coral-dark);
}

.timer-range {
  --timer-progress: 100%;
  width: 100%;
  height: 24px;
  margin: 2px 0 8px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

.timer-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--coral) 0 var(--timer-progress), var(--paper-deep) var(--timer-progress) 100%);
}

.timer-range::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: var(--paper-deep);
}

.timer-range::-moz-range-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--coral);
}

.timer-range::-webkit-slider-thumb {
  width: 21px;
  height: 21px;
  margin-top: -8px;
  border: 4px solid var(--white);
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--ink);
  box-shadow: 0 2px 8px rgba(16, 18, 23, 0.22);
}

.timer-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 4px solid var(--white);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 2px 8px rgba(16, 18, 23, 0.22);
}

.timer-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.timer-action {
  min-width: 0;
  height: 43px;
  padding: 0 8px;
  border: 0;
  border-radius: 13px;
  background: var(--paper-deep);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.timer-action--play {
  background: var(--ink);
  color: var(--white);
  font-size: 1rem;
}

.timer.is-running .timer-action--play {
  background: var(--coral);
  color: var(--ink);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 16px);
  width: min(100%, 860px);
  margin: 0 auto;
}

.control-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: clamp(72px, 12vh, 104px);
  padding: 13px 12px;
  border: 2px solid var(--coral);
  border-radius: clamp(18px, 4vw, 28px);
  background: transparent;
  font-size: clamp(0.82rem, 3.4vw, 1.13rem);
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.control-button:active {
  transform: translateY(3px) scale(0.99);
}

.control-button:disabled,
.timer-action:disabled,
.timer-range:disabled {
  opacity: 0.34;
  cursor: default;
}

.control-button:disabled:active,
.timer-action:disabled:active {
  transform: none;
}

.control-button--hide {
  flex-direction: column;
  gap: 6px;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}

.control-button--primary {
  gap: 8px;
  background: var(--coral);
  box-shadow: 0 8px 0 rgba(190, 55, 44, 0.18);
}

.control-button--secondary {
  gap: 8px;
}

.control-icon {
  color: var(--coral-dark);
  font-size: 1.45em;
  line-height: 1;
}

.control-button--primary .control-icon {
  color: var(--ink);
}

.eye-icon {
  position: relative;
  width: 27px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 70% 15%;
  transform: rotate(45deg);
}

.eye-icon::before {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.eye-icon::after {
  position: absolute;
  top: 7px;
  left: -4px;
  width: 34px;
  height: 2px;
  border-radius: 4px;
  background: var(--coral);
  content: "";
}

.scrim {
  position: fixed;
  z-index: 10;
  inset: 0;
  background: rgba(16, 18, 23, 0.38);
  opacity: 0;
  backdrop-filter: blur(3px);
  transition: opacity 220ms ease;
}

.scrim.is-open {
  opacity: 1;
}

.editor {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(100%, 520px);
  height: 100vh;
  height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) 20px;
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1), visibility 260ms;
}

.editor.is-open {
  transform: translateX(0);
  visibility: visible;
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.editor-kicker {
  margin: 0 0 4px;
  color: var(--coral-dark);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.editor h2 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: clamp(1.65rem, 7vw, 2.2rem);
  letter-spacing: -0.05em;
}

.close-button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--paper-deep);
  font-size: 1.8rem;
  line-height: 1;
}

.add-form {
  margin-top: 26px;
}

.add-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

.add-row {
  display: flex;
  gap: 8px;
}

.add-row input {
  min-width: 0;
  flex: 1;
  height: 50px;
  padding: 0 15px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
}

.add-row input::placeholder {
  color: #8e887e;
}

.add-row button {
  border: 0;
  border-radius: 14px;
  padding: 0 15px;
  background: var(--coral);
  font-weight: 800;
  cursor: pointer;
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 10px;
}

.list-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.text-button {
  padding: 5px;
  border: 0;
  background: transparent;
  color: var(--coral-dark);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.text-button:disabled {
  color: var(--muted);
  opacity: 0.42;
  cursor: default;
}

.word-list {
  min-height: 0;
  margin: 0;
  padding: 0 3px 12px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.empty-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  padding: 30px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.empty-list strong {
  color: var(--ink);
  font-size: 1rem;
}

.empty-list span {
  max-width: 230px;
  margin-top: 6px;
  font-size: 0.83rem;
  line-height: 1.4;
}

.word-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  margin: 7px 0;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--white);
}

.word-item.is-current {
  border-color: var(--coral);
  background: #fff4ed;
}

.item-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--paper-deep);
  font-size: 0.75rem;
  font-weight: 800;
}

.item-text {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.item-actions {
  display: flex;
  gap: 4px;
}

.item-action {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: var(--paper);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.item-action:disabled {
  opacity: 0.3;
  cursor: default;
}

.item-action--delete {
  color: var(--coral-dark);
}

.timer-dialog {
  width: min(calc(100% - 28px), 430px);
  margin: auto;
  padding: 24px;
  border: 0;
  border-radius: 28px;
  background: var(--white);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.timer-dialog::backdrop {
  background: rgba(16, 18, 23, 0.45);
  backdrop-filter: blur(3px);
}

.timer-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.timer-dialog h2 {
  margin: 0;
  font-family: "Manrope", sans-serif;
  font-size: 1.8rem;
  letter-spacing: -0.05em;
}

.timer-dialog-copy {
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.timer-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.timer-presets button {
  min-height: 52px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 800;
  cursor: pointer;
}

.timer-presets button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--lime);
}

.custom-limit-form {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.custom-limit-form > label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 800;
}

.custom-limit-row {
  display: flex;
  gap: 8px;
}

.limit-input-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
  height: 50px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--paper);
}

.limit-input-wrap input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.limit-input-wrap span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.custom-limit-row > button {
  padding: 0 17px;
  border: 0;
  border-radius: 14px;
  background: var(--coral);
  font-weight: 800;
  cursor: pointer;
}

.toast {
  position: fixed;
  z-index: 30;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100% - 36px);
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 0.84rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.editor-open {
  overflow: hidden;
}

@media (hover: hover) {
  .control-button:hover,
  .menu-button:hover,
  .add-row button:hover,
  .timer-limit-button:hover,
  .timer-action:hover,
  .timer-presets button:hover,
  .custom-limit-row > button:hover {
    filter: brightness(0.97);
  }

  .control-button--secondary:hover {
    background: rgba(255, 92, 77, 0.08);
  }

  .item-action:hover,
  .close-button:hover {
    background: #e4ddd1;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .app-shell {
    grid-template-columns: 1fr minmax(280px, 2fr) auto;
    grid-template-rows: 1fr;
    align-items: stretch;
  }

  .topbar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
  }

  .brand span:last-child {
    display: none;
  }

  .menu-button {
    justify-self: auto;
  }

  .stage {
    gap: 12px;
    padding: 10px 16px;
  }

  .word {
    font-size: clamp(2rem, 7vw, 4.2rem);
  }

  .timer {
    padding: 10px 12px;
  }

  .timer-display {
    font-size: 2.4rem;
  }

  .timer-range {
    margin-block: 0 4px;
  }

  .timer-action {
    height: 38px;
  }

  .controls {
    grid-template-columns: 100px;
    align-content: center;
  }

  .control-button {
    min-height: 68px;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .brand span:last-child {
    display: none;
  }

  .progress {
    min-width: 76px;
    padding-inline: 10px;
  }

  .control-button {
    padding-inline: 5px;
  }

  .control-icon {
    display: none;
  }

  .word-item {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    gap: 5px;
  }

  .item-action {
    width: 31px;
  }

  .timer {
    padding-inline: 12px;
  }

  .timer-controls {
    gap: 6px;
  }
}

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