/* Say UI. Tokens from apps/say/DESIGN.md. */

:root {
  --bg: #fafaf8;
  --bg-elevated: #ffffff;
  --ink: #14140f;
  --ink-muted: #5a5a56;
  --ink-soft: #8a8a84;
  --line: #ebebe6;
  --line-strong: #d8d8d2;
  --blush: #fccff6;
  --blush-deep: #e8a8de;
  --success: #1f6b4a;
  --danger: #a33b3b;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --font-display: "Outfit", "Segoe UI", sans-serif;
  --content: 1120px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --shadow-soft: 0 10px 30px rgba(20, 20, 15, 0.05);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.2s;
}

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

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--blush-deep);
  outline-offset: 3px;
}

h1, h2, .brand {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.03em;
}

h1, h2 { margin: 0; font-size: 1.25rem; }

.top, .board { position: relative; z-index: 1; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(var(--content), calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 0;
}

.brand { margin: 0; font-size: 1.35rem; }

.who, .hint, legend, .count { margin: 0; color: var(--ink-muted); }

.board {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr);
  gap: 1rem;
  width: min(var(--content), calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 4.5rem 0 2rem;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1rem 1rem 1.25rem;
  animation: rise var(--dur) var(--ease) both;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.bar {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 12rem;
  max-width: min(36rem, calc(100vw - 1.5rem));
  padding: 0.7rem 1rem;
  color: var(--ink);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity var(--dur) var(--ease);
}

.bar[data-phase="listening"],
.bar[data-phase="processing"],
.bar[data-phase="pasted"],
.bar[data-phase="error"] { opacity: 1; }

.bar[data-phase="listening"] { border-color: var(--blush-deep); background: #fdf0fa; }
.bar[data-phase="pasted"] { border-color: var(--success); }
.bar[data-phase="error"] { border-color: var(--danger); }

.bar-text { margin: 0; font-weight: 600; }

.orb {
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--blush-deep);
}

.bar[data-phase="pasted"] .orb { background: var(--success); }
.bar[data-phase="error"] .orb { background: var(--danger); }

.bars {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 0.9rem;
}

.bars i {
  display: block;
  width: 3px;
  height: 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--ink);
  transform-origin: center bottom;
}

.bar[data-phase="listening"] .bars i {
  animation: wave 0.9s var(--ease) infinite;
}

.bar[data-phase="processing"] .bars,
.bar[data-phase="pasted"] .bars,
.bar[data-phase="error"] .bars,
.bar[data-phase="hidden"] .bars { display: none; }

.bars i:nth-child(2) { animation-delay: 0.1s; }
.bars i:nth-child(3) { animation-delay: 0.2s; }
.bars i:nth-child(4) { animation-delay: 0.05s; }
.bars i:nth-child(5) { animation-delay: 0.18s; }

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-height: min(62vh, 640px);
  overflow: auto;
}

.history li {
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.history li.is-new { animation: rise var(--dur) var(--ease) both; }

.history p { margin: 0.25rem 0; }

.history time, .history small, .raw {
  display: block;
  color: var(--ink-muted);
  font-size: 0.8125rem;
}

.row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.copy {
  min-height: 32px;
  margin: 0;
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.copy:hover { transform: translateY(-1px); }

fieldset {
  border: 0;
  margin: 0.75rem 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

legend { width: 100%; margin-bottom: 0.15rem; }

.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

#hold {
  width: 100%;
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1rem;
  border: 1px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}

#hold:hover { transform: translateY(-1px); }

#hold[aria-pressed="true"] {
  background: #fdf0fa;
  color: var(--ink);
  border-color: var(--blush-deep);
  transform: none;
}

kbd {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.45rem;
  color: inherit;
  font-family: var(--font);
  font-size: 0.75rem;
}

#hold[aria-pressed="true"] kbd { border-color: var(--blush-deep); }

textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--bg);
  resize: vertical;
}

label { display: block; margin-top: 0.75rem; }

.hint {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  min-height: 1.2em;
}

.gate[hidden] { display: none; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.gate .panel { width: min(28rem, 100%); }

#hint:empty { margin: 0; min-height: 0; }

@keyframes wave {
  50% { transform: scaleY(2.4); }
}

@keyframes rise {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; padding-top: 4.75rem; }
  .top, .board { width: min(var(--content), calc(100% - 1.5rem)); }
}

@media (prefers-reduced-motion: reduce) {
  .panel, .history li, .bars i { animation: none; }
  .bar { transition: opacity 0.2s linear; }
  #hold:hover, .copy:hover { transform: none; }
}
