/* ───────────────────────────────────────────────────────────
   haiku.soul · paper-and-ink · aurora · grain
   ─────────────────────────────────────────────────────────── */

:root {
  /* paper palette */
  --paper:        #f6efde;
  --paper-warm:   #ede2cb;
  --paper-deep:   #e6d8b9;
  --ink:          #1c1814;
  --ink-soft:     #4d4439;
  --ink-faint:    #8a7f6e;
  --gold:         #b89358;
  --vermillion:   #b03d2e;

  --serif:  'Cormorant Garamond', 'Shippori Mincho', Georgia, 'Times New Roman', serif;
  --sans:   'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --shadow-sm:  0 1px 2px rgba(28, 24, 20, 0.06);
  --shadow-md:  0 8px 32px rgba(28, 24, 20, 0.10);
  --shadow-lg:  0 32px 80px -16px rgba(28, 24, 20, 0.22),
                0 8px 24px rgba(28, 24, 20, 0.06);
  --shadow-card-inset: inset 0 0 0 1px rgba(184, 147, 88, 0.18);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  20px;

  --ease:        cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft:   cubic-bezier(0.4, 0, 0.2, 1);

  /* mood-defined; see body[data-mood] below */
  --bg-base:     var(--paper);
  --aurora-1:    rgba(176, 61, 46, 0.35);
  --aurora-2:    rgba(184, 147, 88, 0.30);
  --accent:      var(--vermillion);
  --accent-soft: rgba(176, 61, 46, 0.18);
}

/* ── mood palettes ── */
/* each mood paints the canvas with two atmospheric glow colors + an accent */

body[data-mood='bittersweet'] {
  --bg-base: #f5e6d8;
  --aurora-1: rgba(176, 88, 70, 0.38);
  --aurora-2: rgba(217, 152, 130, 0.42);
  --accent: #b0382a;
  --accent-soft: rgba(176, 56, 42, 0.18);
}
body[data-mood='peaceful'] {
  --bg-base: #ecede0;
  --aurora-1: rgba(110, 138, 102, 0.36);
  --aurora-2: rgba(178, 196, 168, 0.42);
  --accent: #5b7a4f;
  --accent-soft: rgba(91, 122, 79, 0.18);
}
body[data-mood='melancholy'] {
  --bg-base: #e6e7eb;
  --aurora-1: rgba(96, 110, 138, 0.36);
  --aurora-2: rgba(140, 152, 178, 0.42);
  --accent: #4f5d7a;
  --accent-soft: rgba(79, 93, 122, 0.18);
}
body[data-mood='joyful'] {
  --bg-base: #f9eecf;
  --aurora-1: rgba(228, 168, 70, 0.42);
  --aurora-2: rgba(248, 210, 130, 0.45);
  --accent: #c47d18;
  --accent-soft: rgba(196, 125, 24, 0.18);
}
body[data-mood='mysterious'] {
  --bg-base: #e9e3e8;
  --aurora-1: rgba(120, 90, 130, 0.38);
  --aurora-2: rgba(170, 140, 178, 0.40);
  --accent: #6c4a72;
  --accent-soft: rgba(108, 74, 114, 0.18);
}
body[data-mood='romantic'] {
  --bg-base: #f5e3df;
  --aurora-1: rgba(196, 92, 110, 0.36);
  --aurora-2: rgba(232, 168, 174, 0.45);
  --accent: #b04a5c;
  --accent-soft: rgba(176, 74, 92, 0.18);
}
body[data-mood='philosophical'] {
  --bg-base: #ebe5d2;
  --aurora-1: rgba(140, 122, 78, 0.36);
  --aurora-2: rgba(192, 174, 130, 0.42);
  --accent: #7a6a3d;
  --accent-soft: rgba(122, 106, 61, 0.18);
}
body[data-mood='playful'] {
  --bg-base: #fbe9d2;
  --aurora-1: rgba(232, 132, 78, 0.40);
  --aurora-2: rgba(248, 188, 138, 0.46);
  --accent: #c45a18;
  --accent-soft: rgba(196, 90, 24, 0.18);
}
body[data-mood='defiant'] {
  --bg-base: #efdcd4;
  --aurora-1: rgba(180, 56, 38, 0.46);
  --aurora-2: rgba(140, 50, 38, 0.30);
  --accent: #9a2e1e;
  --accent-soft: rgba(154, 46, 30, 0.18);
}
body[data-mood='tender'] {
  --bg-base: #f7e6da;
  --aurora-1: rgba(204, 132, 110, 0.38);
  --aurora-2: rgba(232, 178, 156, 0.42);
  --accent: #b85d48;
  --accent-soft: rgba(184, 93, 72, 0.18);
}

