:root {
  --ink: #17212b;
  --ink-soft: #344454;
  --green: #0076bb;
  --green-dark: #005e96;
  --mint: #eaf5fc;
  --lime: #d6edfc;
  --cream: #f4f6f8;
  --paper: #ffffff;
  --line: #dce2e8;
  --muted: #596775;
  --danger: #ad352d;
  --warning: #fff3cf;
  --shadow: 0 4px 20px rgba(18, 38, 58, .04);
}

* { box-sizing: border-box; }
html { background: var(--cream); }
body { margin: 0; color: var(--ink); background: var(--cream); font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button, a, select, label[for] { -webkit-tap-highlight-color: transparent; }
summary:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(0, 118, 187, .35); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.topbar, main, footer { width: min(1000px, calc(100% - 40px)); margin-inline: auto; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; letter-spacing: -.025em; }
.brand-icon { display: block; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.language-label { position: absolute; overflow: hidden; width: 1px; height: 1px; }
select { min-height: 40px; padding: 0 30px 0 11px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 9px; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font: 750 clamp(36px, 5vw, 62px)/1.08 ui-sans-serif, system-ui, sans-serif; letter-spacing: -.05em; }
h2 { margin-bottom: 10px; font-size: 22px; line-height: 1.2; letter-spacing: -.03em; }
h3 { margin-bottom: 12px; font-size: 18px; }
.eyebrow, .step { margin-bottom: 12px; color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.compact-copy { margin-bottom: 18px; }

.auth-view { min-height: calc(100vh - 150px); display: grid; grid-template-columns: 1.35fr .68fr; align-items: center; gap: clamp(50px, 8vw, 120px); padding: 55px 0 90px; }
.hero-copy { max-width: 650px; color: var(--muted); font-size: clamp(18px, 2vw, 22px); }
.trust-line { max-width: 620px; margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; gap: 13px; color: var(--muted); }
.trust-line span { color: var(--green); }
.trust-line p { margin-bottom: 0; }

.card { background: var(--paper); border: 1px solid rgba(18,38,58,.10); border-radius: 14px; box-shadow: var(--shadow); }
.auth-card { padding: 28px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 26px; padding: 4px; background: #edf1f5; border-radius: 10px; }
.tab { min-height: 42px; border: 0; color: var(--muted); background: transparent; border-radius: 7px; cursor: pointer; }
.tab.active { color: var(--ink); background: var(--paper); box-shadow: 0 2px 8px rgba(18,38,58,.06); font-weight: 650; }
label { display: grid; gap: 7px; margin-bottom: 17px; font-size: 13px; font-weight: 750; }
input, textarea { width: 100%; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 10px; }
input { min-height: 47px; padding: 0 13px; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(0,118,187,.12); outline: none; }
.hint { margin: -7px 0 18px; color: var(--muted); font-size: 12px; }
.form-message { min-height: 20px; margin: 12px 0 0; font-size: 13px; }
.error { color: var(--danger); }

.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; padding: 9px 16px; font-weight: 650; text-decoration: none; cursor: pointer; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary, .button.ghost-border { color: var(--ink); background: transparent; border-color: var(--line); }
.button.ghost { min-height: 38px; color: var(--muted); background: transparent; }
.button.danger { color: var(--danger); background: transparent; border-color: #e4b6b0; }
.wide { width: 100%; }

.dashboard { padding: 28px 0 64px; }
.dashboard-title { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 36px; }
.dashboard-title h1 { max-width: 700px; font-size: clamp(30px, 4vw, 44px); }
.connection-card { min-width: 270px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 15px 16px; color: var(--ink); text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.connection-card strong, .connection-card small { display: block; }
.connection-card small { margin-top: 2px; color: var(--muted); }
.status-dot { width: 11px; height: 11px; background: #9d9d96; border-radius: 50%; box-shadow: 0 0 0 5px rgba(100,100,100,.1); }
.connection-card.connected .status-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(0,118,187,.12); }
.connection-card.attention .status-dot { background: #c98200; box-shadow: 0 0 0 5px rgba(201,130,0,.12); }

.section-tabs { display: flex; gap: 4px; margin-bottom: 20px; padding: 4px; width: fit-content; background: #e7edf2; border-radius: 11px; overflow-x: auto; }
.section-tab { min-height: 40px; padding: 7px 16px; border: 0; color: var(--muted); background: transparent; border-radius: 8px; white-space: nowrap; cursor: pointer; }
.section-tab.active { color: var(--ink); background: var(--paper); font-weight: 650; }
.editor-card, .history-card, .guide-intro, .guide-card, .automation-card { padding: 27px; }
.card-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.file-picker { display: block; margin: 0; padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; white-space: nowrap; }
.file-picker { position: relative; color: var(--green); background: var(--mint); border-color: transparent; min-height: 46px; }
.file-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-picker:focus-within { outline: 3px solid var(--green); outline-offset: 3px; }
textarea { min-height: 210px; padding: 15px; resize: vertical; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.editor-actions { display: flex; align-items: center; gap: 9px; margin-top: 14px; }
.action-spacer { flex: 1; }
.result { margin-top: 16px; padding: 15px; background: var(--mint); border-radius: 10px; }
.result.error-result { color: #7d2620; background: #fae4e1; }
.validation-list { margin: 8px 0 0; padding-left: 20px; }
.history-card { margin-top: 20px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); color: var(--ink); background: transparent; border-radius: 9px; font-size: 20px; cursor: pointer; }
.history-list { display: grid; }
.history-row { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 20px; padding: 15px 0; border-top: 1px solid var(--line); }
.history-row span { color: var(--muted); font-size: 13px; }
.history-main strong, .history-main small { display: block; }
.history-main strong { color: var(--ink); font-size: 15px; }
.history-detail { grid-column: 1 / -1; margin: -12px 0 0; color: var(--muted); font-size: 13px; }
.history-detail.error { color: var(--danger); }
.status-pill { width: fit-content; padding: 3px 8px; background: var(--mint); border-radius: 99px; }
.status-pill.failed { color: var(--danger); background: #fae4e1; }

.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; }
.guide-intro, .guide-wide { grid-column: 1 / -1; }
.guide-intro { background: var(--ink); color: white; }
.guide-intro .muted { color: #c6d6e4; }
.guide-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.guide-intro .button.secondary { color: white; border-color: #697e90; }
pre { overflow-x: auto; margin: 15px 0; padding: 15px; color: #e4edf5; background: #17212b; border-radius: 10px; font: 12px/1.55 ui-monospace, monospace; }
.checklist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 30px; margin-bottom: 0; padding-left: 20px; }
.automation-grid, .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.secret-result { margin-top: 15px; padding: 14px; word-break: break-all; background: var(--warning); border-radius: 9px; font-family: ui-monospace, monospace; }
.key-list { display: grid; margin-top: 16px; }
.key-row { display: flex; justify-content: space-between; gap: 15px; padding: 13px 0; border-top: 1px solid var(--line); }
.key-row small { display: block; color: var(--muted); }
.key-row button { border: 0; color: var(--danger); background: transparent; cursor: pointer; }
.workflow { padding-left: 22px; }
.connector-heading { margin-top: 22px; font-size: 15px; }
#connector-url { font-family: ui-monospace, monospace; font-size: 13px; }
.workflow li { margin-bottom: 9px; }
.text-link { color: var(--green); font-weight: 650; }
.danger-zone { border-color: #e4b6b0; }

dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100vh - 30px); overflow-y: auto; padding: 27px; color: var(--ink); background: var(--paper); border: 0; border-radius: 14px; box-shadow: 0 24px 90px rgba(12,30,24,.3); }
dialog::backdrop { background: rgba(10,30,24,.62); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; justify-content: space-between; gap: 15px; }
.notice { margin-bottom: 20px; padding: 14px; border-radius: 10px; }
.notice p { margin: 5px 0 0; }
.warning { background: var(--warning); }
.consent { grid-template-columns: auto 1fr; align-items: start; font-weight: 500; }
.consent input { width: 19px; min-height: 19px; margin-top: 2px; }
.connected-badge { display: flex; align-items: center; gap: 13px; margin-bottom: 18px; padding: 15px; background: var(--mint); border-radius: 10px; }
.connected-badge > span { display: grid; place-items: center; width: 31px; height: 31px; color: white; background: var(--green); border-radius: 50%; }
.connected-badge small { display: block; color: var(--muted); }
.toast { position: fixed; z-index: 20; right: 20px; bottom: 20px; max-width: min(420px, calc(100% - 40px)); padding: 13px 17px; color: white; background: var(--ink); border-radius: 10px; box-shadow: var(--shadow); }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px 0; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }

@media (max-width: 800px) {
  .topbar, main, footer { width: min(100% - 24px, 1160px); }
  .auth-view { grid-template-columns: 1fr; align-items: start; gap: 35px; padding-top: 32px; }
  .dashboard-title { align-items: start; flex-direction: column; }
  .connection-card { width: 100%; }
  .section-tabs { width: 100%; }
  .section-tab { flex: 1; }
  .guide-grid, .automation-grid, .settings-grid { grid-template-columns: 1fr; }
  .guide-intro, .guide-wide { grid-column: auto; }
  .checklist { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr; gap: 3px; }
  .card-heading { flex-direction: column; }
  .file-picker { width: 100%; text-align: center; }
  .editor-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .action-spacer { display: none; }
  .editor-actions .button { width: 100%; }
  /* iOS Safari zooms into any field whose font is smaller than 16px. */
  textarea { font-size: 16px; }
  .inline-form { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
}

@media (max-width: 430px) {
  .brand { font-size: 14px; gap: 6px; }
  .brand-icon { width: 30px; height: 30px; }
  .header-actions select { max-width: 98px; padding-left: 7px; padding-right: 16px; }
  #logout { padding-inline: 7px; font-size: 13px; }
  .header-actions { gap: 4px; }
  h1 { font-size: 36px; }
  .auth-card, .editor-card, .history-card, .guide-intro, .guide-card, .automation-card { padding: 20px; }
  .editor-actions { grid-template-columns: 1fr; }
}

/* Progressive disclosure keeps technical setup out of the everyday workflow. */
.disclosure { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
summary { cursor: pointer; font-size: 14px; font-weight: 650; min-height: 44px; padding-block: 10px; }
details[open] > summary { margin-bottom: 12px; }
details > :last-child { margin-bottom: 0; }
.plan-editor { margin-top: 0; padding-top: 0; border: 0; }
.plan-editor textarea { margin-top: 4px; }
.assistant-help { color: var(--muted); font-size: 14px; }
.selected-plan { padding: 12px 14px; background: var(--mint); border-radius: 8px; font-size: 14px; overflow-wrap: anywhere; }
.advanced-access { grid-column: 1 / -1; box-shadow: none; }
.advanced-access > summary { color: var(--muted); }
.advanced-access[open] > h2 { display: none; }
.advanced-access .text-link { display: inline-block; margin-top: 16px; font-size: 13px; }
.danger-zone { align-self: start; box-shadow: none; }
.danger-zone > summary { color: var(--danger); }
input[type=checkbox] { width: 20px; min-height: 20px; accent-color: var(--green); }
#account-label { font-size: 13px; margin-bottom: 0; overflow-wrap: anywhere; }
.section-tabs { background: transparent; border-bottom: 1px solid var(--line); border-radius: 0; width: 100%; gap: 20px; padding: 0; }
.section-tab { border-radius: 0; border-bottom: 3px solid transparent; padding: 12px 4px; }
.section-tab.active { color: var(--green); background: transparent; border-bottom-color: var(--green); }
.card-heading .step, .dashboard-title .eyebrow { display: none; }
#section-upload { max-width: 820px; margin-inline: auto; }
.key-row { overflow-wrap: anywhere; }
.key-row button { min-height: 44px; padding-inline: 10px; }
@media (max-width: 800px) {
  .auth-view { gap: 24px; padding-bottom: 36px; }
  .hero-copy { font-size: 17px; }
  .trust-line { margin-top: 20px; font-size: 13px; }
  .dashboard-title { gap: 18px; margin-bottom: 22px; }
  .section-tabs { gap: 10px; }
  .section-tab { min-width: 0; white-space: normal; font-size: 14px; }
  .editor-actions { grid-template-columns: auto 1fr; }
  .editor-actions .action-spacer { display: none; }
  select, input, textarea { font-size: 16px; }
  .guide-actions { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
@media (max-width: 360px) {
  .brand > span:last-child { display: none; }
  .topbar { gap: 8px; }
}

.retention { margin: 0 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.retention legend { padding: 0 6px; font-size: 13px; font-weight: 750; }
.retention .consent { margin-bottom: 12px; }
.retention .consent:last-child { margin-bottom: 0; }
.retention small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.privacy-note { position: fixed; z-index: 30; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); padding: 16px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; }
.privacy-note p { margin-bottom: 12px; }
.privacy-note-actions { display: flex; gap: 8px; }
.privacy-note-actions .button { flex: 1; }
footer .text-link { border: 0; background: transparent; cursor: pointer; padding: 0; font: inherit; }

.setup-card { padding: 27px; margin-bottom: 20px; }
.setup-steps { display: grid; gap: 22px; margin: 0 0 22px; padding: 0; list-style: none; counter-reset: setup; }
.setup-steps li { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: start; }
.setup-steps strong { display: block; margin-bottom: 4px; }
.setup-steps p { margin: 0; color: var(--muted); font-size: 14px; }
.setup-art { width: 120px; height: 80px; border-radius: 10px; background: var(--cream); }
.setup-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.setup-help { margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.setup-help summary { cursor: pointer; font-weight: 750; font-size: 14px; }
.setup-help p { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
@media (max-width: 560px) {
  .setup-steps li { grid-template-columns: 1fr; }
  .setup-art { width: 100%; height: auto; max-height: 140px; }
  .setup-actions .button { width: 100%; }
}

.setup-strip { margin-bottom: 20px; padding: 18px; background: var(--cream); border-radius: 12px; }
.setup-strip .setup-steps { gap: 16px; margin-bottom: 0; }
.setup-strip .setup-art { background: var(--paper); }
.disclosure summary { display: flex; align-items: center; gap: 10px; }
.badge { padding: 2px 9px; background: var(--mint); color: var(--green-dark); border-radius: 99px;
  font-size: 12px; font-weight: 800; }
.history-actions { display: flex; align-items: center; gap: 8px; }

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 16px; font-size: 14px; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; text-align: right; font-weight: 650; }

.about-steps { margin-bottom: 18px; }
.footer-links { display: flex; gap: 14px; }
#about-dialog { width: min(640px, calc(100% - 24px)); }

.dialog-language { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.lang-switch { display: inline-flex; gap: 3px; padding: 3px; background: var(--cream);
  border: 1px solid var(--line); border-radius: 11px; }
.lang-option { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 800; letter-spacing: .05em; cursor: pointer; }
.lang-option[aria-pressed="true"] { background: var(--paper); color: var(--ink);
  box-shadow: 0 1px 4px rgba(18, 38, 58, .12); }
.lang-option .flag { display: block; width: 22px; height: 15px; border-radius: 3px; }
.lang-option:not([aria-pressed="true"]) .flag { opacity: .5; }
.language-choices .flag { width: 22px; height: 15px; border-radius: 3px; }
@media (max-width: 430px) { .lang-option span { display: none; } .lang-option { padding: 0 8px; } }
.setup-disclosure { margin-bottom: 16px; }
[data-language-select] { border-radius: 99px; min-height: 44px; }
.header-actions #language { max-width: 145px; }
.language-choices { display: flex; gap: 6px; flex-wrap: wrap; }
.language-choices a { display: inline-flex; gap: 7px; align-items: center; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); text-decoration: none; font-size: 14px; }
.language-choices a[aria-current=true] { color: var(--green-dark); background: var(--mint); border-color: var(--green); }
.workflow-caption { font-size: 14px; color: var(--muted); margin-top: 24px; }
.about-page main { max-width: 880px; padding-bottom: 48px; }
.about-hero { padding: 48px 0 36px; max-width: 720px; }
.about-hero h1 { font-size: clamp(34px, 5vw, 56px); }
.about-hero .hero-copy { font-size: 20px; }
.workflow-cards { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.workflow-cards li { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.workflow-number { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--mint); color: var(--green-dark); font-size: 15px; font-weight: 700; margin-bottom: 20px; }
.workflow-cards h2 { font-size: 21px; }
.workflow-cards p { margin-bottom: 0; color: var(--muted); }
.workflow-note { margin: 22px 0; color: var(--muted); font-size: 14px; }
#about-dialog .text-link { display: inline-block; padding-block: 12px; }
@media (max-width: 600px) {
  .workflow-cards { grid-template-columns: 1fr; }
  .about-page .topbar { flex-wrap: wrap; padding-top: 16px; }
  .about-page .language-choices { margin-left: auto; }
  .about-hero { padding-top: 32px; }
  .header-actions #language { max-width: 126px; }
}

/* The signed-out screen is a form, not a landing page. */
.auth-view { min-height: calc(100svh - 76px); display: grid; grid-template-columns: minmax(0, 380px); justify-content: center; align-content: center; gap: 0; padding: 24px 0 76px; }
.auth-card { width: 100%; padding: 30px; box-shadow: 0 6px 28px rgba(18,38,58,.04); }
.auth-only footer, .auth-only #privacy-note { display: none; }
#auth-error:empty { display: none; }
#register-privacy { border: 0; background: none; padding: 4px 0 16px; font-size: 13px; cursor: pointer; }
@media (max-width: 430px) {
  .auth-view { padding-bottom: 48px; }
  .auth-card { padding: 24px; }
}
