* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --glass-bg: rgba(18, 18, 22, 0.4);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-border-light: rgba(255, 255, 255, 0.3);
  --text: #fff;
  --text-dim: rgba(255, 255, 255, 0.5);
  --text-hint: rgba(255, 255, 255, 0.35);
  --orange: #e8943a;
  --green: #4ade80;
  --blue: #8cb8d9;
  --purple: #bb9af7;
  --red: #f7768e;
  --cyan: #7dcfff;
  --mono: 'SF Mono', 'Menlo', 'Consolas', monospace;
  --system: -apple-system, 'Helvetica Neue', sans-serif;
}

body {
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  padding: 50px 40px 10px;
}

.demo-container {
  position: relative;
  width: 1260px;
  height: 560px;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
}
.demo-container.visible { opacity: 1; transform: scale(1); }

/* ── Rail Label ── */
.rail-label {
  position: absolute; left: -10px; top: -50px; width: 280px;
  text-align: left; opacity: 0; transition: opacity 0.5s ease 0.3s; z-index: 10;
}
.rail-label.visible { opacity: 1; }
.rail-label-title {
  font-family: var(--mono); font-size: 22px; font-weight: 700;
  color: var(--blue); white-space: nowrap; line-height: 1.1; text-transform: lowercase;
}
.rail-label-sub {
  font-family: var(--system); font-size: 13px; color: var(--text-dim);
  margin-top: 4px; white-space: nowrap;
}

/* ── Crystal Rail ── */
.rail {
  position: absolute; left: 0; top: 50%; width: 56px;
  transform: translateY(-50%) translateX(-50px); opacity: 0;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 12px; padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 10;
}
.rail.visible { opacity: 1; transform: translateY(-50%) translateX(0); }

.rail-tile {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  border: 1.5px solid transparent; position: relative; overflow: hidden;
}
.rail-tile.visible { opacity: 1; transform: scale(1); }
.rail-tile.selected { background: rgba(255, 255, 255, 0.08); }
.rail-tile.selected::after {
  content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}
.rail-tile.pulse { overflow: hidden; }
.rail-tile.pulse::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 60%; height: 100%;
  background: linear-gradient(105deg, transparent 20%, rgba(255, 255, 255, 0.35) 45%, rgba(255, 255, 255, 0.1) 55%, transparent 80%);
  animation: shimmer 1.5s ease-in-out infinite; z-index: 2; pointer-events: none;
}
@keyframes shimmer { 0% { left: -100%; } 100% { left: 200%; } }

.rail-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.rail-bottom-btn {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: flex; align-items: center; justify-content: center; cursor: pointer; margin-top: 2px;
}

/* ── Terminal Window ── */
.window {
  position: absolute; left: 340px; top: 0; right: 0; bottom: 0;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
}
.window-header {
  display: flex; align-items: center; justify-content: center;
  padding: 8px 12px 8px; position: relative;
}
.crystl-logo { position: absolute; right: 12px; top: 8px; opacity: 0.6; }