/* ── themes ── */

body[data-theme='ink'] {
  --paper:      #14110d;
  --paper-warm: #1d1812;
  --paper-deep: #221c14;
  --ink:        #f1e7d2;
  --ink-soft:   #c0b59e;
  --ink-faint:  #82786a;
  --gold:       #d6ae6e;
  --shadow-md:  0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg:  0 32px 80px -16px rgba(0, 0, 0, 0.60),
                0 8px 24px rgba(0, 0, 0, 0.30);
  --shadow-card-inset: inset 0 0 0 1px rgba(214, 174, 110, 0.22);
}

body[data-theme='ink'][data-mood='bittersweet']    { --bg-base: #1c1410; --aurora-1: rgba(196, 88, 70, 0.34); --aurora-2: rgba(140, 76, 60, 0.36); --accent: #d96a55; }
body[data-theme='ink'][data-mood='peaceful']       { --bg-base: #131611; --aurora-1: rgba(110, 138, 102, 0.30); --aurora-2: rgba(78, 110, 90, 0.36); --accent: #9bb88c; }
body[data-theme='ink'][data-mood='melancholy']     { --bg-base: #14151a; --aurora-1: rgba(96, 110, 138, 0.30); --aurora-2: rgba(76, 92, 130, 0.36); --accent: #98abce; }
body[data-theme='ink'][data-mood='joyful']         { --bg-base: #1c1610; --aurora-1: rgba(228, 168, 70, 0.30); --aurora-2: rgba(180, 130, 50, 0.36); --accent: #ecc46e; }
body[data-theme='ink'][data-mood='mysterious']     { --bg-base: #181318; --aurora-1: rgba(150, 110, 160, 0.30); --aurora-2: rgba(110, 80, 130, 0.36); --accent: #c39ed2; }
body[data-theme='ink'][data-mood='romantic']       { --bg-base: #1c1316; --aurora-1: rgba(196, 92, 110, 0.30); --aurora-2: rgba(150, 70, 90, 0.36); --accent: #e0879b; }
body[data-theme='ink'][data-mood='philosophical']  { --bg-base: #16140d; --aurora-1: rgba(180, 158, 100, 0.30); --aurora-2: rgba(130, 110, 60, 0.36); --accent: #d8c188; }
body[data-theme='ink'][data-mood='playful']        { --bg-base: #1c1610; --aurora-1: rgba(232, 132, 78, 0.30); --aurora-2: rgba(180, 90, 40, 0.36); --accent: #e89860; }
body[data-theme='ink'][data-mood='defiant']        { --bg-base: #1c100d; --aurora-1: rgba(220, 70, 50, 0.34); --aurora-2: rgba(160, 50, 30, 0.40); --accent: #e26854; }
body[data-theme='ink'][data-mood='tender']         { --bg-base: #1c130f; --aurora-1: rgba(204, 132, 110, 0.30); --aurora-2: rgba(160, 90, 70, 0.36); --accent: #df9a82; }

/* twilight — between paper and ink, sunset hour */
body[data-theme='twilight'] {
  --paper:      #2c2a3a;
  --paper-warm: #36344a;
  --paper-deep: #3a3654;
  --ink:        #f3eadc;
  --ink-soft:   #c8bcaa;
  --ink-faint:  #918394;
  --gold:       #f0c97c;
  --shadow-md:  0 8px 32px rgba(0, 0, 0, 0.30);
  --shadow-lg:  0 32px 80px -16px rgba(0, 0, 0, 0.50),
                0 8px 24px rgba(0, 0, 0, 0.20);
  --shadow-card-inset: inset 0 0 0 1px rgba(240, 201, 124, 0.24);
  --bg-base:    #2b2638;
  --aurora-1:   rgba(232, 138, 110, 0.32);
  --aurora-2:   rgba(126, 100, 168, 0.40);
  --accent:     #f0a878;
  --accent-soft: rgba(240, 168, 120, 0.20);
}

/* zen — pure monochrome */
body[data-theme='zen'] {
  --paper:      #ece9e0;
  --paper-warm: #e2dfd4;
  --paper-deep: #d6d2c5;
  --ink:        #1f1a14;
  --ink-soft:   #5e5648;
  --ink-faint:  #968d7d;
  --gold:       #1f1a14;
  --shadow-card-inset: inset 0 0 0 1px rgba(31, 26, 20, 0.10);
  --bg-base:    #ece9e0;
  --aurora-1:   rgba(31, 26, 20, 0.06);
  --aurora-2:   rgba(31, 26, 20, 0.04);
  --accent:     #1f1a14;
  --accent-soft: rgba(31, 26, 20, 0.10);
}

/* ── reset ── */

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

/* the [hidden] attribute must defeat any later display rule */
[hidden] { display: none !important; }

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

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color 1200ms var(--ease-soft), color 600ms var(--ease-soft);
}

body, body * {
  transition-property: background-color, color, border-color, box-shadow, opacity, transform;
  transition-duration: 600ms;
  transition-timing-function: var(--ease-soft);
}

/* don't transition layout-affecting things */
button, .icon-btn { transition-property: background-color, color, border-color, box-shadow, transform, opacity; }

/* ───────────────────────────────────────────────────────────
   ambient layers (aurora glows + paper grain)
   ─────────────────────────────────────────────────────────── */

.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  filter: saturate(1.05);
}

.aurora::before,
.aurora::after {
  content: '';
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(110px);
  will-change: transform, opacity;
  transition: background 1500ms var(--ease-soft);
}

.aurora::before {
  background: radial-gradient(circle, var(--aurora-1) 0%, transparent 65%);
  top: -25%;
  left: -15%;
  animation: drift1 28s var(--ease-soft) infinite alternate;
}

.aurora::after {
  background: radial-gradient(circle, var(--aurora-2) 0%, transparent 65%);
  bottom: -25%;
  right: -15%;
  animation: drift2 36s var(--ease-soft) infinite alternate;
}

@keyframes drift1 {
  0%   { transform: translate(0, 0) scale(1);     }
  50%  { transform: translate(8vw, 6vh) scale(1.05); }
  100% { transform: translate(-4vw, 10vh) scale(0.95); }
}
@keyframes drift2 {
  0%   { transform: translate(0, 0) scale(1);     }
  50%  { transform: translate(-6vw, -4vh) scale(1.08); }
  100% { transform: translate(4vw, -8vh) scale(0.96); }
}

/* paper grain — SVG turbulence, very subtle */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.8 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='1'/></svg>");
  opacity: 0.045;
  mix-blend-mode: multiply;
}

body[data-theme='ink'] ::before,
body[data-theme='twilight'] ::before {
  mix-blend-mode: screen;
}

#petals {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.85;
}

main, header, footer, aside, .toast {
  position: relative;
  z-index: 3;
}

/* ───────────────────────────────────────────────────────────
   header
   ─────────────────────────────────────────────────────────── */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.75rem 2.25rem;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-mark {
  font-size: 1.7rem;
  color: var(--accent);
  display: inline-block;
  filter: drop-shadow(0 2px 6px var(--accent-soft));
  transition: transform 800ms var(--ease), filter 600ms var(--ease);
}

.brand:hover .brand-mark {
  transform: rotate(180deg) scale(1.1);
  filter: drop-shadow(0 4px 12px var(--accent-soft));
}

.brand h1 {
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1;
}

.brand .dot {
  color: var(--accent);
  font-style: italic;
}

nav {
  display: flex;
  gap: 0.4rem;
}

/* ───────────────────────────────────────────────────────────
   layout
   ─────────────────────────────────────────────────────────── */

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 3.5rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 2.25rem 3.5rem;
  width: 100%;
  align-items: stretch;
}

@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 1rem 1.25rem 2rem;
  }
  .site-header { padding: 1.25rem 1.25rem; }
}

/* ───────────────────────────────────────────────────────────
   composer
   ─────────────────────────────────────────────────────────── */

.composer {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 2.25rem;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--shadow-card-inset);
  position: relative;
}

body[data-theme='ink'] .composer,
body[data-theme='twilight'] .composer {
  background: rgba(28, 22, 16, 0.55);
  border-color: rgba(241, 231, 210, 0.08);
}

body[data-theme='zen'] .composer {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(31, 26, 20, 0.10);
}

.prompt-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--ink-soft);
  letter-spacing: 0.005em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.prompt-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, currentColor, transparent);
  opacity: 0.25;
}

