:root {
  --bg: #0a0a0e;
  --bg-2: #111116;
  --bg-3: #1a1a22;
  --line: #28283a;
  --text: #e8e4f0;
  --muted: #7a7590;
  --accent: #e05577;
  --accent-2: #a63355;
  --accent-glow: rgba(224, 85, 119, 0.15);
  --danger: #d86c6c;
  --ok: #74c58a;
  --warn: #e0a555;
  --casual: #74c58a;
  --unhinged: #e0a555;
  --lawyer: #5599e0;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(900px 400px at 20% 0%, rgba(224, 85, 119, 0.07), transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(85, 153, 224, 0.04), transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  width: 100%;
  max-width: 1100px;
  min-height: 100vh;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

/* sidebar */
.sidebar {
  padding: 32px 22px;
  background: linear-gradient(180deg, #0d0c10 0%, #14131a 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.logo {
  font-size: 52px;
  margin: 0 0 6px;
  filter: drop-shadow(0 2px 8px rgba(224, 85, 119, 0.3));
}
.brand {
  margin: 0 0 4px;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.5px;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.tagline {
  margin: 0 0 22px;
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

.tiers-info {
  width: 100%;
  text-align: left;
  margin: 0 0 auto;
}
.tiers-info h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin: 0 0 10px;
}
.tier-desc {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}
.tier-desc:last-child { border-bottom: none; }
.tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.tier-dot.casual { background: var(--casual); }
.tier-dot.unhinged { background: var(--unhinged); }
.tier-dot.lawyer { background: var(--lawyer); }
.tier-label {
  font-weight: 600;
  display: block;
}
.tier-price {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.footer-note {
  margin: 18px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.footer-note a { color: var(--accent); text-decoration: none; }
.footer-note a:hover { text-decoration: underline; }

/* main panel */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-2);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px currentColor;
}
.dot.thinking { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.dot.error { background: var(--danger); }
.dot.ok { background: var(--ok); }

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

.auth-actions { display: flex; gap: 8px; align-items: center; }

.btn-login {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-2);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: lowercase;
  font-family: inherit;
}
.btn-login:hover:not(:disabled) { background: var(--accent-glow); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-login.ghost {
  color: var(--muted);
  border-color: var(--line);
}
.btn-login.ghost:hover { color: var(--text); border-color: var(--accent-2); }

.notice {
  margin: 0;
  padding: 10px 18px;
  font-size: 12px;
  line-height: 1.4;
  background: var(--accent-glow);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.notice.ok { background: rgba(116, 197, 138, 0.08); color: var(--ok); }
.notice.warn { background: rgba(224, 165, 85, 0.10); color: var(--warn); }
.notice.error { background: rgba(216, 108, 108, 0.10); color: var(--danger); }

/* content area */
.content {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* form */
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

textarea.situation {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
  min-height: 100px;
  max-height: 240px;
}
textarea.situation:focus { border-color: var(--accent-2); }

.quick-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-fields select {
  width: 100%;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7590' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.quick-fields select:focus { border-color: var(--accent-2); }

/* tier selector */
.tier-selector {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.tier-card {
  position: relative;
  background: var(--bg-3);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 16px 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.tier-card:hover { border-color: var(--muted); }
.tier-card.selected { box-shadow: 0 0 20px var(--accent-glow); }
.tier-card.selected.casual { border-color: var(--casual); }
.tier-card.selected.unhinged { border-color: var(--unhinged); }
.tier-card.selected.lawyer { border-color: var(--lawyer); }

.tier-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tier-icon { font-size: 28px; margin: 0 0 6px; display: block; }
.tier-name {
  font-weight: 700;
  font-size: 14px;
  display: block;
  margin: 0 0 4px;
}
.tier-card.casual .tier-name { color: var(--casual); }
.tier-card.unhinged .tier-name { color: var(--unhinged); }
.tier-card.lawyer .tier-name { color: var(--lawyer); }

.tier-cost {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}
.tier-cost.free { color: var(--casual); }

/* generate button */
.btn-generate {
  width: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  border: none;
  padding: 14px 22px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: filter 0.15s, transform 0.1s;
  text-transform: lowercase;
}
.btn-generate:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-generate:active:not(:disabled) { transform: translateY(0); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

/* output */
.output-area {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.output-area.hidden { display: none; }

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
}
.output-header span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}
.btn-copy {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-2);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-copy:hover { background: var(--accent-glow); }
.btn-copy.copied {
  background: rgba(116, 197, 138, 0.12);
  color: var(--ok);
  border-color: var(--ok);
}

.output-body {
  padding: 18px 18px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 60px;
  color: var(--text);
}

/* responsive */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    padding: 16px;
    position: static;
    max-height: none;
    flex-direction: row;
    gap: 14px;
    text-align: left;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .logo { font-size: 36px; margin: 0; }
  .brand { font-size: 20px; }
  .tagline { margin: 0; font-size: 11px; }
  .tiers-info { display: none; }
  .footer-note { display: none; }
  .main { height: auto; min-height: calc(100vh - 100px); }
  .quick-fields { grid-template-columns: 1fr; }
  .tier-selector { grid-template-columns: 1fr; }
}
