@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

/* Colors mirror the app's voice screen (src/app/(auth)/voice-agent.jsx). */
:root {
  --bg: #faf9f6;
  --ink: #1a1a22;
  --muted: #7a7a86;
  --line: #e5e7eb;
  --field: #f3f4f6;
  --blue: #009feb;
  --orange: #fe5b25;
  --danger: #ef4444;
  --sheet: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, "SF Pro Text", system-ui, sans-serif;
  font-size: 16px;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.logo { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 24px; }
.logo img { width: 20px; height: 20px; margin-top: 1px; }

button.primary {
  background: var(--orange); color: #fff; border: 0; border-radius: 24px;
  padding: 12px 24px; font-weight: 600;
}
button.danger { color: var(--danger); }

/* ---------- login ---------- */
body.login { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px;
  align-items: center; text-align: center;
}
.login-card .logo { font-size: 30px; }
.login-card .logo img { width: 26px; height: 26px; }
.login-card p { margin: 0; }
.login-card input {
  width: 100%; font: inherit; font-size: 17px; padding: 13px 18px; border-radius: 24px;
  border: 1px solid var(--line); background: var(--field); outline: none;
}
.login-card input:focus { border-color: var(--blue); }
.login-card .primary { width: 100%; }
.error { color: var(--danger); font-size: 14px; }

/* ---------- creator page (voice screen) ---------- */
body.voice {
  height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  padding-top: env(safe-area-inset-top); user-select: none; -webkit-user-select: none;
}
.voice-header { display: flex; justify-content: center; padding: 44px 16px 0; }
/* The app's header logo is 24px text / 20px icon: 1.5x on phones, 2.5x on iPad. */
.voice-header .logo { font-size: 36px; gap: 0.25em; }
.voice-header .logo img { width: 0.83em; height: 0.83em; margin-top: 0.04em; }
@media (min-width: 700px) { .voice-header .logo { font-size: 60px; } }
.voice-center {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 0 16px; min-height: 0;
}
.orb-group { position: relative; display: flex; flex-direction: column; align-items: center; }
/* Up to the app's iPad cube size (IPAD_ORB_SIZE = 784). */
.stage { position: relative; width: min(118vw, 784px, 62dvh); aspect-ratio: 1; cursor: pointer; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#cube-inner { filter: blur(3px); }
.caption {
  position: absolute; bottom: -8px; display: flex; align-items: center; gap: 10px;
  font-size: 17px; font-weight: 600; letter-spacing: 0.2px; text-align: center; max-width: 320px;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2.5px solid rgba(0, 159, 235, 0.25); border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.prompter {
  position: absolute; bottom: -18px; margin: 0; max-width: 320px; text-align: center;
  color: var(--muted); font-size: 15px; line-height: 21px;
}

.voice-bottom {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px max(env(safe-area-inset-bottom), 8px) 31px;
  width: 100%; max-width: 720px; margin: 0 auto;
}
.composer {
  flex: 1; display: flex; align-items: center; min-height: 48px; padding: 0 1px 0 20px;
  background: var(--field); border: 1px solid var(--line); border-radius: 24px; text-align: left;
}
.composer .placeholder { flex: 1; color: #9ca3af; font-size: 18px; padding: 8px 0 10px; }
.composer .send {
  width: 44px; height: 44px; margin-right: 1px; border-radius: 50%;
  background: #9ca3af; display: grid; place-items: center;
}
.close {
  width: 42px; height: 42px; border-radius: 25px; border: 0;
  background: var(--ink); display: grid; place-items: center; flex: none;
}

/* ---------- scripts sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 26, 0); transition: background 0.22s;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 82dvh; margin: 0 auto; max-width: 720px;
  background: var(--sheet); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.22s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}
body.sheet-open .sheet { transform: translateY(0); }
body.sheet-open .sheet-backdrop { background: rgba(20, 20, 26, 0.28); }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: #d8d8de; margin: 8px auto 2px; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px 10px 18px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 38px; height: 38px; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; color: var(--ink); }
.icon-btn:active { background: var(--field); }
.sheet-body { overflow-y: auto; padding: 0 16px 20px; -webkit-overflow-scrolling: touch; }
.empty, .hint { color: var(--muted); font-size: 14px; line-height: 20px; }
.hint { margin: 10px 2px 14px; }

.script-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%;
  padding: 14px 16px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--bg); text-align: left;
}
.script-row:active { background: var(--field); }
.script-title { font-weight: 600; }
.script-meta { color: var(--muted); font-size: 13px; }

.start-top { width: 100%; }
.line { display: block; width: 100%; border: 0; background: none; text-align: left; padding: 10px 4px; border-radius: 12px; }
.line:active { background: var(--field); }
.line.ai { font-size: 16px; line-height: 23px; }
.line .who {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--orange);
  letter-spacing: 0.04em; margin-right: 8px; vertical-align: 1px;
}
.line.you { text-align: right; }
.bubble {
  display: inline-block; max-width: 85%; background: var(--blue); color: #fff; text-align: left;
  padding: 10px 16px; border-radius: 20px; font-size: 16px; line-height: 22px;
}

.setting { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 14px 2px; font-size: 15px; }
.setting b { margin-left: auto; font-weight: 600; }
.setting input[type="range"] { width: 100%; accent-color: var(--orange); }
.setting.toggle { flex-wrap: nowrap; }
.setting.toggle input { width: 20px; height: 20px; accent-color: var(--orange); }

/* ---------- script editor ---------- */
body.admin { padding: 0 16px 40px; }
.admin-header { display: flex; align-items: center; gap: 14px; padding: 16px 0; max-width: 1100px; margin: 0 auto; }
.admin-header .logo { font-size: 22px; }
.admin-header a { margin-left: auto; }
.admin-layout { display: grid; grid-template-columns: 300px 1fr; gap: 24px; max-width: 1100px; margin: 0 auto; }
@media (max-width: 760px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-list input[type="search"], .admin-editor input, .admin-editor textarea {
  width: 100%; font: inherit; padding: 11px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; outline: none;
}
.admin-editor textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; line-height: 22px; resize: vertical; }
.admin-list input:focus, .admin-editor input:focus, .admin-editor textarea:focus { border-color: var(--blue); }
.list-row {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 100%;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-align: left;
}
.list-row.active { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }
.list-row .date { font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; background: var(--field); border-radius: 999px; padding: 3px 9px; }
.admin-editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.admin-editor label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.admin-editor .hint { font-weight: 400; margin: 0; font-size: 13px; }
.editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.editor-actions button:not(.primary) {
  border: 1px solid var(--line); background: #fff; border-radius: 24px; padding: 11px 18px; font-weight: 500;
}
.links { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.link-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 13px; }
.admin-editor h3 { margin: 6px 0 -6px; font-size: 15px; }
.preview { display: flex; flex-direction: column; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.pv { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 22px; }
.pv.you { justify-content: flex-end; }
.pv .play {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: var(--orange); color: #fff; font-size: 12px;
}

.meter-row { flex-wrap: nowrap; }
.meter { position: relative; flex: 1; height: 10px; border-radius: 5px; background: var(--field); overflow: hidden; }
#meterLevel { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--blue); transition: width 60ms linear; }
#meterThreshold { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--orange); }