#input {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.55;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(28, 24, 20, 0.08);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  width: 100%;
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: border-color 350ms var(--ease), background 350ms var(--ease), box-shadow 350ms var(--ease);
}

#input::placeholder {
  color: var(--ink-faint);
  font-style: italic;
  opacity: 0.85;
}

#input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

body[data-theme='ink'] #input,
body[data-theme='twilight'] #input {
  background: rgba(0, 0, 0, 0.22);
  border-color: rgba(241, 231, 210, 0.10);
}

body[data-theme='ink'] #input:focus,
body[data-theme='twilight'] #input:focus {
  background: rgba(0, 0, 0, 0.32);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.select {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label-text {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.select select {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(28, 24, 20, 0.10);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234d4439' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease);
}

.select select:hover {
  border-color: rgba(28, 24, 20, 0.25);
}
.select select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

body[data-theme='ink'] .select select,
body[data-theme='twilight'] .select select {
  background-color: rgba(0, 0, 0, 0.28);
  border-color: rgba(241, 231, 210, 0.12);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23c0b59e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

.composer-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

button {
  font-family: var(--sans);
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary {
  background: var(--ink);
  color: var(--paper);
  padding: 0.95rem 1.5rem;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
  flex: 1;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 20px -8px rgba(28, 24, 20, 0.4);
}

.primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: translateX(-100%);
  transition: transform 600ms var(--ease);
}

.primary:hover::before { transform: translateX(100%); }

.primary:hover {
  background: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -6px var(--accent-soft);
}

.primary:active { transform: translateY(0); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid rgba(28, 24, 20, 0.12);
  padding: 0.95rem 1.2rem;
  font-size: 0.92rem;
}

.ghost:hover {
  color: var(--ink);
  border-color: rgba(28, 24, 20, 0.32);
  background: rgba(255, 255, 255, 0.32);
}

body[data-theme='ink'] .ghost,
body[data-theme='twilight'] .ghost {
  border-color: rgba(241, 231, 210, 0.16);
}
body[data-theme='ink'] .ghost:hover,
body[data-theme='twilight'] .ghost:hover {
  background: rgba(241, 231, 210, 0.05);
  border-color: rgba(241, 231, 210, 0.32);
}

.icon-btn {
  background: transparent;
  color: var(--ink-soft);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

.icon-btn svg { width: 1.05rem; height: 1.05rem; }

.icon-btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.42);
  transform: translateY(-1px);
}

.icon-btn.is-active {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.5);
}

body[data-theme='ink'] .icon-btn:hover,
body[data-theme='twilight'] .icon-btn:hover {
  background: rgba(241, 231, 210, 0.08);
}

.hint {
  font-size: 0.74rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  text-align: center;
  margin-top: 0.2rem;
}

kbd {
  font-family: var(--sans);
  font-size: 0.7rem;
  padding: 0.12rem 0.4rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(28, 24, 20, 0.1);
  border-radius: 4px;
  color: var(--ink-soft);
  margin: 0 1px;
}

body[data-theme='ink'] kbd,
body[data-theme='twilight'] kbd {
  background: rgba(241, 231, 210, 0.1);
  border-color: rgba(241, 231, 210, 0.16);
}

/* ───────────────────────────────────────────────────────────
   stage / haiku card
   ─────────────────────────────────────────────────────────── */

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 380px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--serif);
  font-size: 1.15rem;
  text-align: center;
  animation: gentleBreath 7s ease-in-out infinite;
}

