:root {
  color-scheme: light;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --inset: #f4f4f7;
  --text: #000000;
  --muted: #707579;
  --line: #dfe1e5;
  --blue: #24a1de;
  --green: #16a34a;
  --gold: #d9a441;
  --danger: #ff595a;
  --success: #34c759;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  overflow-x: hidden;
  min-height: 100vh;
  box-shadow: 0 25px 50px rgba(15, 23, 42, 0.16);
}

.app.login-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.app.login-mode .topbar,
.app.login-mode .bottom-nav {
  display: none;
}

.app.login-mode main {
  width: 100%;
  max-width: 390px;
  padding: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid #f1f5f9;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  backdrop-filter: blur(20px);
}

.brand-row,
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon,
.login-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: linear-gradient(135deg, var(--blue), #38bdf8);
  box-shadow: 0 8px 18px rgba(36, 161, 222, 0.22);
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 12px;
}

.login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
}

p,
label {
  color: var(--muted);
  font-size: 13px;
}

main {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px 16px calc(104px + env(safe-area-inset-bottom));
}

.panel,
.screen-panel {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.section-head,
.login-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

input,
textarea,
button {
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
}

input,
textarea {
  width: 100%;
  background: var(--inset);
  padding: 0 10px;
}

input,
button {
  min-height: 42px;
}

textarea {
  min-height: 86px;
  padding: 10px 14px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  background: #fff;
  outline: none;
}

button {
  padding: 0 12px;
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  font-weight: 700;
}

button:disabled {
  opacity: 0.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--success);
}

.pill.loading::before,
.pill.working::before {
  background: var(--warning);
}

.pill.error::before {
  background: var(--danger);
}

.ghost-button {
  min-height: 32px;
  padding: 0 8px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.create-ideas-prompt {
  display: grid;
  gap: 12px;
}

.create-ideas-prompt h3 {
  margin: 4px 0 0;
  font-size: 17px;
}

.create-ideas-prompt p {
  line-height: 1.45;
}

.create-idea-list {
  display: grid;
  gap: 8px;
}

.create-idea-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  background: #fff;
}

.create-idea-row strong {
  display: block;
  color: #0f172a;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.create-idea-row p {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.create-idea-row button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.review-deck-card {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(36, 161, 222, 0.22);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 14px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.review-deck-card h3 {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.review-hook {
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.review-copy {
  max-height: 240px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: #fff;
  color: #111827;
  font-size: 14px;
  line-height: 1.45;
}

.script-details {
  margin-top: 10px;
}

.script-details summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.script-details .review-copy {
  margin-top: 8px;
}

.review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.review-actions button {
  min-height: 46px;
}

.review-help {
  text-align: center;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.editorial-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.editorial-badges span {
  border: 1px solid #cfe4fb;
  border-radius: 999px;
  background: #eef7ff;
  color: #17659f;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  padding: 5px 8px;
}

.card p {
  line-height: 1.45;
}

.formats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.formats button {
  min-height: 40px;
  background: #111827;
  border-color: #111827;
  font-size: 12px;
}

.formats button.busy {
  position: relative;
  padding-left: 32px;
}

.formats button.busy::before {
  position: absolute;
  left: 12px;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 999px;
  content: "";
  animation: spin 0.8s linear infinite;
}

.formats button.gold {
  background: var(--gold);
  border-color: var(--gold);
}

.formats button.green {
  background: var(--green);
  border-color: var(--green);
}

.formats button.bundle {
  background: var(--blue);
  border-color: var(--blue);
}

.formats button.used,
.formats button.live {
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #64748b;
}

.formats button.live {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.usage-summary {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

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

.login-icon + h2,
.login-icon + h2 + p {
  text-align: center;
}

.login-icon + h2 + p {
  margin: 8px 0 18px;
}

.login-mode .panel {
  padding: 24px;
  border-radius: 16px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  justify-content: space-around;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 0.5px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
}

.nav-item {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  min-height: 52px;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  color: #8e8e93;
}

.nav-item.active {
  color: var(--blue);
}

.nav-label {
  font-size: 10px;
  font-weight: 500;
}

.compact .card {
  padding: 10px;
}

.hidden {
  display: none;
}
