/* =========================================================
   PROMPTER — Design System (Apple HIG)
   ========================================================= */
:root {
  --bg: #fbfbfd; --bg-elev: #ffffff; --bg-sidebar: #f5f5f7;
  --text: #1d1d1f; --text-muted: #6e6e73; --text-faint: #a1a1a6;
  --border: rgba(0,0,0,0.08); --border-strong: rgba(0,0,0,0.14);
  --accent: #0071e3; --accent-hover: #0077ed; --accent-soft: rgba(0,113,227,0.08);
  --success: #30d158; --warning: #ff9f0a; --danger: #ff3b30;
  --radius-sm: 8px; --radius: 12px; --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.05);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.topbar { height: 56px; background: rgba(251,251,253,0.85); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 100; }
.topbar .logo { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; color: var(--text); }
.logo-mark { width: 28px; height: 28px; background: linear-gradient(135deg, #0071e3, #5e5ce6); border-radius: 7px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 800; font-size: 14px; box-shadow: 0 2px 8px rgba(0,113,227,0.25); }
.topbar nav { display: flex; gap: 4px; margin-left: 24px; }
.topbar nav button, .crumb { font-size: 14px; color: var(--text-muted); padding: 6px 12px; border-radius: var(--radius-sm); transition: all 0.18s var(--ease); }
.topbar nav button:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.topbar nav button.active { color: var(--text); font-weight: 500; }
.topbar .grow { flex: 1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #ff9f0a, #ff3b30); display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 13px; cursor: pointer; }

/* Page */
.page { padding: 32px 40px 80px; max-width: 1200px; margin: 0 auto; width: 100%; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 32px; gap: 24px; flex-wrap: wrap; }
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-muted); font-size: 15px; margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 980px; font-size: 14px; font-weight: 500; transition: all 0.18s var(--ease); white-space: nowrap; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,113,227,0.25); }
.btn-secondary { background: rgba(0,0,0,0.06); color: var(--text); }
.btn-secondary:hover { background: rgba(0,0,0,0.1); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(255,59,48,0.08); }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; }