.empty-mark {
  font-size: 2.6rem;
  font-style: normal;
  color: var(--accent);
  opacity: 0.5;
}

.empty-sub {
  font-size: 0.92rem;
  opacity: 0.7;
  letter-spacing: 0.01em;
  font-style: italic;
}

@keyframes gentleBreath {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.025); }
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  font-size: 1.05rem;
  padding: 1rem;
  max-width: 22rem;
}

.error-state span {
  font-size: 1.7rem;
  font-style: normal;
}

/* ── loading: ink-drop ripple ── */

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  color: var(--ink-soft);
}

.loader {
  position: relative;
  width: 60px;
  height: 60px;
}

.loader span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  animation: inkDrop 2.4s var(--ease-soft) infinite;
}
.loader span:nth-child(2) { animation-delay: 0.6s; }
.loader span:nth-child(3) { animation-delay: 1.2s; }

@keyframes inkDrop {
  0%   { transform: scale(0.4); opacity: 0; }
  20%  { opacity: 0.9; }
  100% { transform: scale(1.8); opacity: 0; }
}

.loading-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.08rem;
  color: var(--ink-soft);
  min-height: 1.5rem;
  transition: opacity 350ms var(--ease);
  letter-spacing: 0.005em;
}

/* ── card ── */

.haiku-card {
  position: relative;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.42));
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.25rem 1.6rem;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg), var(--shadow-card-inset);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: cardFloat 700ms var(--ease) backwards;
  overflow: hidden;
}

