/* ── App Page ──────────────────────────────────────────── */

.app-layout {
  display: grid;
  grid-template-columns: 268px 1fr;
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.75rem 2rem;
  gap: 1.75rem;
  align-items: start;
  min-height: calc(100vh - 66px - 80px);
}

/* ── Sidebar ───────────────────────────────────────────── */
.app-sidebar {
  background: var(--navy);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: sticky;
  top: 82px;
  box-shadow: var(--shadow-navy);
}

.sidebar-logo-band {
  display: flex; align-items: center; gap: .65rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-icon { width: 32px; height: 32px; }
.sidebar-brand {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: #fff;
  letter-spacing: -.01em;
}

.sidebar-section {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-label {
  font-family: var(--font-ui); font-size: .66rem; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.45); margin-bottom: .7rem;
}
.sidebar-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: .7rem; }
.sidebar-label-row .sidebar-label { margin-bottom: 0; }
.sidebar-export-row { display: flex; gap: .2rem; }
.sbar-btn { color: rgba(255,255,255,.55) !important; }
.sbar-btn:hover { color: #fff !important; }

.sidebar-plan-card { display: flex; flex-direction: column; gap: .7rem; }
.splan-row { display: flex; align-items: center; justify-content: space-between; }
.splan-upgrade-link {
  font-family: var(--font-ui); font-size: .75rem; font-weight: 500;
  color: var(--orange-light); text-decoration: none;
  transition: color .15s;
}
.splan-upgrade-link:hover { color: var(--orange); }
.splan-upgrade-link.hidden { display: none; }

.splan-meter-label {
  font-family: var(--font-ui); font-size: .76rem;
  color: rgba(255,255,255,.6); margin-bottom: .35rem;
}
.splan-meter-bar {
  height: 5px; border-radius: 10px;
  background: rgba(255,255,255,.12); overflow: hidden;
}
.splan-meter-fill {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, var(--orange-dark), var(--orange));
  transition: width .5s ease;
}

.sidebar-hint { font-size: .8rem; color: rgba(255,255,255,.5); font-style: italic; line-height: 1.55; }

.sbar-weekly-btn {
  width: 100%; justify-content: center; margin-top: .6rem;
  background: transparent; border-color: rgba(255,255,255,.25);
  color: rgba(255,255,255,.8) !important;
}
.sbar-weekly-btn:hover { border-color: var(--orange); color: var(--orange-light) !important; }

.sbar-clear-btn {
  width: 100%; justify-content: center; margin-top: .4rem;
  color: rgba(255,255,255,.35) !important; font-size: .76rem;
}
.sbar-clear-btn:hover { color: rgba(255,100,100,.8) !important; }

/* History list */
.history-list {
  display: flex; flex-direction: column; gap: .4rem;
  max-height: 280px; overflow-y: auto;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-track { background: rgba(255,255,255,.05); }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.history-item {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-sm); padding: .6rem .75rem;
  cursor: pointer; transition: background .15s;
}
.history-item:hover { background: rgba(255,255,255,.13); }
.history-genre {
  font-family: var(--font-ui); font-size: .65rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--orange-light); margin-bottom: .2rem;
}
.history-snippet {
  font-size: .78rem; color: rgba(255,255,255,.65); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.sidebar-auth-nudge { text-align: center; }

/* ── Main ──────────────────────────────────────────────── */
.app-main { display: flex; flex-direction: column; gap: 1.5rem; }

#ad-banner a { color: var(--orange-dark); font-weight: 500; }

/* Generator card */
.app-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.app-card-stripe {
  height: 4px;
  background: linear-gradient(90deg, var(--navy-dark), var(--navy), var(--orange), var(--orange-light));
}
.app-card-body { padding: 2rem; }

.app-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.app-card-icon { width: 52px; height: 52px; opacity: .75; }
.app-title { font-size: 1.75rem; font-weight: 700; color: var(--navy); margin-top: .2rem; }
.app-subtitle { font-size: .88rem; color: var(--muted); font-style: italic; margin-top: .25rem; }

/* Form */
.app-form { display: flex; flex-direction: column; gap: .85rem; margin-bottom: 1.5rem; }
.select-wrap { position: relative; }
.select-wrap .field-input { appearance: none; -webkit-appearance: none; padding-right: 2.5rem; cursor: pointer; }
.select-arrow { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); font-size: .85rem; }

.pro-gate-pill {
  font-size: .64rem; font-family: var(--font-ui); font-weight: 600;
  background: rgba(90,26,138,.1); color: #5a1a8a;
  border: 1px solid rgba(90,26,138,.25); padding: .1rem .45rem;
  border-radius: 20px; vertical-align: middle; margin-left: .35rem;
  letter-spacing: .04em;
}

