/* Nion's look: monotone glass. Greys only, from near-black to near-white, with
   frosted translucent surfaces. There are no accent colors, so Nion's four states
   are told apart by the shape and motion of one icon, not by color. */

:root {
  --ink: #f2f3f7;          /* main text */
  --ink-dim: #a9adbd;      /* secondary text */
  --ink-faint: #6f7385;    /* quietest text */
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(255, 255, 255, 0.12);
  --glass-edge: rgba(255, 255, 255, 0.18);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-family: var(--font);
  /* Soft grey light behind the glass, so the blur has something to show. */
  background:
    radial-gradient(60vmax 60vmax at 15% 10%, rgba(255, 255, 255, 0.09), transparent 60%),
    radial-gradient(50vmax 50vmax at 90% 95%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(160deg, #1a1c24 0%, #0b0c10 70%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Soft grey shapes behind the glass. The frosted panel blurs and bends them, which
   is what makes it look like glass and not just a dark box. */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(36px);
  pointer-events: none;
}
body::before {
  width: 320px;
  height: 320px;
  top: calc(50% - 250px);
  left: calc(50% - 300px);
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.06) 70%);
  animation: drift 16s ease-in-out infinite alternate;
}
body::after {
  width: 260px;
  height: 260px;
  bottom: calc(50% - 250px);
  right: calc(50% - 280px);
  background: radial-gradient(circle at 60% 60%, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.04) 70%);
  animation: drift 20s ease-in-out infinite alternate-reverse;
}
@keyframes drift {
  from { transform: translate(0, 0); }
  to { transform: translate(34px, 26px); }
}

main {
  width: min(92vw, 460px);
  padding: 40px 24px 32px;
  text-align: center;
  /* One big frosted panel that holds everything. */
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.025) 60%);
  border: 1px solid var(--glass-edge);
  border-top-color: rgba(255, 255, 255, 0.32);
  border-left-color: rgba(255, 255, 255, 0.26);
  border-radius: 32px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(30px) saturate(140%);
  backdrop-filter: blur(30px) saturate(140%);
}

/* A faint diagonal sheen across the glass. */
main::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 38%);
  pointer-events: none;
}

main > * {
  position: relative;
}

.wordmark {
  margin: 0 0 28px;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* balances the spacing after the last letter */
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ---------- the state icon ---------- */

.orb {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 0 auto 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  /* A glossy glass sphere: a bright highlight at the top left, darker underneath. */
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.09) 42%, rgba(255, 255, 255, 0.02) 75%),
    linear-gradient(145deg, var(--glass-strong), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--glass-edge);
  border-top-color: rgba(255, 255, 255, 0.45);
  box-shadow:
    inset 0 2px 1px rgba(255, 255, 255, 0.45),
    inset 0 -14px 26px rgba(0, 0, 0, 0.35),
    0 18px 40px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.orb[data-state="off"] {
  opacity: 0.45;
}

/* While Nion is busy, tapping the circle stops it. */
.orb[data-state="speaking"],
.orb[data-state="thinking"] {
  cursor: pointer;
}

.icon {
  display: none;
  width: 92px;
  height: 92px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show only the picture that matches what Nion is doing. */
.orb[data-state="off"] .icon-waiting,
.orb[data-state="waiting"] .icon-waiting,
.orb[data-state="listening"] .icon-listening,
.orb[data-state="thinking"] .icon-thinking,
.orb[data-state="speaking"] .icon-speaking {
  display: block;
}

/* waiting: a ring that breathes, with a soft glow so it is easy to see */
.icon-waiting {
  stroke-width: 3;
  filter: drop-shadow(0 0 7px rgba(255, 255, 255, 0.45));
}
.icon-waiting .core {
  fill: var(--ink);
  stroke: none;
}
.orb[data-state="waiting"] .icon-waiting {
  animation: breathe 4.5s ease-in-out infinite;
}

/* listening: a microphone with a soft pulse */
.icon-listening .pulse {
  stroke-width: 1.6;
  opacity: 0.5;
  transform-origin: 32px 32px;
  animation: pulse 1.8s ease-out infinite;
}

/* thinking: three dots that bounce in turn */
.icon-thinking .dot {
  fill: var(--ink);
  stroke: none;
  animation: bounce 1.1s ease-in-out infinite;
}
.icon-thinking .d2 { animation-delay: 0.15s; }
.icon-thinking .d3 { animation-delay: 0.3s; }

/* speaking: waves that ripple outward */
.icon-speaking .body {
  fill: var(--ink);
  stroke-width: 1.5;
}
.icon-speaking .wave {
  animation: ripple 1.2s ease-in-out infinite;
}
.icon-speaking .w2 { animation-delay: 0.2s; }
.icon-speaking .w3 { animation-delay: 0.4s; }

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.07); opacity: 1; }
}

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-9px); opacity: 1; }
}

