/* ==========================================================================
   Let Me ChatGPT That For You — styles
   Tokens first, then generic components, then the two views.
   ========================================================================== */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --bg-2: #f7f7f8;
  --bg-3: #ececf1;
  --bg-4: #dcdce3;
  --text: #0d0d0d;
  --text-2: #5f5f66;
  --text-3: #8e8e9a;
  --border: #e3e3e8;
  --border-2: #cfcfd8;

  --accent: #6d5dfc;
  --accent-2: #b05cff;
  --accent-hover: #5a4ae6;
  --accent-soft: rgba(109, 93, 252, 0.14);
  --on-accent: #ffffff;
  --warning: #b86b00;

  --send-bg: #0d0d0d;
  --send-fg: #ffffff;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 12px 40px rgba(16, 16, 32, 0.08);
  --shadow-sm: 0 2px 10px rgba(16, 16, 32, 0.06);
  --ring: 0 0 0 3px var(--accent-soft);

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f0f10;
  --bg-2: #181819;
  --bg-3: #232326;
  --bg-4: #303035;
  --text: #ececec;
  --text-2: #b4b4bc;
  --text-3: #85858f;
  --border: #2a2a2e;
  --border-2: #3b3b42;

  --accent: #8f82ff;
  --accent-2: #c48bff;
  --accent-hover: #a59bff;
  --accent-soft: rgba(143, 130, 255, 0.2);
  --warning: #e0a04a;

  --send-bg: #ececec;
  --send-fg: #0f0f10;

  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.4);

  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
p { margin: 0 0 1em; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--accent); color: var(--on-accent); padding: 8px 12px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }
.noscript {
  max-width: 640px; margin: 48px auto; padding: 20px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--border-2); background: var(--bg); color: var(--text);
  font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--bg-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-small { padding: 7px 14px; font-size: 14px; }
.btn.is-done { background: var(--bg-3); border-color: var(--border-2); color: var(--text); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; }

.theme-toggle svg { display: none; }
.theme-toggle[data-pref="system"] .icon-auto,
.theme-toggle[data-pref="light"] .icon-light,
.theme-toggle[data-pref="dark"] .icon-dark { display: block; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200;
  transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   View 1 — Generator
   ========================================================================== */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1100px; margin: 0 auto; padding: 14px clamp(16px, 4vw, 32px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand b { color: var(--accent); }
.site-nav { display: flex; align-items: center; gap: 6px; }

.container { max-width: 760px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px) 64px; }

.hero { text-align: center; padding: clamp(24px, 6vw, 56px) 0 28px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 14px; }
.hero h1 b {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--text-2); font-size: clamp(16px, 2.2vw, 19px); max-width: 560px; margin: 0 auto; }

.card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(18px, 3vw, 28px);
}

.field-label { display: block; font-weight: 600; margin-bottom: 8px; }
textarea {
  display: block; width: 100%; padding: 14px 16px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--text); line-height: 1.5;
  resize: vertical; min-height: 96px;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--bg); }
.field-meta { display: flex; justify-content: flex-end; color: var(--text-3); font-size: 13px; margin-top: 6px; }

.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; color: var(--text-3); font-size: 14px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text-2);
  border-radius: 999px; padding: 6px 12px; font-size: 13px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.result-empty { margin: 22px 0 0; color: var(--text-3); text-align: center; }
.result { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-row input {
  flex: 1 1 240px; min-width: 0; padding: 11px 16px;
  border: 1px solid var(--border-2); border-radius: 999px; background: var(--bg-2);
  font-family: var(--mono); font-size: 14px; color: var(--text-2);
}
.link-row input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.warning { color: var(--warning); font-size: 14px; margin: 10px 0 0; }
.muted { color: var(--text-3); font-size: 14px; margin: 10px 0 0; }

@media (max-width: 480px) { .brand span { font-size: 14px; } }

.site-footer {
  border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; line-height: 1.7;
  text-align: center; padding: 22px clamp(16px, 4vw, 32px);
}
.site-footer p { max-width: 720px; margin: 0 auto 6px; }
.site-footer a { color: var(--text-2); }

/* ==========================================================================
   View 2 — Player (the fake chat)
   ========================================================================== */
.player {
  display: flex; height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg);
}

.sidebar {
  width: 260px; flex: 0 0 260px; display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-2); border-right: 1px solid var(--border); padding: 12px;
  user-select: none;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.sidebar-top img { width: 28px; height: 28px; border-radius: 7px; }
