:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e2e2df;
  --text: #1a1a1a;
  --text-muted: #6e6e6b;
  --ink: #111111;
  --ink-soft: #2b2b2b;
  --risk-low: #2f6f4f;
  --risk-medium: #8a6d1f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.screen { min-height: 100vh; }

/* ---------- Login ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#login-screen[hidden] { display: none; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand { text-align: center; margin-bottom: 8px; }

.brand-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.brand-mark.small { width: 32px; height: 32px; font-size: 12px; margin: 0; }

.brand h1 { font-size: 19px; margin: 0 0 4px; }
.subtitle { color: var(--text-muted); font-size: 13px; margin: 0; }

label { font-size: 13px; font-weight: 600; color: var(--text); }

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fbfbfa;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
  background: #fff;
}

button {
  cursor: pointer;
  font-family: inherit;
}

#login-btn, .btn-primary {
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
  width: 100%;
  margin-top: 20px;
}

#login-btn:hover, .btn-primary:hover { background: var(--ink-soft); }

.error-text {
  color: #7a2727;
  font-size: 13px;
  background: #faf1f1;
  border: 1px solid #e6cccc;
  padding: 8px 10px;
  border-radius: 8px;
  margin: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-weight: 700; font-size: 15px; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.btn-ghost:hover { background: #f0f0ee; border-color: var(--ink); }

/* ---------- Tabs ---------- */
.tabbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tabbar-inner {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 10px 0;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover { background: #f0f0ee; color: var(--text); }

.tab-btn.active {
  background: var(--ink);
  color: #fff;
}

/* ---------- View transitions ---------- */
.view {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.view.view-visible {
  opacity: 1;
  transform: translateY(0);
}

.field-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.creative-output {
  margin-top: 22px;
  padding: 18px 20px;
  background: #f7f7f5;
  border: 1px dashed var(--border);
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
}

.creative-output .field-label { margin: 0 0 6px; }

/* ---------- Main ---------- */
.main {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 24px;
}

.panel h2 { margin: 0 0 6px; font-size: 18px; }
.panel-hint { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }

.generate-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { min-width: 160px; }

#generate-btn {
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.15s;
}

#generate-btn:hover { background: var(--ink-soft); }
#generate-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.spinner[hidden] { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Sliders ---------- */
.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slider-value {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  background: #f0f0ee;
  padding: 2px 9px;
  border-radius: 999px;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: #e6e6e2;
  appearance: none;
  -webkit-appearance: none;
  margin: 10px 0 2px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

.slider-hint {
  margin: -4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Results ---------- */
.results-block { margin-bottom: 28px; }
.results-block:last-child { margin-bottom: 0; }
.results-block h2 { margin: 0 0 12px; font-size: 17px; }

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.item-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.copy-btn {
  flex-shrink: 0;
  background: #f0f0ee;
  color: var(--ink);
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s;
}

.copy-btn:hover { background: #e4e4e0; }
.copy-btn.copied { background: #e4efe6; color: var(--risk-low); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 32px; margin-bottom: 10px; opacity: 0.6; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 200;
}

@media (max-width: 560px) {
  .field-row { flex-direction: column; }
  .topbar { padding: 12px 16px; }
  .panel { padding: 20px; }
  .item-row { flex-direction: column; align-items: stretch; }
  .copy-btn { align-self: flex-start; }
}
