/* Penguina UI kit v0.2 – Speak-style glass/light theme */
:root {
  --font-body: 'DM Sans', 'Space Grotesk', 'Manrope', system-ui, -apple-system, sans-serif;
  --bg: radial-gradient(circle at 20% 20%, #c5ddff 0%, transparent 45%),
    radial-gradient(circle at 80% 30%, #ffd3f4 0%, transparent 40%),
    linear-gradient(180deg, #f8fbff 0%, #eef1f8 60%, #e8ecf3 100%);
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.82);
  --panel-soft: rgba(255, 255, 255, 0.7);
  --border: rgba(30, 41, 59, 0.08);
  --border-strong: rgba(30, 41, 59, 0.12);
  --text: #0f172a;
  --muted: #5f6b85;
  --accent: #2f7cff;
  --accent-strong: #1d4ed8;
  --accent-ink: #0b225f;
  --pill: rgba(47, 124, 255, 0.12);
  --pill-border: rgba(47, 124, 255, 0.24);
  --success: #22c55e;
  --danger: #f87171;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.16), 0 6px 20px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --menu-text: #334155;
  --menu-sep: #94a3b8;
  --menu-right: #475569;
  --menu-bg: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(238,242,248,0.96));
  --title-text: #1f2937;
  --label-text: #1f2937;
  --brand-text: #4b5563;
  --mono-text: #1f2937;
  --btn-secondary-bg: rgba(15, 23, 42, 0.06);
  --progress-track: rgba(15, 23, 42, 0.06);
  --progress-border: rgba(15, 23, 42, 0.08);
  --pill-danger-bg: rgba(248,113,113,0.1);
  --pill-danger-border: rgba(248,113,113,0.28);
  --pill-danger-text: #7f1d1d;
  --pill-success-bg: rgba(34,197,94,0.14);
  --pill-success-border: rgba(34,197,94,0.3);
  --pill-success-text: #0f5132;
  color-scheme: light;
  color: var(--text);
  font-family: var(--font-body);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: radial-gradient(circle at 18% 22%, rgba(59, 130, 246, 0.18) 0%, transparent 42%),
      radial-gradient(circle at 82% 18%, rgba(236, 72, 153, 0.16) 0%, transparent 38%),
      linear-gradient(180deg, #0b1220 0%, #0f172a 55%, #0b1220 100%);
    --panel: rgba(15, 23, 42, 0.85);
    --panel-strong: rgba(15, 23, 42, 0.92);
    --panel-soft: rgba(30, 41, 59, 0.7);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --accent-ink: #dbeafe;
    --pill: rgba(96, 165, 250, 0.26);
    --pill-border: rgba(147, 197, 253, 0.55);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.25);
    --menu-text: #e2e8f0;
    --menu-sep: #94a3b8;
    --menu-right: #cbd5e1;
    --menu-bg: linear-gradient(180deg, rgba(15,16,24,0.94), rgba(15,23,42,0.94));
    --title-text: #e2e8f0;
    --label-text: #e2e8f0;
    --brand-text: #cbd5e1;
    --mono-text: #e5e7eb;
    --btn-secondary-bg: rgba(255, 255, 255, 0.06);
    --progress-track: rgba(255, 255, 255, 0.08);
    --progress-border: rgba(255, 255, 255, 0.12);
    --pill-danger-bg: rgba(239, 68, 68, 0.16);
    --pill-danger-border: rgba(239, 68, 68, 0.34);
    --pill-danger-text: #fecdd3;
    --pill-success-bg: rgba(34, 197, 94, 0.18);
    --pill-success-border: rgba(34, 197, 94, 0.38);
    --pill-success-text: #bbf7d0;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: radial-gradient(circle at 18% 22%, rgba(59, 130, 246, 0.18) 0%, transparent 42%),
    radial-gradient(circle at 82% 18%, rgba(236, 72, 153, 0.16) 0%, transparent 38%),
    linear-gradient(180deg, #0b1220 0%, #0f172a 55%, #0b1220 100%);
  --panel: rgba(15, 23, 42, 0.85);
  --panel-strong: rgba(15, 23, 42, 0.92);
  --panel-soft: rgba(30, 41, 59, 0.7);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #60a5fa;
  --accent-ink: #0b1220;
  --pill: rgba(96, 165, 250, 0.16);
  --pill-border: rgba(96, 165, 250, 0.38);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.25);
  --menu-text: #e2e8f0;
  --menu-sep: #94a3b8;
  --menu-right: #cbd5e1;
  --menu-bg: linear-gradient(180deg, rgba(15,16,24,0.94), rgba(15,23,42,0.94));
  --title-text: #e2e8f0;
  --label-text: #e2e8f0;
  --brand-text: #cbd5e1;
  --mono-text: #e5e7eb;
  --btn-secondary-bg: rgba(255, 255, 255, 0.06);
  --progress-track: rgba(255, 255, 255, 0.08);
  --progress-border: rgba(255, 255, 255, 0.12);
  --pill-danger-bg: rgba(239, 68, 68, 0.16);
  --pill-danger-border: rgba(239, 68, 68, 0.34);
  --pill-danger-text: #fecdd3;
  --pill-success-bg: rgba(34, 197, 94, 0.18);
  --pill-success-border: rgba(34, 197, 94, 0.38);
  --pill-success-text: #bbf7d0;
}

:root[data-theme="light"] {
  --bg: radial-gradient(circle at 20% 20%, #c5ddff 0%, transparent 45%),
    radial-gradient(circle at 80% 30%, #ffd3f4 0%, transparent 40%),
    linear-gradient(180deg, #f8fbff 0%, #eef1f8 60%, #e8ecf3 100%);
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.82);
  --panel-soft: rgba(255, 255, 255, 0.7);
  --border: rgba(30, 41, 59, 0.08);
  --border-strong: rgba(30, 41, 59, 0.12);
  --text: #0f172a;
  --muted: #5f6b85;
  --accent: #2f7cff;
  --accent-ink: #0b225f;
  --pill: rgba(47, 124, 255, 0.12);
  --pill-border: rgba(47, 124, 255, 0.24);
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.16), 0 6px 20px rgba(15, 23, 42, 0.08);
  --menu-text: #334155;
  --menu-sep: #94a3b8;
  --menu-right: #475569;
  --menu-bg: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(238,242,248,0.96));
  --title-text: #1f2937;
  --label-text: #1f2937;
  --brand-text: #4b5563;
  --mono-text: #1f2937;
  --btn-secondary-bg: rgba(15, 23, 42, 0.06);
  --progress-track: rgba(15, 23, 42, 0.06);
  --progress-border: rgba(15, 23, 42, 0.08);
  --pill-danger-bg: rgba(248,113,113,0.1);
  --pill-danger-border: rgba(248,113,113,0.28);
  --pill-danger-text: #7f1d1d;
  --pill-success-bg: rgba(34,197,94,0.14);
  --pill-success-border: rgba(34,197,94,0.3);
  --pill-success-text: #0f5132;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-repeat: no-repeat;
  background-size: 155% 145%, 155% 145%, 155% 145%;
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 96px 0 32px;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.6;
}

@supports (height: 100dvh) { body { min-height: 100dvh; } }

.pg-sky {
  position: fixed;
  inset: -12% -12% -12% -12%;
  min-height: 110vh;
  background: var(--bg);
  background-repeat: no-repeat;
  background-size: 170% 155%, 170% 155%, 170% 155%;
  filter: blur(1.5px) saturate(1.04);
  z-index: 0;
  transform-origin: 50% 50%;
}

.pg-grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="160" height="160" viewBox="0 0 160 160"><filter id="n" x="0" y="0"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="2" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.08"/></svg>');
  mix-blend-mode: soft-light;
  z-index: 1;
}

