/* ── RESET & VARIABLES ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f0f;
  --surface:   #171717;
  --surface2:  #1e1e1e;
  --border:    #2a2a2a;
  --accent:    #c9a84c;
  --accent2:   #e8c87a;
  --text:      #e8e4dc;
  --muted:     #6b6760;
  --danger:    #c0392b;
  --success:   #2ecc71;
  --radius:    10px;
  --sidebar-w: 220px;
  --font-head: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Mono', 'Courier New', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── GRAIN ── */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.35;
}

/* ── LAYOUT ── */
body { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 0 20px;
}

.main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
  padding: 40px 48px;
}

/* ── SIDEBAR ── */
.sidebar-header {
  padding: 0 22px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.logo {
  display: block;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.sidebar-nav { flex: 1; padding: 0 10px; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  margin-bottom: 4px;
}

.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: rgba(201,168,76,0.12); color: var(--accent); }
.nav-icon { font-size: 14px; }

.sidebar-footer { padding: 16px 18px 0; border-top: 1px solid var(--border); margin-top: 12px; }

.usage-badge {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 8px;
  background: var(--surface2);
  border-radius: 6px;
}

/* ── VIEWS ── */
.view { display: none; animation: fadeUp 0.25s ease; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── HEADERS ── */
.view-header { margin-bottom: 32px; }

.view-header h1 {
  font-family: var(--font-head);
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.view-header .sub { color: var(--muted); font-size: 12.5px; }

/* ── ALERT ── */
.alert {
  background: rgba(192,57,43,0.1);
  border: 1px solid rgba(192,57,43,0.3);
  color: #e07060;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  font-size: 12.5px;
}
.alert a { color: var(--accent); text-decoration: none; }
.alert a:hover { text-decoration: underline; }

/* ── GENERATOR GRID ── */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ── INPUTS ── */
.input-panel, .output-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.textarea {
  width: 100%;
  min-height: 200px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 14px;
  resize: vertical;
  transition: border-color 0.15s;
  outline: none;
  line-height: 1.7;
}
.textarea:focus { border-color: var(--accent); }
.textarea.short { min-height: 90px; }

.input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }

select.input { cursor: pointer; }
select.input option { background: var(--surface2); }

/* ── TONE GRID ── */
.tone-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tone-btn {
  padding: 8px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.tone-btn:hover { border-color: var(--accent); color: var(--text); }
.tone-btn.active {
  background: rgba(201,168,76,0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── BUTTONS ── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: var(--accent);
  color: #0f0f0f;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.slim { margin-top: 8px; max-width: 160px; justify-content: center; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-icon { font-size: 16px; }

.btn-sm {
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* ── OUTPUT PANEL ── */
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.output-actions { display: flex; gap: 8px; }

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
  gap: 12px;
}

.empty-icon { font-size: 28px; opacity: 0.4; }

/* ── LOADER ── */
.loading-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
  color: var(--muted);
}

.loader {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── PROPOSAL OUTPUT ── */
.proposal-output { flex: 1; }

.proposal-text {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.8;
  min-height: 200px;
  outline: none;
  white-space: pre-wrap;
  cursor: text;
  transition: border-color 0.15s;
}
.proposal-text:focus { border-color: var(--accent); }

.proposal-text p { margin-bottom: 12px; }
.proposal-text p:last-child { margin-bottom: 0; }
.proposal-text strong { color: var(--text); font-weight: 600; }
.proposal-text em { font-style: italic; color: var(--accent2); }
.proposal-text ol, .proposal-text ul {
  padding-left: 20px;
  margin: 10px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.proposal-text ol { list-style: decimal; }
.proposal-text ul { list-style: disc; }
.proposal-text li { line-height: 1.7; }

/* ── TIP BOX ── */
.tip-box {
  background: rgba(201,168,76,0.07);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.tip-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.tip-text { font-size: 12.5px; color: var(--muted); }

/* ── FORM CARDS ── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px;
  max-width: 720px;
}

.form-card.narrow { max-width: 440px; }

.form-group { margin-bottom: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hint { color: var(--muted); font-size: 11px; }

.hint-block {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}
.hint-block a { color: var(--accent); text-decoration: none; }
.hint-block a:hover { text-decoration: underline; }

.save-confirm {
  display: inline-block;
  margin-left: 12px;
  font-size: 12px;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
}
.save-confirm.show { opacity: 1; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── RESPONSIVE (basic) ── */
@media (max-width: 900px) {
  .generator-grid { grid-template-columns: 1fr; }
  .main { padding: 24px 20px; overflow-y: auto; }
  body { overflow: auto; }
}

/* ── PAYWALL MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; animation: fadeUp 0.25s ease; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 36px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.modal-badge {
  background: rgba(201,168,76,0.15);
  border: 1px solid rgba(201,168,76,0.3);
  color: var(--accent);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 5px 14px;
  border-radius: 20px;
}

.modal-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.modal-sub { font-size: 13px; color: var(--muted); line-height: 1.6; }

.modal-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.price {
  font-family: var(--font-head);
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
}
.price-period { font-size: 14px; color: var(--muted); }

.modal-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  width: 100%;
  padding: 0 10px;
}
.modal-features li { font-size: 13px; color: var(--text); }
.modal-features li::first-letter { color: var(--accent); }

.btn-upgrade {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #0f0f0f;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  margin-top: 4px;
}
.btn-upgrade:hover { background: var(--accent2); transform: translateY(-1px); }

.btn-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}
.btn-modal-close:hover { color: var(--text); }

/* ── EMAIL SECTION ── */
.email-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.email-input {
  font-size: 11.5px;
  padding: 8px 10px;
}

.btn-email {
  width: 100%;
  padding: 8px;
  background: rgba(201,168,76,0.15);
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-email:hover { background: rgba(201,168,76,0.25); }

.email-hint {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

/* ── APP FOOTER ── */
.app-footer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  padding: 10px 48px;
  display: flex;
  gap: 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}

.app-footer a {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.app-footer a:hover { color: var(--accent); }

/* ── EMAIL SECTION HIGHLIGHTED ── */
.email-section {
  background: rgba(201,168,76,0.05);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: var(--radius);
  padding: 12px;
}

.email-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-bottom: 8px;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 14px 24px;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success {
  background: #1a2e1a;
  border: 1px solid #2ecc71;
  color: #2ecc71;
}

.toast-error {
  background: #2e1a1a;
  border: 1px solid #e07060;
  color: #e07060;
}

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 768px) {
  html, body {
    overflow: auto !important;
    height: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  body { flex-direction: column; }

  /* Sidebar becomes top nav */
  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 0 0;
    flex-direction: column;
    position: relative;
  }

  .sidebar-header {
    padding: 0 16px 12px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
  }

  .logo { font-size: 20px; }
  .logo-sub { display: none; }

  /* Nav buttons horizontal scroll */
  .sidebar-nav {
    display: flex;
    flex-direction: row;
    padding: 8px 12px;
    gap: 8px;
    overflow-x: auto;
  }

  .nav-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 12px;
  }

  /* Email section — full width stacked */
  .sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .email-section {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 0;
    width: 100%;
  }

  .email-input {
    flex: 1;
    min-width: 0;
    font-size: 14px !important;
    padding: 10px 12px;
    height: 40px;
  }

  .btn-email {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 12px;
    height: 40px;
    white-space: nowrap;
  }

  .email-hint { display: none; }

  .usage-badge {
    font-size: 12px;
    padding: 8px;
    text-align: center;
    width: 100%;
  }

  /* Main content full width */
  .main {
    height: auto !important;
    padding: 20px 16px 40px;
    overflow: visible !important;
    width: 100%;
  }

  /* Stack generator grid */
  .generator-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .view-header h1 { font-size: 22px; }
  .view-header .sub { font-size: 12px; }

  /* Panels full width */
  .input-panel, .output-panel {
    padding: 16px;
  }

  /* Textarea readable on mobile */
  .textarea {
    font-size: 14px !important;
    min-height: 150px;
  }

  /* Tone grid 2 columns */
  .tone-grid { grid-template-columns: repeat(2, 1fr); }

  /* Buttons full width */
  .btn-primary { font-size: 14px; padding: 14px; }

  /* Output actions wrap */
  .output-actions { flex-wrap: wrap; gap: 6px; }

  /* Footer inline not fixed */
  .app-footer {
    position: relative;
    left: auto;
    bottom: auto;
    padding: 16px;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
  }

  /* Form rows stack */
  .form-row { grid-template-columns: 1fr; }

  /* Inputs readable */
  .input { font-size: 14px !important; }

  /* Modal full width */
  .modal { width: 95%; padding: 24px 16px; }

  /* Toast full width */
  .toast { width: 90%; max-width: 90%; }
}
