/* ============================================================
   UGC University — Script Generator
   Editorial call-sheet: paper, ink, hairlines. No gradients.
   ============================================================ */
:root {
  --paper: #F6F2E9;
  --paper-deep: #EFE9DC;
  --ink: #141046;
  --ink-70: rgba(20, 16, 70, 0.7);
  --ink-45: rgba(20, 16, 70, 0.45);
  --hairline: rgba(20, 16, 70, 0.18);
  --hairline-soft: rgba(20, 16, 70, 0.10);
  --gold: #A88216;
  --stamp: #C24A2A;
  --white: #FDFCF8;

  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Schibsted Grotesk', system-ui, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, monospace;
}

* , *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- Masthead ---------------- */
.masthead {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1.5px solid var(--ink);
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 50;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.masthead-dept {
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-45);
}

.masthead-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.usage-chip {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  color: var(--ink-70);
  white-space: nowrap;
}

.usage-chip.unlimited { border-color: var(--gold); color: var(--gold); }

.account-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: uppercase;
}

.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
  z-index: 60;
}

.account-email {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-70);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline-soft);
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-menu button {
  background: none;
  border: none;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 0;
  color: var(--ink);
}

.account-menu button:hover { color: var(--gold); }

/* ---------------- Landing ---------------- */
.landing { flex: 1; display: flex; flex-direction: column; }

.landing-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 60px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 72px 28px 64px;
  align-items: center;
  flex: 1;
}

.kicker {
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--stamp);
  margin-bottom: 18px;
}

.landing-copy h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.9rem, 6vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.landing-copy h1 em { font-style: italic; color: var(--gold); }

.lede {
  margin-top: 22px;
  font-size: 1.0625rem;
  color: var(--ink-70);
  max-width: 46ch;
}

.landing-points {
  list-style: none;
  margin-top: 34px;
  border-top: 1px solid var(--hairline);
}

.landing-points li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.9375rem;
  font-weight: 500;
}

.landing-points span {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-45);
}

/* Auth card */
.auth-card {
  background: var(--white);
  border: 1.5px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 30px 28px;
}

.auth-title {
  font-family: var(--serif);
  font-size: 1.45rem;
  margin-bottom: 20px;
}

.auth-provider {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px;
  margin-bottom: 10px;
  background: var(--white);
  border: 1.5px solid var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.auth-provider:hover {
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0 var(--ink);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--ink-45);
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

#magicForm { display: flex; flex-direction: column; gap: 10px; }

input, textarea {
  font-family: var(--sans);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--hairline);
  padding: 12px 14px;
  width: 100%;
  transition: border-color 0.15s ease;
}

input::placeholder, textarea::placeholder { color: var(--ink-45); }

input:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.btn-ink {
  background: var(--ink);
  color: var(--paper);
  border: 1.5px solid var(--ink);
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 13px 22px;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-ink:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0 rgba(20, 16, 70, 0.35);
}

.btn-ink:disabled { opacity: 0.6; cursor: wait; }

.auth-status {
  margin-top: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gold);
  min-height: 1.3em;
}

.auth-fineprint {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-45);
  letter-spacing: 0.04em;
}

/* Marquee strip */
.landing-strip {
  border-top: 1.5px solid var(--ink);
  padding: 12px 0;
  display: flex;
  gap: 26px;
  justify-content: center;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--ink-45);
  overflow: hidden;
  white-space: nowrap;
}

/* ---------------- Workspace ---------------- */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 380px 1fr;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}

.brief {
  border-right: 1px solid var(--hairline);
  padding: 30px 26px 40px;
}

.panel-label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--ink-45);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--ink);
}

.f { margin-bottom: 14px; }

.f label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.f label b { color: var(--stamp); font-weight: 700; }

.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.len-row { display: flex; gap: 8px; flex-wrap: wrap; }

.len-row label { cursor: pointer; }

.len-row input { position: absolute; opacity: 0; width: 0; height: 0; }

.len-row span {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8125rem;
  padding: 7px 13px;
  border: 1.5px solid var(--hairline);
  color: var(--ink-70);
  transition: all 0.12s ease;
  user-select: none;
}

.len-row input:checked + span {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.len-row label:hover span { border-color: var(--ink); }

.extras {
  margin: 6px 0 14px;
  border: 1px solid var(--hairline);
}

.extras summary {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 11px 14px;
  cursor: pointer;
  color: var(--ink-70);
  list-style: none;
}

.extras summary::before { content: "+ "; font-family: var(--mono); }
.extras[open] summary::before { content: "− "; }
.extras summary::-webkit-details-marker { display: none; }

.extras .f { padding: 0 14px; }
.extras .f:last-child { padding-bottom: 14px; }

.btn-generate { width: 100%; padding: 15px; font-size: 1rem; }

.quota-note {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  color: var(--ink-45);
  text-align: center;
  min-height: 1.2em;
}

.history { margin-top: 36px; }

.history-list { list-style: none; }

.history-list li button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline-soft);
  padding: 10px 2px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  font-size: 0.875rem;
  color: var(--ink);
}

.history-list li button:hover { background: var(--paper-deep); }

.history-list .h-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.history-list .h-date {
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-45);
  white-space: nowrap;
}

.history-empty {
  font-size: 0.8125rem;
  color: var(--ink-45);
  padding: 8px 2px;
}

/* ---------------- Stage / output ---------------- */
.stage { padding: 30px 34px 60px; min-width: 0; }