.pg-shell { position: relative; z-index: 2; width: min(1100px, 92vw); padding: 24px 0 56px; }

.pg-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100vw;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 12px calc(16px + env(safe-area-inset-left));
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 13px;
  color: var(--menu-text);
  background: var(--menu-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  z-index: 5;
}
.pg-menu a { color: inherit; text-decoration: none; }
.pg-menu a:hover { text-decoration: none; }
.pg-crumbs { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.pg-crumb-sep { color: var(--menu-sep); font-weight: 700; letter-spacing: 0; }
.pg-menu .right { font-weight: 700; letter-spacing: 0.08em; color: var(--menu-right); }
.pg-menu .menu-credit { font-weight: 700; letter-spacing: 0.08em; line-height: 1; }
.pg-menu .menu-link { text-decoration: none; color: inherit; font-weight: 800; letter-spacing: 0.08em; padding: 2px 0; line-height: 1; }

.pg-window {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: floatIn 420ms ease;
}

.pg-titlebar {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(245,247,250,0.9));
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.pg-title {
  margin: 0;
  font-weight: 800;
  color: var(--title-text);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 16px;
  line-height: 1.4;
}

.pg-body { padding: 36px 38px 42px; display: grid; gap: 20px; }

.pg-card,
.card {
  background: var(--panel-strong);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: floatIn 420ms ease;
}

.pg-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  font-size: 13px;
  color: var(--brand-text);
  opacity: 0.9;
}
.pg-brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2f7cff, #7c9bff);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.36), 0 8px 20px rgba(47,124,255,0.2);
}

.pg-sub { margin: 0; color: var(--muted); line-height: 1.55; }
.pg-sub { font-size: 15px; }
.pg-row { display: flex; flex-direction: column; gap: 6px; }
.pg-grid { display: grid; gap: 12px 16px; }

