:root {
  --bg: #11111b;
  --surface: #1e1e2e;
  --card: #181825;
  --overlay: #313244;
  --text: #cdd6f4;
  --muted: #a6adc8;
  --blue: #89b4fa;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --pink: #f38ba8;
  --mauve: #cba6f7;
  --peach: #fab387;
  --ink: #11111b;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 16px; }
#app { min-height: 100dvh; display: flex; flex-direction: column; padding-top: calc(12px + var(--safe-top)); padding-bottom: calc(84px + var(--safe-bottom)); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 4px 18px 10px; }
.eyebrow { margin: 0 0 2px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 1.15rem; line-height: 1.25; }
.badge-version { flex-shrink: 0; background: var(--overlay); color: var(--yellow); border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; }
.content { flex: 1; padding: 0 16px 20px; }
.view[hidden] { display: none !important; }
.card, .search-card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.search-card label, .card label, .card h2 { display: block; margin: 0 0 8px; font-size: 0.92rem; }
.card h2 { color: var(--yellow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.hint { margin: 0 0 12px; color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.search-row, .btn-row { display: flex; gap: 8px; }
.btn-row.wrap { flex-wrap: wrap; margin-top: 10px; }
.grow { flex: 1; }
input, textarea, select { width: 100%; border: 0; border-radius: 14px; background: var(--overlay); color: var(--text); font: inherit; padding: 12px 14px; }
textarea { resize: vertical; min-height: 88px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--blue); }
.search-row input { flex: 1; }
.btn { border: 0; border-radius: 14px; padding: 12px 14px; font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; min-height: 46px; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-sm { min-height: 38px; padding: 8px 10px; font-size: 0.85rem; }
.btn-blue { background: var(--blue); }
.btn-green { background: var(--green); }
.btn-pink { background: var(--pink); }
.btn-yellow { background: var(--yellow); }
.btn-yellow-soft { background: #e8d5a3; }
.btn-peach { background: var(--peach); }
.btn-mauve { background: var(--mauve); }
.full { width: 100%; margin-top: 10px; }
.media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.media-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 72px; margin: 0; background: var(--overlay); border-radius: 14px; font-size: 0.85rem; font-weight: 700; }
.media-btn span { font-size: 1.3rem; }
.preview-media { background: var(--overlay); border-radius: 14px; min-height: 72px; padding: 10px; color: var(--muted); font-size: 0.88rem; display: flex; align-items: center; justify-content: center; text-align: center; overflow: hidden; }
.preview-media img, .preview-media video { max-width: 100%; max-height: 160px; border-radius: 10px; }
.result-card { display: grid; gap: 14px; }
.poster-box { width: 100%; max-width: 220px; margin: 0 auto; aspect-ratio: 180 / 260; background: var(--overlay); border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; }
.poster-box img { width: 100%; height: 100%; object-fit: cover; }
.status-line { min-height: 1.2em; margin: 8px 0 0; color: var(--yellow); font-size: 0.85rem; }
.panel { background: var(--overlay); border-radius: 14px; padding: 12px; white-space: pre-wrap; line-height: 1.45; min-height: 72px; margin-bottom: 12px; }
.panel-green { color: var(--green); }
.panel-pink { color: var(--pink); }
.panel-result { color: var(--text); min-height: 140px; }
.actions-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.history-list { display: grid; gap: 10px; }
.history-item { background: var(--card); border-radius: var(--radius); padding: 14px; }
.history-item h3 { margin: 0 0 6px; font-size: 1rem; }
.history-meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; }
.history-item p { margin: 0 0 10px; color: var(--text); font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.history-actions { display: flex; gap: 8px; }
.empty-state { text-align: center; color: var(--muted); padding: 32px 12px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); background: #181825ee; backdrop-filter: blur(12px); border-top: 1px solid #313244; padding: 6px 8px calc(8px + var(--safe-bottom)); z-index: 20; }
.tab { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; font-size: 0.78rem; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab span { font-size: 1.15rem; }
.tab.is-active { color: var(--blue); }
.overlay { position: fixed; inset: 0; background: #11111bcc; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 40; }
.overlay[hidden] { display: none; }
.spinner { width: 42px; height: 42px; border: 4px solid #313244; border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--safe-bottom)); background: var(--yellow); color: var(--ink); border-radius: 14px; padding: 12px 14px; font-weight: 700; z-index: 50; text-align: center; }
.toast[hidden] { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (min-width: 720px) {
  #app { max-width: 560px; margin: 0 auto; border-left: 1px solid #313244; border-right: 1px solid #313244; }
  .result-card { grid-template-columns: 180px 1fr; align-items: start; }
}