/* sumi-ink wash on the card — radial accent glow */
.haiku-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 100%, var(--accent-soft) 0%, transparent 55%);
  pointer-events: none;
  opacity: 0.55;
}

/* corner seal ✿ — like a chop signature */
.card-seal {
  position: absolute;
  top: 1.05rem;
  right: 1.15rem;
  font-size: 1.05rem;
  color: var(--accent);
  opacity: 0.55;
  font-family: var(--serif);
  pointer-events: none;
  letter-spacing: 0;
  z-index: 2;
}

body[data-theme='ink'] .haiku-card,
body[data-theme='twilight'] .haiku-card {
  background: linear-gradient(160deg, rgba(36, 30, 22, 0.65), rgba(28, 22, 16, 0.55));
  border-color: rgba(241, 231, 210, 0.10);
}

body[data-theme='zen'] .haiku-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.5));
  border-color: rgba(31, 26, 20, 0.12);
}

@keyframes cardFloat {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}

.haiku {
  font-family: var(--serif);
  font-size: 1.85rem;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  text-align: center;
  letter-spacing: 0.005em;
  font-weight: 400;
  min-height: 9.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.haiku.typing::after {
  content: '';
  display: inline-block;
  width: 1.5px;
  height: 1.05em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: caretBlink 0.95s steps(2) infinite;
  position: relative;
  top: 0.2em;
}

@keyframes caretBlink {
  50% { opacity: 0; }
}

@media (max-width: 540px) {
  .haiku { font-size: 1.5rem; line-height: 1.8; }
}

.haiku.is-speaking { color: var(--accent); }

/* brushstroke arc — sits under the haiku */
.brushstroke {
  display: block;
  width: min(180px, 60%);
  height: 8px;
  margin: 0.2rem auto 0;
  opacity: 0;
  transition: opacity 700ms var(--ease) 200ms;
  position: relative;
  z-index: 1;
}

.haiku-card.shown .brushstroke { opacity: 0.65; }

.brushstroke path {
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: brushDraw 1200ms var(--ease) 300ms forwards;
}

@keyframes brushDraw {
  to { stroke-dashoffset: 0; }
}

.card-meta {
  font-size: 0.7rem;
  color: var(--ink-faint);
  text-align: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.card-actions {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(28, 24, 20, 0.06);
  position: relative;
  z-index: 1;
}

.voice-picker {
  flex: 1;
  min-width: 130px;
  max-width: 200px;
  margin-right: 0.4rem;
}
.voice-picker .label-text { font-size: 0.62rem; }
.voice-picker select {
  padding: 0.4rem 1.8rem 0.4rem 0.55rem;
  font-size: 0.85rem;
  background-position: right 0.55rem center;
}

body[data-theme='ink'] .card-actions,
body[data-theme='twilight'] .card-actions { border-top-color: rgba(241, 231, 210, 0.08); }

#speak.is-active {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.5);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
  50%      { box-shadow: 0 0 0 14px transparent; }
}

#save.is-active { color: var(--accent); }
#save.is-active svg path { fill: var(--accent); }

/* ───────────────────────────────────────────────────────────
   favorites drawer
   ─────────────────────────────────────────────────────────── */

.favorites-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: var(--paper);
  border-left: 1px solid rgba(28, 24, 20, 0.08);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 450ms var(--ease);
  overflow-y: auto;
}