.pg-label { font-weight: 700; color: var(--label-text); letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; }
.pg-input {
  width: 100%;
  padding: 14px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.pg-input:focus {
  border-color: rgba(47, 124, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(47, 124, 255, 0.15);
  outline: none;
}

.pg-hint { font-size: 13px; color: var(--muted); line-height: 1.45; }

.pg-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  min-height: 44px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.22);
  transition: transform 120ms ease, box-shadow 120ms ease, background 140ms ease, filter 120ms ease;
}
.pg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pg-btn:hover,
.btn:hover { transform: translateY(-1px); box-shadow: 0 16px 34px rgba(37, 99, 235, 0.28); filter: brightness(1.02); }
.pg-btn:active,
.btn:active { transform: translateY(0); filter: brightness(0.97); }
.pg-btn.secondary,
.btn.secondary { background: var(--btn-secondary-bg); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.icon-btn { min-width: 40px; min-height: 40px; padding: 0; font-size: 16px; line-height: 1; }

.pg-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--pill-border);
  background: var(--pill);
  color: var(--accent-ink);
  font-weight: 700;
  width: fit-content;
}
.pg-pill.danger { background: var(--pill-danger-bg); border-color: var(--pill-danger-border); color: var(--pill-danger-text); }
.pg-pill.success { background: var(--pill-success-bg); border-color: var(--pill-success-border); color: var(--pill-success-text); }

.pill-dot { width: 9px; height: 9px; border-radius: 999px; background: #fbbf24; box-shadow: 0 0 0 6px rgba(251,191,36,0.12); }
.pill-online .pill-dot { background: #22c55e; box-shadow: 0 0 0 6px rgba(34,197,94,0.16); animation: pulseDot 1.6s ease-in-out infinite; }
.pill-offline .pill-dot { background: #ef4444; box-shadow: 0 0 0 6px rgba(239,68,68,0.16); }
.pill-starting .pill-dot { background: #f97316; box-shadow: 0 0 0 6px rgba(249,115,22,0.16); }
.pill-upgrading .pill-dot { background: #a855f7; box-shadow: 0 0 0 6px rgba(168,85,247,0.18); }

.pg-progress,
.progress {
  position: relative;
  height: 10px;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--progress-border);
}
.pg-progress-bar,
.progress-bar { position: absolute; inset: 0; width: 0%; background: linear-gradient(90deg, #2f7cff, #60a5fa, #93c5fd); transition: width 160ms ease-out; }

.pg-emoji-pill,
.word-icon { width: 34px; height: 34px; border-radius: var(--radius); background: var(--pill); color: var(--accent-ink); display: grid; place-items: center; font-size: 17px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.7); border: 1px solid var(--pill-border); }
.word-icon.hidden { display: none; }

.pg-phonetic,
.phonetic-text { font-size: 18px; padding: 8px 12px; border-radius: var(--radius); background: var(--pill); color: var(--accent-ink); border: 1px solid var(--pill-border); }

.pg-muted,
.muted { color: var(--muted); font-size: 14px; }
.mono { font-family: 'Space Grotesk', ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace; font-size: 14px; color: var(--mono-text); }

.pg-section { background: var(--panel-strong); border: 1px solid var(--border); border-radius: 16px; padding: 18px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.5); }

.pg-input-row,
.input-wrap { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--border); box-shadow: inset 0 1px 0 rgba(255,255,255,0.4); transition: box-shadow 180ms ease, transform 180ms ease; }
.input-wrap:focus-within { box-shadow: 0 18px 40px rgba(47, 124, 255, 0.12); transform: translateY(-1px); }

.pg-title-sm {
  margin: 6px 0 8px;
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--title-text);
}
.pg-label-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 999px; background: var(--panel-soft); border: 1px solid var(--border); font-weight: 600; color: var(--label-text); }

@media (max-width: 720px) {
  body { padding: 72px 0 24px; }
  .pg-body { padding: 24px; }
  .input-wrap { grid-template-columns: 1fr; }
  .pg-menu { letter-spacing: 0.12em; flex-direction: column; align-items: flex-start; gap: 8px; }
  .pg-menu .right { width: 100%; display: flex !important; align-items: center; gap: 8px; flex-wrap: wrap; white-space: normal !important; }
  .pg-menu .menu-credit { display: none !important; }
  .pg-menu .menu-link.menu-support { display: none !important; }
}

@keyframes floatIn { from { opacity: 0; transform: translateY(14px) scale(0.995); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes skyDrift {
  0% { background-position: -6% -2%, 106% 18%, 50% -4%; background-size: 162% 146%, 158% 144%, 166% 150%; }
  50% { background-position: 12% 12%, 88% 32%, 50% 14%; background-size: 176% 160%, 170% 156%, 182% 166%; }
  100% { background-position: 4% 20%, 80% 10%, 50% 10%; background-size: 168% 154%, 174% 160%, 170% 156%; }
}
@keyframes pulseDot { 0% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34,197,94,0.18); } 50% { transform: scale(1.08); box-shadow: 0 0 0 12px rgba(34,197,94,0.08); } 100% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34,197,94,0.18); } }
