/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f12;
  --bg2: #1a1a22;
  --bg3: #242430;
  --border: #2e2e3e;
  --text: #e0e0ee;
  --text-dim: #7a7a99;
  --accent: #e9aa00;
  --accent-hover: #f0bc1a;
  --green: #27ae60;
  --red: #c0392b;
  --red-bright: #e74c3c;
  --yellow: #e6a817;
  --orange: #e67e22;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.5);
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }

.screen { display: flex; flex-direction: column; min-height: 100vh; }
.screen.hidden { display: none !important; }

/* ── Login Screen ──────────────────────────────────────── */
#login-screen { align-items: center; justify-content: center; background: var(--bg); }
.login-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 48px 40px; max-width: 400px; width: 100%; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-logo-img { width: 220px; margin: 0 auto 12px; display: block; }
.login-box h1 { font-size: 1.4rem; text-align: center; margin-bottom: 2px; }
.login-subtitle { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 4px; }
.btn-link { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.82rem; text-decoration: underline; padding: 0; text-align: left; }
.btn-link:hover { color: var(--text); }
.success-msg { color: #2ecc71; font-size: 0.85rem; }

/* ── Loading Overlay ───────────────────────────────────── */
.loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.loading-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 40px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.loading-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Offline Banner ────────────────────────────────────── */
.offline-banner { background: rgba(230,168,23,0.15); border-bottom: 1px solid var(--yellow); color: var(--yellow); padding: 6px 16px; font-size: 0.84rem; text-align: center; }

/* ── Asset Upload ──────────────────────────────────────── */
.asset-upload-grid { display: flex; flex-direction: column; gap: 14px; }
.special-asset-row { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--bg3); border-radius: 6px; }
.special-asset-row > label { font-size: 0.82rem; color: var(--text-dim); }
.asset-file-row { display: flex; align-items: center; gap: 8px; }
.asset-current-name { flex: 1; font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-vol-row { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; margin-top: 4px; }
.asset-vol-row input[type=range] { flex: 1; }

/* ── Wide Modal ────────────────────────────────────────── */
.modal-box.wide { width: min(800px, 95vw); }

/* ── Startup Screen ─────────────────────────────────────── */
#startup-screen { padding: 24px; }
.startup-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.startup-header h1 { font-size: 1.6rem; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.profile-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.profile-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.profile-card h3 { font-size: 1.1rem; margin-bottom: 8px; }
.profile-card .meta { color: var(--text-dim); font-size: 0.85rem; }
.profile-card-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.card-btn-row { display: flex; gap: 6px; }
.card-btn-half { flex: 1; text-align: center; }
.card-btn-third { flex: 1; text-align: center; font-size: 0.78rem; padding: 5px 4px; }

/* ── Top Bar ─────────────────────────────────────────────── */
.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 0 16px; height: 48px; flex-shrink: 0; gap: 12px; }
.top-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-bar-left span { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-bar-center { flex: 1; display: flex; justify-content: center; }
.top-bar-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Status Badge */
.status-badge { padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.5px; }
.status-not-started { background: rgba(122,122,153,0.15); color: var(--text-dim); }
.room-status-chip { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px; white-space: nowrap; }
.room-status-chip.needs-reset { background: rgba(231,76,60,0.2); color: #e74c3c; border: 1px solid #e74c3c; }
.room-status-chip.needs-checking { background: rgba(230,126,34,0.2); color: #e67e22; border: 1px solid #e67e22; }
.room-status-chip.ready { background: rgba(39,174,96,0.2); color: #27ae60; border: 1px solid #27ae60; }
.status-in-progress { background: rgba(39,174,96,0.15); color: #2ecc71; }
.status-complete { background: rgba(41,128,185,0.15); color: #3498db; }
.status-expired { background: rgba(192,57,43,0.15); color: var(--red-bright); }

/* ── Guide Layout ────────────────────────────────────────── */
.guide-layout { display: grid; grid-template-columns: 260px 1fr 280px; gap: 12px; padding: 12px; flex: 1; overflow: hidden; height: calc(100vh - 105px); }

.panel-left, .panel-center, .panel-right { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }

/* ── Cards ───────────────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card-header { font-size: 0.75rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-header .sub-label { font-weight: 400; color: var(--accent); letter-spacing: 0; text-transform: none; }

/* ── Timer ───────────────────────────────────────────────── */
.timer-big { font-size: 3.5rem; font-family: 'Courier New', monospace; text-align: center; letter-spacing: 4px; font-weight: bold; padding: 8px 0; color: var(--text); }
.timer-big.paused { color: var(--text-dim); }
.timer-big.urgent { color: var(--red-bright); }
.timer-controls { display: flex; gap: 6px; align-items: center; justify-content: center; margin-bottom: 10px; }
.btn-time { background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; transition: background 0.1s; }
.btn-time:hover { background: var(--accent); border-color: var(--accent); }
.timer-freeform { display: flex; gap: 6px; }
.timer-freeform input { flex: 1; }

/* ── Puzzle Tracker ──────────────────────────────────────── */
.puzzle-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.puzzle-item:last-child { border-bottom: none; }
.puzzle-item.active { background: rgba(233,170,0,0.08); border-radius: 6px; padding: 8px; margin: 0 -8px; border-bottom: none; }
.puzzle-item.selected { background: rgba(233,170,0,0.12); border-radius: 6px; padding: 8px; margin: 0 -8px; border-bottom: none; outline: 1px solid rgba(233,170,0,0.3); }
.puzzle-group-tag { display: inline-block; margin-left: 6px; font-size: 0.68rem; background: rgba(233,170,0,0.15); color: var(--accent); border-radius: 4px; padding: 1px 5px; font-weight: 600; letter-spacing: 0.5px; vertical-align: middle; }
.puzzle-item.done .puzzle-name { color: var(--text-dim); text-decoration: line-through; }
.puzzle-check { width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; accent-color: var(--accent); margin-top: 2px; }
.puzzle-info { flex: 1; min-width: 0; }
.puzzle-name { font-size: 0.9rem; font-weight: 500; }
.puzzle-timer { font-size: 0.78rem; margin-top: 3px; font-family: 'Courier New', monospace; }
.puzzle-timer.ok { color: var(--text-dim); }
.puzzle-timer.warn { color: var(--yellow); }
.puzzle-timer.alert { color: var(--red-bright); font-weight: bold; }

/* ── Hint Suggestion Banner ──────────────────────────────── */
.hint-suggest-banner { background: rgba(230,168,23,0.1); border: 1px solid var(--yellow); border-radius: var(--radius); padding: 12px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.suggest-label { font-size: 0.75rem; font-weight: 700; color: var(--yellow); letter-spacing: 1px; text-transform: uppercase; flex-shrink: 0; }
.suggest-text { flex: 1; font-size: 0.9rem; font-style: italic; color: var(--text); }
.suggest-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Hint Library ─────────────────────────────────────────── */
.hint-lib-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.hint-lib-item:last-child { border-bottom: none; }
.hint-lib-text { flex: 1; font-size: 0.9rem; line-height: 1.4; }
.hint-lib-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

/* ── Hint History ─────────────────────────────────────────── */
.history-list { max-height: 200px; overflow-y: auto; }
.history-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.84rem; }
.history-item:last-child { border-bottom: none; }
.history-time { color: var(--text-dim); font-family: monospace; margin-right: 6px; }

/* ── Queue ────────────────────────────────────────────────── */
.queue-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.queue-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.queue-item:last-child { border-bottom: none; }
.queue-item-text { flex: 1; }

/* ── Session Controls ─────────────────────────────────────── */
.session-input-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 0.88rem; }
.session-input-row input { padding: 4px 8px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.session-buttons { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.btn-win { background: rgba(39,174,96,0.2); border: 1px solid var(--green); color: #2ecc71; padding: 9px 16px; border-radius: 6px; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: background 0.15s; }
.btn-win:hover { background: rgba(39,174,96,0.4); }
.btn-panic { background: rgba(192,57,43,0.2); border: 1px solid var(--red); color: var(--red-bright); padding: 9px 16px; border-radius: var(--radius); cursor: pointer; font-size: 0.88rem; font-weight: 700; letter-spacing: 0.5px; margin-top: 8px; transition: background 0.15s; }
.btn-panic:hover { background: rgba(231,76,60,0.35); }

/* ── Asset List ───────────────────────────────────────────── */
.volume-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 0.85rem; }
.volume-row input[type=range] { flex: 1; }
.asset-list { display: flex; flex-direction: column; gap: 6px; }
.asset-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg3); border-radius: 6px; font-size: 0.84rem; }
.asset-item-stacked { flex-direction: column; align-items: stretch; gap: 4px; }
.asset-item-row1 { display: flex; align-items: center; gap: 6px; }
.asset-item-row1 .asset-item-name { white-space: normal; word-break: break-word; flex: 1; }
.asset-item-row2 { display: flex; align-items: center; gap: 8px; }
.asset-item-row2 .asset-vol { flex: 1; }
.asset-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-vol { width: 80px; }

/* ── Display Controls ─────────────────────────────────────── */
.display-controls { display: flex; flex-direction: column; gap: 8px; }
.display-controls label { font-size: 0.82rem; color: var(--text-dim); }
.display-controls input[type=range] { width: 100%; }

/* ── Buttons (shared) ─────────────────────────────────────── */
.btn-primary { background: var(--accent); border: none; color: #111; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 0.88rem; font-weight: 600; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 0.88rem; transition: background 0.15s; }
.btn-secondary:hover { background: #2e2e42; border-color: var(--accent); }
.btn-icon { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1.1rem; padding: 4px 8px; border-radius: 4px; transition: color 0.1s; }
.btn-icon:hover { color: var(--text); }
.btn-primary.small, .btn-secondary.small { padding: 5px 10px; font-size: 0.8rem; }
.full { width: 100%; text-align: center; }

/* ── Inputs ───────────────────────────────────────────────── */
input[type=text], input[type=number], textarea, select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 8px 10px; font-size: 0.88rem; font-family: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { resize: vertical; }
select { cursor: pointer; }

/* ── Rich Text Toolbar ──────────────────────────────────────── */
.rte-toolbar { display: flex; gap: 4px; margin-bottom: 4px; }
.rte-toolbar-sm .rte-btn { padding: 2px 6px; font-size: 0.75rem; }
.rte-btn { background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 0.82rem; line-height: 1.4; transition: background 0.1s; }
.rte-btn:hover { background: var(--border); }

/* ── Freeform ──────────────────────────────────────────────── */
.freeform-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none !important; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.modal-box { position: relative; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; width: min(700px, 95vw); max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,0.6); }
.modal-box.small { width: min(420px, 95vw); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h2 { font-size: 1.1rem; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { font-size: 0.82rem; color: var(--text-dim); margin-bottom: 4px; display: block; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-shrink: 0; }

/* ── Editor Tabs ──────────────────────────────────────────── */
.editor-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -4px -20px 16px; padding: 0 20px; }
.tab-btn { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-dim); padding: 8px 14px; cursor: pointer; font-size: 0.88rem; transition: color 0.1s; margin-bottom: -1px; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: flex; flex-direction: column; gap: 12px; }
.tab-pane.hidden { display: none; }

/* ── Puzzle Editor ────────────────────────────────────────── */
.puzzle-editor-item { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.puzzle-editor-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.puzzle-editor-header input { flex: 1; }
.hint-editor-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.hint-editor-item { display: flex; gap: 6px; align-items: flex-start; }
.hint-editor-item-full { align-items: flex-start; }
.hint-media-attach { display: flex; align-items: center; gap: 4px; }
.hint-media-badge { font-size: 0.9em; margin-left: 6px; opacity: 0.8; }
.hint-editor-item input[type=text] { font-size: 0.84rem; }
.hint-editor-item input[type=number] { font-size: 0.84rem; }
.puzzles-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* ── Misc ─────────────────────────────────────────────────── */
/* ── Cloud Badge ────────────────────────────────────────────────────────────── */
.cloud-badge { font-size: 0.78rem; padding: 3px 10px; border-radius: 20px; }
.cloud-badge.online { background: rgba(39,174,96,0.15); color: #2ecc71; }
.cloud-badge.offline { background: rgba(122,122,153,0.15); color: var(--text-dim); }

/* ── Private Notes ──────────────────────────────────────────────────────────── */
#private-notes-card { border-left: 3px solid var(--yellow); background: rgba(230,168,23,0.06); }
#private-notes-display { color: #e8d9a0; }

.error-msg { color: var(--red-bright); font-size: 0.85rem; margin-top: 6px; }
.empty-state { color: var(--text-dim); font-size: 0.85rem; font-style: italic; padding: 8px 0; }
.help-text { color: var(--text-dim); font-size: 0.84rem; line-height: 1.5; }
.help-text code { background: var(--bg3); padding: 1px 5px; border-radius: 4px; font-size: 0.82rem; }

/* ── Session Summary ──────────────────────────────────────── */
#session-summary { font-size: 0.92rem; line-height: 1.8; }
#session-summary .outcome { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }

/* ── Scrollbars ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