.favorites-drawer:not([hidden]) { transform: translateX(0); }

body[data-theme='ink'] .favorites-drawer,
body[data-theme='twilight'] .favorites-drawer {
  background: var(--paper-warm);
  border-left-color: rgba(241, 231, 210, 0.10);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(28, 24, 20, 0.08);
}

.drawer-header h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 500;
  font-style: italic;
}

.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.fav-item {
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(28, 24, 20, 0.06);
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  position: relative;
  transition: background 200ms var(--ease), transform 200ms var(--ease);
}
.fav-item:hover {
  background: rgba(255, 255, 255, 0.7);
  transform: translateX(-2px);
}

body[data-theme='ink'] .fav-item,
body[data-theme='twilight'] .fav-item {
  background: rgba(241, 231, 210, 0.04);
  border-color: rgba(241, 231, 210, 0.10);
}
body[data-theme='ink'] .fav-item:hover,
body[data-theme='twilight'] .fav-item:hover { background: rgba(241, 231, 210, 0.10); }

.fav-haiku {
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--ink);
}

.fav-input {
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-top: 0.5rem;
  font-style: italic;
  letter-spacing: 0.02em;
}

.fav-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 200ms var(--ease);
}
.fav-item:hover .fav-actions { opacity: 1; }

.fav-actions button {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  width: 1.85rem;
  height: 1.85rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fav-actions button:hover { color: var(--accent); }

.favorites-empty {
  text-align: center;
  color: var(--ink-faint);
  font-style: italic;
  font-family: var(--serif);
  padding: 3rem 1rem;
}

/* ───────────────────────────────────────────────────────────
   toast
   ─────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transition: all 350ms var(--ease);
  pointer-events: none;
}

.toast:not([hidden]) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ───────────────────────────────────────────────────────────
   footer
   ─────────────────────────────────────────────────────────── */

footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.78rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.footer-mark {
  margin: 0 0.5rem;
  color: var(--accent);
  opacity: 0.5;
}

#counter {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ───────────────────────────────────────────────────────────
   easter egg — rainbow mode
   ─────────────────────────────────────────────────────────── */

body.rainbow .haiku {
  background: linear-gradient(90deg, #ff6b6b, #f6dc6d, #6dd97f, #6db5f6, #b96df6, #ff6b6b);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbowFlow 4s linear infinite;
}

@keyframes rainbowFlow {
  to { background-position: 200% 0; }
}

body.rainbow .aurora { filter: hue-rotate(0deg); animation: rainbowHue 6s linear infinite; }

@keyframes rainbowHue {
  to { filter: hue-rotate(360deg); }
}

/* ───────────────────────────────────────────────────────────
   reduced motion
   ─────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  #petals { display: none; }
  .aurora::before, .aurora::after { animation: none; }
}