/* Cards & lists */
.grid { display: grid; gap: 16px; }
.grid-projects { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--bg-elev); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; transition: all 0.25s var(--ease); cursor: pointer; display: flex; flex-direction: column; gap: 12px; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card-meta { font-size: 13px; color: var(--text-muted); }
.card-stats { display: flex; gap: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); margin-top: auto; }
.card-stats span { display: flex; align-items: center; gap: 4px; }
.card-new { border: 1.5px dashed var(--border-strong); background: transparent; align-items: center; justify-content: center; text-align: center; color: var(--text-muted); min-height: 160px; }
.card-new:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }
.card-new .plus { width: 36px; height: 36px; border-radius: 50%; background: rgba(0,0,0,0.05); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 300; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 980px; font-size: 12px; font-weight: 500; }
.badge-draft { background: rgba(110,110,115,0.1); color: var(--text-muted); }
.badge-review { background: rgba(255,159,10,0.12); color: #b56b00; }
.badge-validated { background: rgba(48,209,88,0.12); color: #1b8a3a; }
.badge-active { background: rgba(0,113,227,0.1); color: var(--accent); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; gap: 16px; transition: all 0.18s var(--ease); cursor: pointer; }
.list-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.list-item .name { font-weight: 500; font-size: 15px; flex: 1; }
.list-item .meta { color: var(--text-muted); font-size: 13px; display: flex; gap: 14px; }
.list-item .actions { display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s; color: var(--text-muted); }
.icon-btn:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* Editor */
.editor-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; min-height: calc(100vh - 200px); }
.editor-main { background: var(--bg-elev); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 32px; display: flex; flex-direction: column; }
.editor-toolbar { display: flex; gap: 6px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.editor-toolbar .icon-btn { width: 34px; height: 34px; }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: 4px 4px; }
.editor-textarea { flex: 1; border: none; outline: none; resize: none; font-size: 18px; line-height: 1.7; font-family: var(--font); color: var(--text); background: transparent; letter-spacing: -0.005em; min-height: 400px; width: 100%; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.save-status { display: flex; align-items: center; gap: 6px; }

.editor-side { display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 13px; color: var(--text-muted); font-weight: 500; display: flex; justify-content: space-between; }
.field label .val { color: var(--text); font-weight: 500; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field select, .field textarea { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 14px; background: var(--bg); outline: none; transition: all 0.15s; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; background: var(--border); border-radius: 999px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: white; border: 0.5px solid rgba(0,0,0,0.1); box-shadow: 0 1px 4px rgba(0,0,0,0.2); cursor: pointer; }

input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
.field-slider-input { display: flex; align-items: center; gap: 10px; }
.field-slider-input input[type="range"] { flex: 1; }
.field-num { width: 64px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 500; outline: none; background: var(--bg); }
.field-num:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.toggle { position: relative; width: 44px; height: 26px; background: rgba(120,120,128,0.16); border-radius: 999px; cursor: pointer; transition: background 0.18s; flex-shrink: 0; }
.toggle.on { background: var(--success); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; background: white; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.18s var(--ease); }
.toggle.on::after { transform: translateX(18px); }
.field-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }

.swatches { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; }
.swatch.active { border-color: var(--accent); transform: scale(1.05); }

/* Teleprompter */
.tp-mode { background: #000; color: #fff; min-height: 100vh; position: relative; overflow: hidden; }
.tp-controls { position: fixed; top: 16px; left: 16px; right: 16px; display: flex; align-items: center; gap: 12px; background: rgba(28,28,30,0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: var(--radius); padding: 10px 16px; z-index: 50; transition: opacity 0.3s; }
.tp-controls.hidden { opacity: 0; pointer-events: none; }
.tp-controls button, .tp-controls .icon-btn { color: rgba(255,255,255,0.85); }
.tp-controls .icon-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.tp-controls .icon-btn.active { background: rgba(255,255,255,0.18); color: white; }
.tp-controls .icon-btn.recording { background: rgba(255,59,48,0.3); color: #ff3b30; animation: blink 1.5s infinite; }
.tp-time { font-variant-numeric: tabular-nums; font-size: 14px; color: rgba(255,255,255,0.7); }
.tp-speed { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,0.85); font-size: 13px; }

.tp-stage { height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 20vh 8vw; overflow: hidden; }
.tp-text { font-size: 56px; line-height: 1.4; font-weight: 500; letter-spacing: -0.01em; text-align: center; max-width: 1100px; white-space: pre-wrap; transition: transform 0.05s linear; }
.tp-cue { position: fixed; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, rgba(255,59,48,0.9) 40%, rgba(255,59,48,0.9) 60%, transparent); z-index: 40; pointer-events: none; }
.tp-mirror-h .tp-text { transform: scaleX(-1); }
.tp-mirror-v .tp-text { transform: scaleY(-1); }
.tp-mirror-h.tp-mirror-v .tp-text { transform: scale(-1, -1); }
.tp-countdown { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); z-index: 100; font-size: 280px; font-weight: 200; letter-spacing: -0.04em; }

/* Client view */
.client-shell { background: var(--bg); min-height: 100vh; }
.client-bar { background: var(--bg-elev); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; gap: 16px; }
.client-bar .project-info { flex: 1; }
.client-bar .project-info h2 { font-size: 16px; font-weight: 600; }
.client-bar .project-info p { font-size: 13px; color: var(--text-muted); }
.client-doc { max-width: 760px; margin: 32px auto; padding: 0 24px; display: grid; grid-template-columns: 1fr 240px; gap: 24px; }
.doc-paper { background: var(--bg-elev); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 48px 56px; min-height: 500px; font-size: 17px; line-height: 1.8; letter-spacing: -0.005em; outline: none; }
.doc-paper p { margin-bottom: 1em; }
.client-side { display: flex; flex-direction: column; gap: 16px; }
.comment-list { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow: auto; }
.comment { background: rgba(255,235,120,0.18); border-left: 3px solid #ffcc00; padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 13px; }
.comment .who { font-weight: 600; font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
.comment .quote { font-style: italic; color: var(--text-muted); border-left: 2px solid rgba(0,0,0,0.1); padding-left: 8px; margin: 6px 0; font-size: 12px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: none; align-items: center; justify-content: center; z-index: 200; padding: 24px; animation: fadeIn 0.18s var(--ease); }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-elev); border-radius: var(--radius-lg); width: 100%; max-width: 480px; padding: 28px; box-shadow: var(--shadow-lg); animation: popIn 0.22s var(--ease); }
.modal h3 { font-size: 20px; font-weight: 600; margin-bottom: 4px; letter-spacing: -0.01em; }
.modal p.sub { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

.share-link-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 13px; margin-top: 8px; }
.share-link-box .url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: rgba(28,28,30,0.95); color: white; padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 300; display: flex; align-items: center; gap: 8px; animation: toastIn 0.25s var(--ease); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Login */
.login-body { background: linear-gradient(180deg, #fbfbfd 0%, #f0f0f4 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--bg-elev); border-radius: var(--radius-lg); padding: 40px 36px; max-width: 400px; width: 100%; box-shadow: var(--shadow); border: 1px solid var(--border); }
.login-card h1 { font-size: 24px; font-weight: 700; margin-top: 24px; letter-spacing: -0.02em; }
.login-card .login-logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); }
.login-card form { margin-top: 20px; }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: rgba(255,59,48,0.08); color: var(--danger); border: 1px solid rgba(255,59,48,0.18); }

/* Import tiles */
.import-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.import-tile { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; text-align: center; transition: all 0.18s var(--ease); }
.import-tile:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.import-tile svg { width: 36px; height: 36px; }

.qr-box { background: white; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 12px 0; }
.qr-mock { width: 180px; height: 180px; background-image: linear-gradient(45deg, #000 25%, transparent 25%), linear-gradient(-45deg, #000 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #000 75%), linear-gradient(-45deg, transparent 75%, #000 75%); background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0px; border-radius: 8px; }

/* Responsive */
@media (max-width: 900px) {
  .page { padding: 24px 20px 60px; }
  .editor-layout { grid-template-columns: 1fr; }
  .client-doc { grid-template-columns: 1fr; }
  .topbar nav { display: none; }
}