@keyframes ripple {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

/* People who ask their device for less motion get still pictures. The four
   states still look different, because the shapes are different. */
@media (prefers-reduced-motion: reduce) {
  .orb,
  body::before,
  body::after,
  .icon-waiting,
  .icon-listening .pulse,
  .icon-thinking .dot,
  .icon-speaking .wave {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- text and buttons ---------- */

.status {
  margin: 0 0 22px;
  min-height: 3em;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.pill {
  font: inherit;
  font-size: 0.95rem;
  padding: 12px 24px;
  color: var(--ink);
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: background 0.2s ease, transform 0.1s ease;
}

.pill:hover {
  background: rgba(255, 255, 255, 0.18);
}

.pill:active {
  transform: scale(0.98);
}

.pill:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.pill.small {
  margin-top: 16px;
  padding: 6px 14px;
  font-size: 0.8rem;
}

.heard {
  margin: 20px 0 0;
  min-height: 1.5em;
  font-size: 0.9rem;
  color: var(--ink-dim);
}

.problem {
  margin: 12px 0 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
}

/* Only shown when the page is opened with ?debug */
.debug {
  text-align: left;
  margin: 14px 0 0;
  max-height: 40vh;
  overflow: auto;
  padding: 10px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  color: var(--ink-dim);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
}

@media (max-width: 420px) {
  main {
    padding: 32px 16px 24px;
    border-radius: 26px;
  }
  .orb {
    width: 148px;
    height: 148px;
  }
}

/* ---------- History ---------- */

.history-link,
.back {
  color: var(--ink-dim);
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.history-link:hover,
.back:hover {
  color: var(--ink);
  border-bottom-color: var(--glass-edge);
}

.history-link:focus-visible,
.back:focus-visible,
.convo:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

main.history {
  width: min(92vw, 640px);
  text-align: left;
}

.history .back {
  display: inline-block;
  margin-bottom: 18px;
}

.history .wordmark {
  text-align: center;
}

.convo {
  display: block;
  margin: 0 0 10px;
  padding: 14px 16px;
  color: var(--ink);
  text-decoration: none;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: background 0.2s ease;
}

.convo:hover {
  background: var(--glass-strong);
}

.convo-title {
  display: block;
  font-size: 1rem;
  line-height: 1.4;
}

.convo-meta {
  display: block;
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--ink-dim);
}

.empty {
  margin: 28px 0 8px;
  text-align: center;
  color: var(--ink-dim);
}

.transcript-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.4;
}

.turn {
  margin: 16px 0 0;
  padding: 12px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
}

.turn-user {
  background: var(--glass-strong);
}

.who {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.said {
  margin: 4px 0 0;
  line-height: 1.5;
}

.sources {
  margin: 8px 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-dim);
}

.sources a {
  color: var(--ink-dim);
}

.history .pill {
  display: block;
  margin: 22px auto 0;
}

/* The small grey text can land on a bright patch of the glass, so give it a soft
   dark edge to stay readable. */
.convo-meta,
.who,
.sources,
.heard {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

/* ---------- A notebook panel, opened by voice ---------- */

.panel {
  margin: 18px 0 0;
  padding: 12px 16px;
  text-align: left;
  background: var(--glass-strong);
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.panel-body {
  margin: 8px 0 0;
  max-height: 38vh;
  overflow-y: auto;
  font: inherit;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- Last answer, shown as text, and typing ---------- */

.exchange {
  margin: 18px 0 0;
  padding: 12px 16px;
  text-align: left;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
}

.exchange p {
  margin: 0;
  overflow-wrap: anywhere;
}

.ex-q {
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.ex-a {
  margin-top: 6px;
  line-height: 1.5;
}

.ex-sources {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.exchange p:empty {
  display: none;
}

.ex-meta {
  margin-top: 6px;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.tagline {
  margin: -16px 0 22px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  line-height: 1.5;
  color: var(--ink-dim);
}

.tour {
  margin: 16px 0;
  padding: 14px 16px;
  text-align: left;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
}

.tour h2 {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.tour p {
  margin: 0 0 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-dim);
}

.tour ol {
  margin: 0 0 8px;
  padding-left: 20px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ink-dim);
}

.tour b {
  font-weight: 600;
  color: var(--ink);
}

.tour-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.linkish {
  padding: 0;
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.typed {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 0;
}

.typed input {
  flex: 1;
  min-width: 0;
  padding: 10px 16px;
  color: var(--ink);
  font: inherit;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
}

.typed input::placeholder {
  color: var(--ink-faint);
}

.typed input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.try {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 14px 0 0;
}

.try-label {
  width: 100%;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.try button {
  padding: 6px 12px;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.try button:hover {
  color: var(--ink);
  background: var(--glass);
}

.try button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- Notebook ---------- */

.nb-intro {
  margin: 0 0 8px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-dim);
}

.nb-section {
  margin: 22px 0 0;
}

.nb-section h2 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.nb-day {
  margin: 12px 0 4px;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.nb-row,
.nb-draft {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 10px 14px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
}

.nb-row .nb-text {
  flex: 1;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.nb-row.done .nb-text {
  color: var(--ink-faint);
  text-decoration: line-through;
}

.nb-draft {
  display: block;
}

.nb-draft .nb-head {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-dim);
  overflow-wrap: anywhere;
}

.nb-draft .nb-body {
  margin: 8px 0 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.nb-empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-faint);
}

.mini {
  flex: none;
  padding: 4px 12px;
  color: var(--ink-dim);
  font: inherit;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.mini:hover {
  color: var(--ink);
  background: var(--glass);
}

.mini:focus-visible,
.nb-row input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.nb-row input[type="checkbox"] {
  flex: none;
  width: 18px;
  height: 18px;
  accent-color: #d9dbe4;
}

.nb-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 26px 0 0;
}

.history .nb-actions .pill {
  display: inline-block;
  margin: 0;
}

.nb-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 8px;
}

.nb-head-row h2 {
  margin: 0;
}

.nb-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

a.mini {
  text-decoration: none;
}

.nb-actions {
  flex-wrap: wrap;
}