.generate-btn {
  font-size: .97rem; padding: .82rem 1.75rem;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.generate-arrow { display: inline-block; transition: transform .18s; }
.generate-btn:not(:disabled):hover .generate-arrow { transform: translateX(4px); }

/* Result area */
.result-area {
  min-height: 130px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--parchment);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: border-color .3s, border-style .3s, background .3s;
}
.result-area.has-output {
  border-style: solid; border-color: var(--orange);
  background: var(--white);
}

.result-idle { text-align: center; padding: 2rem; color: var(--muted); }
.result-idle p { font-size: .85rem; font-style: italic; margin-top: .75rem; }
.idle-orbs { display: flex; gap: 7px; justify-content: center; }
.idle-orbs span {
  width: 8px; height: 8px; border-radius: 50%;
  animation: orbPulse 1.6s ease-in-out infinite;
}
.idle-orbs span:nth-child(1) { background: var(--navy-light); animation-delay: 0s; }
.idle-orbs span:nth-child(2) { background: var(--orange); animation-delay: .2s; }
.idle-orbs span:nth-child(3) { background: var(--navy-light); animation-delay: .4s; }
@keyframes orbPulse { 0%,80%,100%{transform:scale(.8);opacity:.4} 40%{transform:scale(1.3);opacity:1} }

.result-loading { text-align: center; padding: 2.5rem; color: var(--muted); }
.result-loading p { font-size: .85rem; font-style: italic; margin-top: 1rem; }
.loading-ring {
  width: 40px; height: 40px; margin: 0 auto;
  border: 3px solid var(--border-strong);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spinRing .75s linear infinite;
}

.result-output { padding: 1.5rem; width: 100%; animation: fadeUp .35s ease; }
.output-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: .5rem; flex-wrap: wrap; }
.output-genre-pill {
  font-family: var(--font-ui); font-size: .7rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  padding: .2rem .7rem;
  background: rgba(27,46,94,.08); color: var(--navy);
  border: 1px solid var(--border-strong); border-radius: 20px;
}
.output-actions { display: flex; gap: .25rem; }
.output-actions .btn { color: var(--muted); }
.output-actions .btn:hover { color: var(--ink); }
.output-prompt {
  font-family: var(--font-display); font-size: 1.1rem; font-style: italic;
  color: var(--ink); line-height: 1.75;
  border: none; padding: 0; margin-bottom: .6rem;
  quotes: '\201C' '\201D';
}
.output-prompt::before { content: open-quote; }
.output-prompt::after  { content: close-quote; }
.output-meta { font-family: var(--font-ui); font-size: .74rem; color: var(--muted); font-style: italic; }

.result-error { text-align: center; padding: 1.75rem; color: var(--error); width: 100%; }
.result-error-icon { font-size: 1.5rem; display: block; margin-bottom: .5rem; }
.result-error p { font-size: .88rem; line-height: 1.55; }

/* Weekly card */
.weekly-card {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm);
  animation: fadeUp .4s ease;
}
.weekly-stripe { height: 3px; background: linear-gradient(90deg, var(--navy), var(--orange)); }
.weekly-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem .75rem; flex-wrap: wrap; gap: .75rem;
}
.weekly-actions { display: flex; gap: .4rem; align-items: center; }

.weekly-table { width: 100%; border-collapse: collapse; }
.weekly-table thead th {
  background: var(--navy); color: rgba(255,255,255,.85);
  font-family: var(--font-ui); font-size: .72rem; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  padding: .65rem 1.25rem; text-align: left;
}
.weekly-table thead th:first-child { width: 170px; }
.weekly-table tbody tr:nth-child(even) { background: var(--parchment); }
.weekly-table tbody tr:hover { background: var(--parchment-2); }
.weekly-table tbody td {
  padding: .9rem 1.25rem; vertical-align: top;
  border-bottom: 1px solid var(--border);
  font-size: .88rem; line-height: 1.6; color: var(--ink-soft);
}
.weekly-table tbody tr:last-child td { border-bottom: none; }
.weekly-genre-tag {
  font-family: var(--font-ui); font-size: .72rem; font-weight: 600;
  padding: .18rem .6rem;
  background: rgba(27,46,94,.08); color: var(--navy);
  border: 1px solid var(--border-strong); border-radius: 20px; white-space: nowrap;
}

.app-attr {
  font-family: var(--font-body); font-style: italic;
  font-size: .8rem; color: var(--muted); text-align: center; padding: .25rem 0 .75rem;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; padding: 1rem; }
  .app-sidebar { position: static; }
}
@media (max-width: 480px) {
  .app-card-body { padding: 1.25rem; }
  .weekly-header { flex-direction: column; align-items: flex-start; }
}
