:root {
  --bg: #2b2d30;
  --ink: #f3f1ea;
  --muted: #b7b4aa;
  --card: #35373b;
  --line: #4a4d53;
  --accent: #4ea2ff;
  --accent-ink: #101114;
  --warn: #ff7a6e;
  --ok: #6ee7b7;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Outfit, "Segoe UI", sans-serif;
  font-weight: 300;
  color: var(--ink);
  background: var(--bg);
}
button, input, textarea, a {
  font-family: Outfit, "Segoe UI", sans-serif;
  font-weight: 400;
}
h1, h2 { margin: 0 0 0.4rem; letter-spacing: -0.02em; font-weight: 400; }
p { color: var(--muted); line-height: 1.45; }
.lead { margin: 1.1rem 0 1.4rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 2rem;
}
.login-card { width: min(440px, 100%); }
.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: #2b2d30;
}

.logo {
  display: inline-flex;
  text-decoration: none;
  font-weight: 400;
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  letter-spacing: -0.04em;
  line-height: 1;
  gap: 0.02em;
}
.logo span:nth-child(1) { color: #ff5c7a; }
.logo span:nth-child(2) { color: #ffb020; }
.logo span:nth-child(3) { color: #ffe14a; }
.logo span:nth-child(4) { color: #5ee0a0; }
.logo span:nth-child(5) { color: #3ec6ff; }
.logo span:nth-child(6) { color: #6b8cff; }
.logo span:nth-child(7) { color: #c084fc; }
.logo span:nth-child(8) { color: #ff7ad9; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
  margin-bottom: 0.9rem;
  color: var(--ink);
}
input, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  background: #1f2124;
  color: var(--ink);
}
textarea { resize: vertical; width: 100%; }
button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-small {
  padding: 0.42rem 0.85rem;
  font-size: 0.86rem;
  border-radius: 999px;
}
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.8rem;
  font-size: 0.86rem;
}
.error { color: var(--warn); }

.page-atelier { min-height: 100vh; background: #2b2d30; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.4rem;
  border-bottom: 1px solid #3c3f44;
  background: #2b2d30;
}
.topbar-right {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  flex-wrap: wrap;
}
.student-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.student-name {
  margin: 0;
  color: #f6f3ea;
  font-size: 1.05rem;
  font-weight: 400;
  white-space: nowrap;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #d8d4cc;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.timer {
  font-family: "Bebas Neue", Impact, sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 2.35rem;
  letter-spacing: 0.06em;
  color: #fff7e8;
  background: none;
  border: 0;
  padding: 0;
  min-width: 0;
  line-height: 1;
}
.timer.urgent { color: #ff7a6e; }

.templates, .studio { padding: 1.2rem 1.4rem 1.6rem; }
.templates h2, .templates p { color: var(--ink); }
.templates p { color: var(--muted); }
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}
.template-card {
  text-align: left;
  border-radius: 18px;
  padding: 1rem;
  background: #35373b;
  color: var(--ink);
  border: 1px solid var(--line);
}
.template-card small { display: block; color: var(--muted); margin-top: 0.35rem; font-weight: 400; }

.studio {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  height: calc(100vh - 88px);
  max-height: calc(100vh - 88px);
  overflow: hidden;
}
.prompt-panel, .preview-panel {
  background: #35373b;
  border: 1px solid var(--line);
  border-radius: 20px;
  min-height: 0;
  overflow: hidden;
}
.prompt-panel {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  height: 100%;
}
.prompt-panel label { color: var(--ink); }
.prompt-panel textarea {
  flex: 0 0 auto;
  max-height: 180px;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; flex: 0 0 auto; }
.coach {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  font-size: 0.84rem;
  font-weight: 400;
  line-height: 1.35;
  color: #1f2124;
}
.coach.praise { background: #8ee4b8; }
.coach.tip { background: #ffe08a; }
.coach.warning { background: #ffb4a8; }
.log {
  flex: 1 1 auto;
  margin: 0;
  background: #1b1d20;
  color: #d7e4ff;
  border-radius: 14px;
  padding: 0.8rem;
  min-height: 140px;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: #7a7e86 transparent;
}
.log::-webkit-scrollbar {
  width: 6px;
}
.log::-webkit-scrollbar-track {
  background: transparent;
}
.log::-webkit-scrollbar-thumb {
  background: #7a7e86;
  border-radius: 99px;
}
.preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 3px solid #ffffff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.preview-panel.working {
  animation: preview-pulse 0.9s ease-in-out infinite;
}
@keyframes preview-pulse {
  0%, 100% {
    border-color: #ffb020;
    box-shadow: 0 0 0 1px #ff7a18, inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  }
  50% {
    border-color: #ff7a18;
    box-shadow: 0 0 16px #ffb020, inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  }
}
iframe {
  border: 0;
  width: 100%;
  flex: 1;
  background: white;
  min-height: 480px;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 12, 0.62);
  display: grid;
  place-items: center;
  padding: 1rem;
  cursor: pointer;
}
.overlay .card {
  cursor: default;
  max-width: 420px;
}
.overlay .card p,
.overlay .card a { color: var(--ink); font-weight: 300; }
.overlay .card button { margin-top: 0.6rem; }
.overlay[hidden], [hidden] { display: none !important; }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