.stage-empty {
  height: 100%;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink-45);
  font-size: 0.9375rem;
  border: 1px dashed var(--hairline);
}

.stage-empty-mark {
  font-family: var(--serif);
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 12px;
  color: var(--hairline);
}

.stage-loading {
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  border: 1px solid var(--hairline);
}

.typebar { display: flex; gap: 6px; }

.typebar span {
  width: 8px;
  height: 8px;
  background: var(--ink);
  animation: typeblink 1.1s infinite;
}

.typebar span:nth-child(2) { animation-delay: 0.18s; }
.typebar span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typeblink {
  0%, 70%, 100% { opacity: 0.18; }
  35% { opacity: 1; }
}

#loadingLine {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.06em;
  color: var(--ink-70);
}

.script-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1.5px solid var(--ink);
}

.script-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.1;
}

.script-meta {
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-45);
  margin-top: 6px;
}

.script-actions { display: flex; gap: 10px; }

.btn-line {
  background: none;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.8125rem;
  padding: 9px 16px;
  transition: all 0.12s ease;
}

.btn-line:hover { background: var(--ink); color: var(--paper); }

/* The call sheet */
.sheet { display: flex; flex-direction: column; }

.sheet-row {
  display: grid;
  grid-template-columns: 130px 1.3fr 1fr 1fr;
  gap: 0;
  border-bottom: 1px solid var(--hairline);
}

.sheet-row.head {
  border-bottom: 1.5px solid var(--ink);
  position: sticky;
  top: 61px;
  background: var(--paper);
  z-index: 5;
}

.sheet-row.head > div {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink);
  padding: 10px 14px 8px 0;
}

.sheet-row > div {
  padding: 14px 14px 14px 0;
  font-size: 0.9063rem;
  min-width: 0;
  overflow-wrap: break-word;
}

.sheet-row > div + div { padding-left: 14px; border-left: 1px solid var(--hairline-soft); }

.cell-timing {
  font-family: var(--mono);
  font-size: 0.75rem !important;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.cell-dialogue { font-weight: 500; }

.cell-opts { color: var(--ink-70); font-size: 0.8438rem !important; }

.cell-opts .opt {
  display: block;
  padding: 2px 0;
}

.cell-opts .opt::before {
  content: attr(data-n) " ";
  font-family: var(--mono);
  font-size: 0.625rem;
  color: var(--ink-45);
}

/* ---------------- Paywall ---------------- */
.paywall-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 70, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.paywall {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  max-width: 460px;
  width: 100%;
  padding: 38px 36px 30px;
  text-align: left;
}

.paywall h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.2rem;
  line-height: 1.05;
  margin-bottom: 14px;
}

.paywall-lede { color: var(--ink-70); font-size: 0.9688rem; }

.paywall-points {
  list-style: none;
  margin: 20px 0 26px;
  border-top: 1px solid var(--hairline);
}

.paywall-points li {
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.9375rem;
  font-weight: 500;
}

.paywall-points li::before {
  content: "→ ";
  font-family: var(--mono);
  color: var(--gold);
}

.btn-wide { width: 100%; padding: 15px; font-size: 1rem; }

.plan-buttons { display: flex; flex-direction: column; gap: 10px; }

.plan-tag {
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-light, #D4B642);
  background: rgba(212, 182, 66, 0.16);
  padding: 3px 8px;
  border-radius: 3px;
  margin-left: 8px;
}

.paywall-close {
  display: block;
  margin: 14px auto 0;
  background: none;
  border: none;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-45);
  text-decoration: underline;
}

/* ---------------- Colophon ---------------- */
.colophon {
  border-top: 1.5px solid var(--ink);
  padding: 16px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-45);
}

.colophon nav { display: flex; gap: 20px; }

.colophon a:hover { color: var(--ink); }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 12px 22px;
  border: 1.5px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(20, 16, 70, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 300;
  max-width: min(92vw, 460px);
  text-align: center;
}

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

/* ---------------- Responsive ---------------- */
@media (max-width: 960px) {
  .landing-grid { grid-template-columns: 1fr; gap: 44px; padding-top: 48px; }
  .workspace { grid-template-columns: 1fr; }
  .brief { border-right: none; border-bottom: 1px solid var(--hairline); }
  .sheet-row { grid-template-columns: 96px 1fr; }
  .sheet-row > div:nth-child(3),
  .sheet-row > div:nth-child(4) { grid-column: 2; border-left: none; padding-left: 0; padding-top: 0; }
  .sheet-row > .cell-opts::before {
    content: attr(data-label);
    display: block;
    font-family: var(--mono);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--ink-45);
    margin: 8px 0 2px;
  }
  .sheet-row.head > div:nth-child(3),
  .sheet-row.head > div:nth-child(4) { display: none; }
  .sheet-row > div { padding-bottom: 8px; }
  .sheet-row { padding-bottom: 10px; }
  .masthead { padding: 14px 18px; }
  .masthead-dept { display: none; }
  .stage { padding: 24px 18px 48px; }
}

/* Native Google sign-in overlay: the invisible official GIS button sits on
   top of our styled button so clicks trigger Google's popup flow. */
.g-wrap { position: relative; }
#gisMount {
  position: absolute;
  inset: 0 0 10px 0; /* googleBtn has 10px margin-bottom */
  opacity: 0.0001;
  overflow: hidden;
  z-index: 2;
}
#gisMount > div { width: 100% !important; height: 100% !important; }
