:root {
  color-scheme: light;
  --blue: #0b6bff;
  --blue-dark: #064cc2;
  --ink: #10213a;
  --muted: #61728a;
  --bg: #f3f7fd;
  --surface: #ffffff;
  --line: #d8e3f3;
  --danger: #c8323d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .83rem; line-height: 1.45; }
.eyebrow { margin: 0 0 .35rem; font-weight: 800; font-size: .74rem; letter-spacing: .12em; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 540px); }
.brand-panel { padding: clamp(2rem, 7vw, 7rem); display: flex; flex-direction: column; justify-content: center; color: #fff; background: radial-gradient(circle at 20% 15%, #37baff 0, transparent 30%), linear-gradient(145deg, #0b6bff 0%, #0738c4 50%, #04145e 100%); }
.brand-icon { width: 108px; height: 108px; border-radius: 25%; box-shadow: 0 24px 70px rgba(0,0,0,.25); margin-bottom: 2rem; }
.brand-panel h1 { font-size: clamp(3.2rem, 8vw, 6.8rem); margin: 0; line-height: .95; }
.brand-panel .lead { font-size: clamp(1.1rem, 2vw, 1.5rem); opacity: .9; max-width: 34rem; }
.promise-list { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .9rem; color: #dfeeff; }
.promise-list li::before { content: "✓"; display: inline-grid; place-items: center; width: 1.45rem; height: 1.45rem; margin-right: .7rem; border-radius: 50%; background: rgba(255,255,255,.18); font-weight: 900; }
.auth-card { align-self: center; margin: clamp(1.2rem, 4vw, 4rem); padding: clamp(1.4rem, 4vw, 3rem); background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 28px 90px rgba(16,33,58,.13); }
.auth-card.narrow { width: min(520px, calc(100vw - 2rem)); margin: 2rem auto; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 1.8rem; background: #eaf2ff; border-radius: 14px; }
.segmented button { border: 0; border-radius: 11px; padding: .8rem; color: var(--muted); background: transparent; font-weight: 750; }
.segmented button.active { background: #fff; color: var(--blue); box-shadow: 0 4px 18px rgba(11,107,255,.12); }
label { display: grid; gap: .45rem; margin-bottom: 1.1rem; font-size: .9rem; font-weight: 750; }
input, textarea { width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 13px; padding: .85rem 1rem; outline: none; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11,107,255,.13); }
.consent { grid-template-columns: auto 1fr; align-items: start; gap: .65rem; font-size: .82rem; line-height: 1.4; font-weight: 550; }
.consent input { width: auto; margin: .2rem 0 0; }
.primary, .secondary, .quiet, .danger { border-radius: 13px; min-height: 44px; padding: .7rem 1.1rem; font-weight: 780; border: 1px solid transparent; }
.primary { background: var(--blue); color: #fff; box-shadow: 0 9px 25px rgba(11,107,255,.24); }
.primary:hover { background: #075ee8; }
.secondary { background: #eaf2ff; color: var(--blue); border-color: #cfe0ff; }
.quiet { background: #fff; color: var(--ink); border-color: var(--line); }
.danger { background: #fff0f1; color: var(--danger); border-color: #f2c5ca; }
.wide { width: 100%; }
.link-button { border: 0; background: transparent; color: var(--blue); padding: 1rem 0; font-weight: 700; }
.single-layout { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 50% -10%, #d7ecff, transparent 42%); }
.reset-icon { width: 72px; height: 72px; border-radius: 20px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: .7rem clamp(1rem, 5vw, 4rem); color: #fff; background: linear-gradient(100deg, #075ee8, #063ab4); box-shadow: 0 5px 24px rgba(6,76,194,.22); }
.topbar-brand { display: flex; align-items: center; gap: .75rem; font-size: 1.2rem; font-weight: 900; letter-spacing: .04em; }
.topbar-brand img { width: 42px; height: 42px; border-radius: 12px; }
.topbar-actions { display: flex; align-items: center; gap: .8rem; }
.topbar .quiet { min-height: 38px; color: #fff; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.24); }
.account-email { font-size: .9rem; color: #dceaff; }
.workspace { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2.5rem 0 4rem; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: clamp(1.4rem, 4vw, 2.5rem); color: #fff; border-radius: 28px; background: radial-gradient(circle at 90% 0%, #35baff 0, transparent 33%), linear-gradient(130deg, #0b6bff, #073ebf 65%, #081f71); box-shadow: 0 25px 65px rgba(7,62,191,.23); }
.hero h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); }
.hero p:not(.eyebrow) { margin-bottom: 0; color: #dceaff; }
.hero-actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: end; min-width: max-content; }
.hero .secondary { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3); }
.hero .primary { background: #fff; color: var(--blue); }
.library-tools { display: flex; gap: .8rem; margin: 1.6rem 0 1rem; }
.library-tools input { max-width: 520px; }
.subscription-card { margin: 1.6rem 0 0; padding: 22px; border: 1px solid #cfe0ff; border-radius: 22px; background: linear-gradient(135deg, #eef5ff, #fff); box-shadow: 0 10px 30px rgba(16,33,58,.06); }
.subscription-main { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.subscription-main h2 { margin: 4px 0 8px; font-size: clamp(20px, 3vw, 28px); }
.subscription-status { margin: 0 0 6px; font-weight: 700; }
.payment-history { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.payment-history summary { cursor: pointer; font-weight: 700; }
.payments-list { display: grid; gap: 9px; margin-top: 12px; }
.payment-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: #f3f7fd; }
.payment-row strong, .payment-row small { display: block; }
.payment-row small { margin-top: 3px; color: var(--muted); }
.payment-state { padding: 5px 9px; border-radius: 999px; background: #eaf2ff; color: var(--blue); font-size: 12px; font-weight: 800; }
.payment-state.canceled, .payment-state.failed { background: #fff0f1; color: var(--danger); }
.document-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.document-card { text-align: left; min-height: 165px; padding: 1.25rem; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); background: #fff; box-shadow: 0 10px 30px rgba(16,33,58,.06); transition: transform .15s ease, box-shadow .15s ease; }
.document-card:hover { transform: translateY(-2px); box-shadow: 0 17px 38px rgba(16,33,58,.1); }
.document-card h3 { margin: .8rem 0 .45rem; font-size: 1.05rem; }
.document-card p { margin: 0; color: var(--muted); font-size: .84rem; }
.doc-badge { display: inline-flex; padding: .35rem .55rem; border-radius: 8px; color: var(--blue); background: #eaf2ff; font-size: .72rem; font-weight: 900; }
.empty { grid-column: 1 / -1; padding: 3rem; text-align: center; border: 1px dashed #b9cbe4; border-radius: 20px; color: var(--muted); background: rgba(255,255,255,.55); }

.editor-shell { min-height: calc(100vh - 68px); }
.editor-top { position: sticky; top: 68px; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: rgba(243,247,253,.94); backdrop-filter: blur(16px); }
.editor-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: end; }
.save-status { color: var(--muted); font-size: .86rem; }
.paper-wrap { width: min(900px, calc(100% - 2rem)); margin: 2rem auto 5rem; padding: clamp(1.2rem, 5vw, 4rem); border: 1px solid var(--line); background: #fff; box-shadow: 0 25px 75px rgba(16,33,58,.12); }
.document-title { padding: .25rem 0 .7rem; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 850; }
.document-title:focus { box-shadow: none; }
.editor-hint { margin: 1rem 0; padding: .75rem 1rem; color: var(--muted); background: #f3f7fd; border-radius: 10px; font-size: .82rem; }
#document-editor { min-height: 62vh; padding: 1rem 0; resize: vertical; border: 0; border-radius: 0; line-height: 1.65; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; }
#document-editor:focus { box-shadow: none; }
.pdf-frame { width: 100%; min-height: 72vh; margin-top: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #eef3f9; }
.sessions-list { display: grid; gap: .7rem; margin: 1.2rem 0; }
.session-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: 13px; }
.session-row strong, .session-row small { display: block; }
.session-row small { margin-top: .25rem; color: var(--muted); }

dialog { width: min(500px, calc(100vw - 2rem)); padding: 1.6rem; border: 1px solid var(--line); border-radius: 22px; color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(3,17,41,.58); backdrop-filter: blur(4px); }
.dialog-actions { display: flex; justify-content: end; gap: .7rem; }
.toast { position: fixed; left: 50%; bottom: 1.4rem; z-index: 20; max-width: min(620px, calc(100vw - 2rem)); padding: .9rem 1.15rem; color: #fff; background: #10213a; border-radius: 13px; box-shadow: 0 12px 38px rgba(0,0,0,.25); transform: translate(-50%, 140%); transition: transform .2s ease; }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: #992631; }

@media (max-width: 800px) {
  .auth-layout { grid-template-columns: 1fr; }
  .brand-panel { min-height: 38vh; padding: 2rem 1.5rem; }
  .brand-icon { width: 78px; height: 78px; margin-bottom: 1rem; }
  .brand-panel h1 { font-size: 3.5rem; }
  .promise-list { display: none; }
  .auth-card { margin: -1.7rem 1rem 1rem; position: relative; }
  .hero { align-items: stretch; flex-direction: column; }
  .hero-actions { justify-content: stretch; min-width: 0; }
  .hero-actions button { flex: 1 1 170px; }
  .subscription-main { align-items: stretch; flex-direction: column; }
  .account-email { display: none; }
  .editor-top { align-items: stretch; flex-direction: column; }
  .editor-actions { justify-content: stretch; }
  .editor-actions button { flex: 1 1 130px; }
  .save-status { width: 100%; }
}