.sidebar-close { display: none; }
.side-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text); font-size: 14px; }
.side-item svg { width: 18px; height: 18px; color: var(--text-2); }
.side-item:hover { background: var(--bg-3); }
.side-section { color: var(--text-3); font-size: 12px; font-weight: 600; padding: 16px 10px 6px; }
.side-history { color: var(--text-2); font-size: 14px; padding: 8px 10px; border-radius: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-history:hover { background: var(--bg-3); }
.sidebar-bottom { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; font-size: 14px; }
.avatar-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.sidebar-backdrop { display: none; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; }
.header-left, .header-right { display: flex; align-items: center; gap: 4px; }
.chat-header .menu { display: none; }
.model-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; font-weight: 600; font-size: 17px; color: var(--text); }
.model-chip svg { width: 16px; height: 16px; color: var(--text-3); }
.skip { font-size: 13px; color: var(--text-3); padding: 8px 10px; border-radius: 8px; }
.skip:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 16px; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.chat-inner { width: 100%; max-width: 768px; margin: 0 auto; padding: 12px 0; }
.player.state-empty .chat-main { justify-content: center; }
.player.state-empty .chat-scroll { flex: 0 1 auto; }
.chat-empty { text-align: center; padding: 0 0 22px; }
.chat-empty h2 { font-size: clamp(24px, 3.5vw, 30px); font-weight: 600; letter-spacing: -0.02em; margin: 0; }

.messages { display: flex; flex-direction: column; gap: 24px; }
.msg { display: flex; gap: 14px; }
.msg-user { justify-content: flex-end; }
.bubble {
  background: var(--bg-3); border-radius: 20px; padding: 10px 18px; max-width: 75%;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.msg-assistant .avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; margin-top: 2px; }
.msg-assistant .content { flex: 1; min-width: 0; padding-top: 4px; }

.typing-dots { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); animation: bounce 1.2s infinite ease-in-out; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.composer-wrap { width: 100%; max-width: 768px; margin: 0 auto; padding: 8px 0 10px; }
.composer {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 28px;
  padding: 12px 12px 10px 18px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.composer.focused { border-color: var(--border-2); box-shadow: var(--shadow); }
.composer-input {
  min-height: 26px; max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 16px; color: var(--text);
}
.composer-input .placeholder { color: var(--text-3); }
.caret {
  display: inline-block; width: 1.5px; height: 1.1em; margin-left: 1px;
  background: var(--text); vertical-align: -0.2em; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.composer-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.composer-tools { display: flex; gap: 4px; }
.composer-tools .icon-btn { width: 34px; height: 34px; border-radius: 50%; }
.send-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--send-bg); color: var(--send-fg);
  display: inline-flex; align-items: center; justify-content: center;
  opacity: .35; transition: opacity .15s, transform .1s;
}
.send-btn.active { opacity: 1; }
.send-btn.pressed { transform: scale(.88); }
.send-btn svg { width: 18px; height: 18px; }
.composer-note { text-align: center; font-size: 12px; color: var(--text-3); margin: 10px 0 0; }

/* Fake pointer. Its transform is set from JS; the arrow tip sits at the element's top-left. */
.fake-cursor {
  position: fixed; left: 0; top: 0; width: 28px; height: 28px; z-index: 60;
  pointer-events: none; opacity: 0;
  transition: transform .9s cubic-bezier(.25, .8, .25, 1), opacity .3s;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
}
.fake-cursor.visible { opacity: 1; }
.fake-cursor svg { width: 100%; height: 100%; transform-origin: 15% 12%; }
.fake-cursor.click svg { animation: cursor-click .22s ease; }
@keyframes cursor-click { 50% { transform: scale(.82); } }
.fake-cursor .ripple {
  position: absolute; left: 4px; top: 3px; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0; transform: translate(-50%, -50%) scale(.3);
}
.fake-cursor.click .ripple { animation: ripple .45s ease-out; }
@keyframes ripple {
  0% { opacity: .9; transform: translate(-50%, -50%) scale(.3); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); }
}

/* Mobile: sidebar becomes a drawer */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: none;
  }
  .player.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .sidebar-close { display: inline-flex; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .player.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .chat-header .menu { display: inline-flex; }
  .bubble { max-width: 88%; }
  .chat-main { padding: 0 10px; }
  .skip { padding: 8px 6px; }
}
@media (max-width: 420px) {
  .model-chip { font-size: 16px; padding: 8px 6px; }
  .composer { padding: 10px 10px 8px 14px; }
}

/* Respect reduced-motion: the JS also skips the choreography entirely. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
