:root {
  --ground: #eef1ef;
  --ink: #23272e;
  --accent: #4a6b7e;
  --tint-p: #bed7e0;
  --tint-a: #ccdbb9;
  --tint-c: #c5b9df;
  --tint-x: #a4a4ad;
  --serif: "Cormorant Garamond", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --hair: color-mix(in srgb, var(--ink) 20%, transparent);
  /* one poem-text row: composer font-size × line-height */
  --row: calc(1.35rem * 1.5);
  --faint: color-mix(in srgb, var(--ink) 62%, transparent);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  max-width: 30rem;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.45; cursor: default; }
:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* masthead */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.wordmark { font-weight: 500; letter-spacing: 0.02em; }
.mast-right { display: inline-flex; align-items: center; gap: 0.6rem; }
.mast-date { font-size: 0.72rem; color: var(--faint); letter-spacing: 0.06em; }
.icon-btn { display: inline-flex; padding: 0.2rem; color: var(--faint); }
.icon-btn:not(:disabled):active { color: var(--ink); }

/* ko line — the day's seed, resting beneath the word bank */
.ko-line {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  margin: 0.4rem 0 0.15rem;
  min-height: 1.4em;
}

/* composer */
.composer { flex-shrink: 0; margin-top: 1rem; }
.line-wrap { margin-bottom: 0.65rem; }
.line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.32em;
  /* reserve exactly one text row (--row + padding + border) so adding the
     first word never shifts the layout; only wrap spillover does */
  min-height: calc(var(--row) + 0.32rem + 1px);
  padding: 0.1rem 0.1rem 0.22rem;
  border-bottom: 1px solid var(--hair);
  transition: border-color 0.45s ease;
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.5;
  cursor: text;
}
.line.met { border-color: transparent; }

.token {
  display: inline-block;
  padding: 0 0.14em;
  border-radius: 0.3em;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.18s ease;
}
.token.pressed {
  background: var(--press-tint, var(--tint-x));
  box-shadow: 0 2px 6px color-mix(in srgb, var(--ink) 18%, transparent);
}
.token.dragging { opacity: 0.25; }
.token.fading { opacity: 0; }

.ghost-plus {
  color: var(--hair);
  font-family: var(--mono);
  font-size: 0.95rem;
  align-self: center;
  padding: 0 0.3em;
  /* full row height: a spillover row holding only the + is already as tall
     as it will be once a word lands on it */
  height: var(--row);
  display: inline-flex;
  align-items: center;
}

.inline-edit {
  font: inherit;
  font-family: var(--serif);
  line-height: 1.5;
  color: inherit;
  background: none;
  border: none;
  border-bottom: 1px dotted var(--hair);
  outline: none;
  caret-color: var(--accent);
  min-width: 2ch;
}

/* dots */
.dots { display: flex; gap: 0.32rem; padding: 0.3rem 0.15rem 0; min-height: 0.65rem; }
.dot {
  width: 5px; height: 5px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
  transition: background 0.3s ease, border-color 0.3s ease;
}
.dot.ink { background: var(--ink); border-color: var(--ink); }
.dot.over {
  background: color-mix(in srgb, var(--accent) 78%, var(--ground));
  border-color: color-mix(in srgb, var(--accent) 78%, var(--ground));
}

/* actions */
.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: 0.35rem 0 0.6rem;
}
.text-btn { font-size: 0.82rem; letter-spacing: 0.04em; padding: 0.2rem 0.1rem; transition: color 0.25s ease; }
.text-btn.flash { color: var(--accent); }
#btn-keep:not(:disabled) { color: var(--accent); }

/* tray */
.tray {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hair);
  padding-top: 0.5rem;
}
.tray-tabs { display: flex; gap: 1rem; padding: 0 0.1rem 0.5rem; }
.tab {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--faint);
  padding: 0.1rem 0;
}
.tab.active { color: var(--ink); }
.tray-tiles {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-content: flex-start;
  padding: 0.15rem 0.1rem 1rem;
}
.tile {
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.32em 0.6em;
  border-radius: 0.55em;
  background: var(--tint-x);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
body:not(.no-tints) .tile[data-vein="p"] { background: var(--tint-p); }
body:not(.no-tints) .tile[data-vein="a"] { background: var(--tint-a); }
body:not(.no-tints) .tile[data-vein="c"] { background: var(--tint-c); }
.tile:active { filter: brightness(0.56); }

/* drag */
.drag-ghost {
  position: fixed;
  left: 0; top: 0;
  transform: translate(-50%, -140%);
  font-family: var(--serif);
  font-size: 1.25rem;
  padding: 0.05em 0.35em;
  border-radius: 0.3em;
  background: var(--ground);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--ink) 25%, transparent);
  pointer-events: none;
  z-index: 40;
}
.drop-caret {
  position: fixed;
  width: 2px;
  border-radius: 1px;
  background: color-mix(in srgb, var(--ink) 60%, transparent);
  pointer-events: none;
  z-index: 39;
}

/* overlays */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--ground);
  z-index: 50;
  display: flex;
  flex-direction: column;
  max-width: 30rem;
  margin: 0 auto;
  padding: 0.75rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
}
.overlay.hidden, .hidden { display: none; }
.overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 0.8rem;
}
.overlay-title { font-size: 0.72rem; letter-spacing: 0.14em; color: var(--faint); }
.overlay-body { flex: 1; overflow-y: auto; }

/* archive */
.kept-item { padding: 0.9rem 0; border-bottom: 1px solid var(--hair); }
.kept-poem {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.5;
  white-space: pre-line;
}
.kept-meta {
  font-size: 0.68rem;
  color: var(--faint);
  letter-spacing: 0.08em;
  margin-top: 0.45rem;
  display: flex;
  gap: 1rem;
  align-items: baseline;
}
.kept-actions { display: flex; gap: 0.9rem; margin-top: 0.35rem; }
.kept-actions .text-btn { font-size: 0.72rem; color: var(--faint); }
.archive-empty { color: var(--faint); font-size: 0.82rem; padding-top: 1.5rem; text-align: center; }

/* settings */
.settings-body { display: flex; flex-direction: column; }
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  text-align: left;
  padding: 0.9rem 0.1rem;
  border-bottom: 1px solid var(--hair);
  font-size: 0.85rem;
}
.set-state { color: var(--faint); font-size: 0.72rem; letter-spacing: 0.08em; }

/* tutorial */
.tutorial { justify-content: center; align-items: center; background: color-mix(in srgb, var(--ground) 92%, var(--ink)); }
.tutorial-card {
  background: var(--ground);
  border-radius: 0.8rem;
  box-shadow: 0 6px 30px color-mix(in srgb, var(--ink) 15%, transparent);
  padding: 1.6rem 1.4rem 1.1rem;
  margin: 1.5rem;
  max-width: 20rem;
}
.tutorial-text {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.55;
  min-height: 5.2em;
}
.tutorial-nav { display: flex; justify-content: space-between; margin-top: 1rem; }
.tutorial-nav .text-btn { color: var(--faint); }
#tut-next { color: var(--ink); }

/* whisper */
.whisper {
  position: fixed;
  bottom: 2.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--faint);
  background: var(--ground);
  padding: 0.3rem 0.8rem;
  border-radius: 1rem;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--ink) 12%, transparent);
  z-index: 60;
  transition: opacity 0.4s ease;
}

/* motion */
.rise { animation: rise 0.55s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