/* Tab bar */
.tab-bar { display: flex; align-items: center; padding: 14px 12px 10px; gap: 2px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); min-height: 46px; }
.tab {
  padding: 6px 12px; font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  border-radius: 6px; cursor: pointer; white-space: nowrap; opacity: 0;
  transition: opacity 0.3s ease, background 0.2s ease; display: flex; align-items: center; gap: 6px;
}
.tab.visible { opacity: 1; }
.tab.active { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.tab .tab-icon, .tab-icon { width: 14px; height: 14px; flex-shrink: 0; }
.tab .close { font-size: 9px; color: var(--text-dim); margin-left: 6px; }
.tab-add { color: var(--text-dim); padding: 6px 8px; cursor: pointer; display: flex; align-items: center; }

/* Shard bar */
.shard-bar { display: flex; align-items: center; padding: 8px 14px; gap: 14px; font-family: var(--mono); font-size: 10px; }
.shard-label { font-family: var(--system); font-size: 10px; font-weight: 500; color: var(--text-dim); letter-spacing: 0.5px; margin-right: 6px; }
.shard-name { color: rgba(186, 214, 237, 0.8); font-size: 11px; padding: 2px 0; border-bottom: 2px solid transparent; }
.shard-name.active { border-bottom-color: rgba(186, 214, 237, 0.6); }
.shard-add, .shard-split { color: var(--text-dim); font-size: 16px; cursor: pointer; display: flex; align-items: center; }
.shard-isolated { margin-left: auto; color: var(--text-dim); font-size: 10px; font-family: var(--system); cursor: pointer; }

/* Terminal content */
.terminal {
  flex: 1; padding: 16px 20px 40px; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.35; color: var(--text); overflow: hidden; position: relative;
}
.terminal .line { min-height: 1.35em; white-space: pre-wrap; word-break: break-all; }
.terminal .cursor { display: inline-block; width: 7px; height: 15px; background: rgba(255, 255, 255, 0.6); vertical-align: text-bottom; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.c-orange { color: var(--orange); }
.c-cyan { color: var(--cyan); }
.c-purple { color: #c084fc; }
.c-dim { color: var(--text-dim); }
.c-green { color: var(--green); }
.c-white { color: var(--text); }
.bold { font-weight: 700; }

/* Facet inserts */
.facet-bar { display: flex; align-items: center; padding: 6px 16px; gap: 8px; }
.facet-pill {
  display: flex; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 6px;
  background: rgba(255, 255, 255, 0.04); overflow: hidden;
}
.facet-btn {
  padding: 4px 12px; border: none; border-right: 1px solid rgba(255, 255, 255, 0.1);
  background: none; font-family: var(--system); font-size: 11px;
  color: var(--text-dim); cursor: pointer; white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.facet-btn:last-child { border-right: none; }
.facet-btn.pressed { background: rgba(140, 184, 217, 0.15); color: var(--blue); }
.facet-gear { color: var(--text-hint); display: flex; align-items: center; cursor: pointer; }

/* Status bar */
.status-bar {
  display: flex; align-items: center; padding: 8px 16px 10px;
  font-family: var(--mono); font-size: 10px; color: var(--text-dim); gap: 8px;
}
.status-bar .mode { color: var(--green); font-weight: 600; }
.status-bar .path-icon { display: flex; align-items: center; opacity: 0.4; }
.status-gem-icon { display: flex; align-items: center; margin-left: auto; opacity: 0.35; }
.status-pill {
  display: flex; background: rgba(255, 255, 255, 0.1); border-radius: 6px; overflow: hidden;
}
.status-pill .gem-settings {
  margin-left: 0; background: none; padding: 3px 12px;
  border-radius: 0; font-family: var(--system); font-size: 11px; color: var(--text-dim); cursor: pointer;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.status-pill .gem-settings:last-child { border-right: none; }

/* ── Floating Panels ── */
.panel {
  position: absolute; background: var(--glass-bg); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px; font-family: var(--system); opacity: 0;
  transform: translateY(-10px) scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.panel.visible { opacity: 1; transform: translateY(0) scale(1); }
.panel.dismiss { opacity: 0; transform: translateY(-10px) scale(0.96); }
.panel-open { margin-left: auto; font-size: 9px; font-weight: 400; color: rgba(255, 255, 255, 0.3); font-family: var(--system); }

/* Approval panel */
.approval-panel { width: 240px; padding: 12px; left: 72px; z-index: 20; }
.approval-panel .project-name { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.approval-panel .tool-name { font-size: 10px; font-weight: 500; color: rgba(255, 180, 120, 0.8); margin-bottom: 6px; }
.approval-panel .detail { font-family: var(--mono); font-size: 9px; color: var(--text-dim); margin-bottom: 12px; line-height: 1.4; max-height: 2.8em; overflow: hidden; }
.approval-panel .buttons { display: flex; gap: 3px; }
.approval-panel .btn {
  flex: 1; padding: 4px 0; border-radius: 6px; border: none;
  font-family: var(--system); font-size: 11px; font-weight: 600;
  cursor: pointer; text-align: center; transition: background 0.15s ease;
}
.btn-deny { background: rgba(255, 255, 255, 0.1); color: var(--text-dim); }
.btn-always { background: rgba(140, 184, 217, 0.15); color: var(--blue); }
.btn-allow { background: rgba(74, 222, 128, 0.3); color: var(--green); }
.btn-allow.pressed { background: rgba(74, 222, 128, 0.5); }

/* Notification panel */
.notif-panel { width: 240px; padding: 12px; left: 72px; z-index: 20; }
.notif-panel .headline { font-size: 10px; font-weight: 500; color: rgba(120, 180, 230, 0.8); margin-bottom: 3px; }
.notif-panel .subtitle { font-family: var(--mono); font-size: 9px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.4; }
.notif-panel .btn-dismiss {
  width: 100%; padding: 4px 0; border-radius: 6px; border: none;
  background: rgba(255, 255, 255, 0.1); color: var(--text-dim);
  font-family: var(--system); font-size: 12px; font-weight: 500;
  cursor: pointer; text-align: center; transition: background 0.15s ease;
}
.btn-dismiss.pressed { background: rgba(255, 255, 255, 0.3); }

/* Flyout menu */
.flyout {
  position: absolute; left: 72px; top: 50%; transform: translateY(-50%);
  width: 210px; z-index: 20; background: var(--glass-bg);
  border: 1px solid var(--glass-border-light); border-radius: 12px; padding: 12px 8px;
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.flyout.visible { opacity: 1; transform: translateY(-50%); }
.flyout-header { font-family: var(--system); font-size: 9px; font-weight: 700; color: rgba(255, 255, 255, 0.8); text-align: center; letter-spacing: 0.5px; margin-bottom: 8px; }
.flyout-item {
  padding: 6px 10px; border-radius: 6px; font-family: var(--system); font-size: 12px;
  color: var(--text-dim); cursor: pointer; transition: background 0.2s ease, color 0.2s ease; margin-bottom: 2px;
}
.flyout-item.active { background: rgba(255, 255, 255, 0.12); color: var(--text); }

/* New Project panel */
.new-project-panel {
  position: absolute; left: 72px; bottom: 20px; z-index: 20; width: 240px;
  background: var(--glass-bg); border: 1px solid var(--glass-border-light);
  border-radius: 12px; padding: 12px; opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.new-project-panel.visible { opacity: 1; }
.new-project-panel .panel-title { font-family: var(--system); font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.new-project-panel label {
  font-family: var(--system); font-size: 9px; font-weight: 600;
  color: rgba(255, 255, 255, 0.7); letter-spacing: 0.5px; text-transform: uppercase; display: block; margin-bottom: 4px;
}
.new-project-panel .field {
  width: 100%; padding: 6px 10px; background: rgba(255, 255, 255, 0.12); border: none;
  border-radius: 8px; font-family: var(--mono); font-size: 12px; color: var(--text); margin-bottom: 12px;
}
.color-grid { display: flex; gap: 6px; margin-bottom: 12px; }
.color-swatch { width: 18px; height: 18px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s ease; }
.color-swatch.selected { border-color: var(--text); }
.icon-grid { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.icon-item {
  width: 22px; height: 22px; border-radius: 6px; background: rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s ease;
}
.icon-item.selected { border-color: var(--text); background: rgba(255, 255, 255, 0.15); }
.np-checkbox {
  display: flex; align-items: center; gap: 6px; font-family: var(--system); font-size: 10px;
  color: var(--text-dim); margin-bottom: 10px; text-transform: none; letter-spacing: 0; font-weight: 400; white-space: nowrap;
}
.np-check-box {
  width: 14px; height: 14px; min-width: 14px; border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.08);
  display: flex; align-items: center; justify-content: center; font-size: 9px; color: var(--green); line-height: 1;
}
.btn-create {
  width: 100%; padding: 6px 0; border-radius: 6px; border: none;
  background: rgba(74, 222, 128, 0.3); color: var(--green);
  font-family: var(--system); font-size: 11px; font-weight: 600;
  cursor: pointer; text-align: center; transition: background 0.15s ease;
}
.btn-create.pressed { background: rgba(74, 222, 128, 0.6); }

/* ── Question Series Panel ── */
.question-panel {
  position: absolute; left: 72px; top: 80px; width: 240px; z-index: 20;
  background: var(--glass-bg); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px; overflow: hidden;
  opacity: 0; transform: translateY(-10px) scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.question-panel.visible { opacity: 1; transform: translateY(0) scale(1); }
.question-panel.dismiss { opacity: 0; transform: translateY(-10px) scale(0.96); }

.qp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(187, 154, 247, 0.2), rgba(140, 184, 217, 0.1));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.qp-header-left { display: flex; align-items: center; gap: 8px; }
.qp-header-icon { display: flex; align-items: center; }
.qp-project { font-family: var(--system); font-size: 12px; font-weight: 600; color: var(--text); }
.qp-show { font-family: var(--system); font-size: 9px; color: rgba(255,255,255,0.3); }
.qp-category { font-family: var(--system); font-size: 11px; font-weight: 700; color: var(--purple); padding: 6px 14px 2px; }
.qp-question { font-family: var(--system); font-size: 12px; color: var(--text); padding: 4px 14px 8px; line-height: 1.4; }

.qp-options { padding: 0 14px 8px; }
.qp-option {
  padding: 4px 10px; border-radius: 6px; font-family: var(--mono); font-size: 11px;
  color: var(--text-dim); margin-bottom: 3px; line-height: 1.4;
}

.qp-dots { display: flex; justify-content: center; align-items: center; gap: 6px; padding: 6px 14px; }
.qp-arrow { font-family: var(--system); font-size: 12px; color: var(--text-hint); cursor: pointer; }
.qp-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); transition: background 0.3s ease; }
.qp-dot.active { background: var(--purple); }
.qp-dot.done { background: rgba(187, 154, 247, 0.5); }

.qp-input-row {
  display: flex; align-items: center; gap: 4px; padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.qp-input {
  flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px; padding: 5px 8px; font-family: var(--mono); font-size: 10px; color: var(--text);
}
.qp-send {
  padding: 5px 10px; border-radius: 6px; border: none; flex-shrink: 0;
  background: rgba(187, 154, 247, 0.3); color: var(--purple);
  font-family: var(--system); font-size: 10px; font-weight: 600;
  cursor: pointer; transition: background 0.15s ease;
}
.qp-send.submit { background: rgba(187, 154, 247, 0.5); }
.qp-send.pressed { background: rgba(187, 154, 247, 0.6); }
.qp-skip { font-family: var(--system); font-size: 10px; color: var(--text-hint); cursor: pointer; padding: 4px 14px 10px; }

/* Replay button */
.replay-btn {
  position: absolute; top: -38px; right: 0; z-index: 30;
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transition: opacity 0.3s ease, background 0.15s ease;
  pointer-events: none;
}
.replay-btn.visible { opacity: 1; pointer-events: auto; }
.replay-btn:hover { background: rgba(255, 255, 255, 0.12); }
.replay-btn svg { transition: transform 0.3s ease; }
.replay-btn:hover svg { transform: rotate(-45deg); }

/* ── Screenshot Bar ── */
.ss-bar {
  height: 0; overflow: hidden; border-top: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; padding: 0 16px; gap: 10px;
  transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1), padding 0.4s ease;
}
.ss-bar.visible { height: 56px; padding: 6px 16px; }
.ss-strip { display: flex; gap: 6px; flex: 1; overflow: hidden; align-items: center; }
.ss-thumb {
  width: 42px; height: 42px; border-radius: 5px; flex-shrink: 0;
  border: 0.5px solid rgba(255,255,255,0.15); overflow: hidden;
  opacity: 0; transform: scale(0.8);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}
.ss-thumb.visible { opacity: 1; transform: scale(1); }
.ss-thumb.hover { border-color: rgba(255,255,255,0.4); box-shadow: 0 0 8px rgba(140,184,217,0.3); }
.ss-thumb.dragging { opacity: 0.4; transform: scale(0.9); }
.ss-close { font-size: 12px; color: var(--text-dim); cursor: pointer; font-weight: 300; flex-shrink: 0; }
.ss-inner { width: 100%; height: 100%; position: relative; }
.ss-hbar { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: rgba(255,255,255,0.08); display: flex; align-items: center; padding: 0 2px; gap: 1px; }
.ss-dot { width: 1.5px; height: 1.5px; border-radius: 50%; }
.ss-ln { height: 1.5px; border-radius: 1px; position: absolute; }
.ss-blk { border-radius: 1px; position: absolute; }
.ss-ghost {
  position: absolute; width: 42px; height: 42px; border-radius: 5px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.3); box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; z-index: 30; transition: none;
}
.ss-ghost.visible { opacity: 0.9; }

/* ── Mobile ── */
@media (max-width: 700px) {
  body { padding: 30px 10px 20px; }
  .demo-container { width: 100%; height: auto; min-height: 400px; justify-content: flex-start; }
  .window { display: none; }
  .rail-label { display: block; left: 10px; top: -25px; }
  .rail { position: relative; transform: none; top: auto; left: 10px; height: auto; }
  .rail.visible { transform: none; }
  .approval-panel, .notif-panel, .new-project-panel { left: 72px; }
}
