:root {
  color-scheme: light;
  --paper: oklch(96.5% 0.012 84);
  --paper-deep: oklch(92.8% 0.018 82);
  --ink: oklch(22% 0.025 63);
  --ink-soft: oklch(45% 0.024 64);
  --line: oklch(83% 0.022 78);
  --accent: oklch(61% 0.19 42);
  --accent-dark: oklch(45% 0.16 38);
  --success: oklch(50% 0.11 151);
  --warning: oklch(66% 0.15 76);
  --danger: oklch(50% 0.17 27);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --display: "Avenir Next", Avenir, "Century Gothic", sans-serif;
  --body: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
}

* { box-sizing: border-box; }

.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important; }

html { min-width: 320px; background: var(--paper); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), color-mix(in oklch, var(--line), transparent 72%) calc(100% - 1px)) 0 0 / 5rem 100%,
    var(--paper);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--accent), transparent 62%);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 4rem;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--paper), transparent 6%);
  backdrop-filter: blur(14px);
}

.brand { display: inline-flex; align-items: center; gap: .75rem; color: inherit; font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 1.9rem; height: 1.9rem; place-items: center; background: var(--ink); color: var(--paper); font-family: var(--body); font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 1.2rem; font-size: .78rem; }
.health { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink-soft); }
.health i { width: .45rem; height: .45rem; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px color-mix(in oklch, var(--warning), transparent 78%); }
.health.online i { background: var(--success); box-shadow: 0 0 0 3px color-mix(in oklch, var(--success), transparent 78%); }
.text-link, .text-button { border: 0; padding: .2rem 0; background: none; color: var(--ink); text-decoration: none; cursor: pointer; }
.text-link:hover, .text-button:hover { color: var(--accent-dark); }
.text-button.muted { color: var(--ink-soft); }


.workspace {
  display: grid;
  grid-template-columns: minmax(19rem, 24rem) minmax(0, 1fr);
  min-height: calc(100vh - 4rem);
}

.composer { position: relative; padding: clamp(2.2rem, 5vw, 5rem) 2.1rem 3rem; border-right: 1px solid var(--line); background: color-mix(in oklch, var(--paper), var(--paper-deep) 28%); }
.section-heading { margin-bottom: 2.5rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--accent-dark); font-size: .66rem; font-weight: 800; letter-spacing: .17em; }
.section-heading h1, .queue-header h2 { margin: 0; font-family: var(--body); font-size: clamp(2.15rem, 4vw, 3.25rem); font-weight: 500; letter-spacing: -.045em; line-height: .98; }
.section-heading > p:last-child { max-width: 24rem; margin: 1rem 0 0; color: var(--ink-soft); font-family: var(--body); font-size: 1rem; line-height: 1.55; }

.job-form { display: grid; gap: 1rem; }
.field { display: grid; gap: .45rem; }
.field > span { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.field b, .field em { color: var(--ink-soft); font-size: .65rem; font-style: normal; font-weight: 500; }
.field-url { position: relative; }
.field-url > kbd { position: absolute; right: .7rem; bottom: .7rem; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: color-mix(in oklch, var(--paper), white 26%);
  color: var(--ink);
  transition: border-color 160ms var(--ease), background-color 160ms var(--ease), transform 160ms var(--ease);
}
input { min-height: 2.85rem; padding: .7rem .85rem; }
textarea { resize: vertical; min-height: 5.3rem; padding: .8rem .85rem; line-height: 1.4; }
input:hover, textarea:hover { border-color: color-mix(in oklch, var(--ink), transparent 58%); }
input:focus, textarea:focus { border-color: var(--accent); background: color-mix(in oklch, var(--paper), white 52%); }
input::placeholder, textarea::placeholder { color: color-mix(in oklch, var(--ink-soft), transparent 28%); }
kbd { border: 1px solid var(--line); padding: .12rem .34rem; background: var(--paper-deep); color: var(--ink-soft); font-size: .62rem; font-weight: 700; }

.presets { display: flex; gap: .45rem; margin-top: -.35rem; }
.presets button { flex: 1; border: 1px solid var(--line); padding: .45rem .35rem; background: transparent; color: var(--ink-soft); font-size: .68rem; cursor: pointer; transition: color 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease); }
.presets button:hover { border-color: var(--accent); color: var(--accent-dark); transform: translateY(-1px); }
.optional-field { margin-top: .4rem; }
.button { min-height: 2.85rem; border: 1px solid transparent; padding: .65rem 1rem; cursor: pointer; transition: transform 160ms var(--ease), background-color 160ms var(--ease); }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--ink); color: var(--paper); }
.button.primary:hover { background: var(--accent-dark); }
.submit-button { display: flex; align-items: center; justify-content: space-between; margin-top: .35rem; text-align: left; }
.submit-button kbd { border-color: color-mix(in oklch, var(--paper), transparent 68%); background: transparent; color: color-mix(in oklch, var(--paper), transparent 20%); }
.form-feedback { min-height: 1.15rem; margin: -.4rem 0 0; color: var(--danger); font-family: var(--body); font-size: .8rem; }

.agent-note { margin-top: 3.2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.agent-note span { color: var(--success); font-size: .67rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.agent-note p { margin: .45rem 0 .75rem; color: var(--ink-soft); font-family: var(--body); font-size: .82rem; line-height: 1.5; }
.agent-note button { border: 0; padding: 0; background: transparent; color: var(--ink); font-size: .72rem; font-weight: 700; text-decoration: underline; text-underline-offset: .2rem; cursor: pointer; }

.queue { min-width: 0; padding: clamp(2.2rem, 5vw, 5rem) clamp(1.25rem, 4vw, 4rem); }
.queue-header { display: flex; align-items: end; justify-content: space-between; margin-bottom: 2rem; }
.queue-header h2 { font-size: clamp(2rem, 3vw, 2.75rem); }
.icon-button { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 1.2rem; cursor: pointer; transition: transform 500ms var(--ease), border-color 160ms var(--ease); }
.icon-button:hover { border-color: var(--accent); transform: rotate(120deg); }
.filters { display: flex; gap: 1.35rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.filters button { position: relative; border: 0; padding: 0 0 .75rem; background: transparent; color: var(--ink-soft); font-size: .72rem; font-weight: 700; white-space: nowrap; cursor: pointer; }
.filters button::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); content: ""; transform: scaleX(0); transform-origin: left; transition: transform 180ms var(--ease); }
.filters button.active { color: var(--ink); }
.filters button.active::after { transform: scaleX(1); }
.filters span { margin-left: .3rem; color: var(--ink-soft); font-weight: 500; }

.queue-list { container-type: inline-size; }
.job { display: grid; grid-template-columns: 8.4rem minmax(0, 1fr) auto; gap: 1.15rem; align-items: start; padding: 1.35rem 0; border-bottom: 1px solid var(--line); transition: background-color 220ms var(--ease), transform 220ms var(--ease), opacity 220ms var(--ease); }
.job.new { animation: arrive 520ms var(--ease) both; }
.job-time { color: var(--ink-soft); font-size: .72rem; line-height: 1.45; }
.job-time strong { display: block; color: var(--ink); font-family: var(--body); font-size: 1.04rem; font-weight: 500; }
.job-body { min-width: 0; }
.job-title { margin: 0; overflow-wrap: anywhere; font-family: var(--body); font-size: 1.02rem; font-weight: 600; line-height: 1.35; }
.job-url { display: block; margin-top: .4rem; overflow: hidden; color: var(--ink-soft); font-size: .7rem; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.job-url:hover { color: var(--accent-dark); text-decoration: underline; }
.job-error { margin: .65rem 0 0; padding-left: .65rem; border-left: 2px solid var(--danger); color: var(--danger); font-family: var(--body); font-size: .76rem; line-height: 1.4; }
.job-meta { display: flex; align-items: center; justify-content: flex-end; gap: .55rem; }
.status { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .45rem; background: var(--paper-deep); color: var(--ink-soft); font-size: .62rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
.status::before { width: .34rem; height: .34rem; border-radius: 50%; background: currentColor; content: ""; }
.status.published { color: var(--success); }
.status.failed { color: var(--danger); }
.status.publishing { color: var(--accent-dark); }
.job-actions { display: flex; gap: .15rem; opacity: 0; transform: translateX(.3rem); transition: opacity 160ms var(--ease), transform 160ms var(--ease); }
.job:hover .job-actions, .job:focus-within .job-actions { opacity: 1; transform: none; }
.job-actions button, .job-actions a { border: 0; padding: .35rem; background: transparent; color: var(--ink-soft); font-size: .68rem; text-decoration: none; cursor: pointer; }
.job-actions button:hover, .job-actions a:hover { color: var(--accent-dark); }
.job-actions .danger:hover { color: var(--danger); }

.empty-state { padding: 6rem 0 0; max-width: 25rem; }
.empty-line { width: 3rem; height: 1px; margin-bottom: 1.5rem; background: var(--accent); }
.empty-state h3 { margin: 0; font-family: var(--body); font-size: 1.35rem; font-weight: 500; }
.empty-state p { color: var(--ink-soft); font-family: var(--body); line-height: 1.6; }

.auth-gate { position: fixed; z-index: 100; inset: 0; display: none; place-items: center; padding: 1.25rem; background: var(--paper); }
.auth-gate.visible { display: grid; }
.auth-panel { width: min(100%, 24rem); padding: 2.4rem; border: 1px solid var(--line); background: color-mix(in oklch, var(--paper), white 28%); box-shadow: 1rem 1rem 0 var(--paper-deep); }
.auth-panel h1 { margin: 0 0 .7rem; font-family: var(--body); font-size: 2.2rem; font-weight: 500; }
.auth-panel > p:not(.eyebrow, .auth-error) { margin: 0 0 1.8rem; color: var(--ink-soft); font-family: var(--body); line-height: 1.5; }
.auth-panel label { display: grid; gap: .5rem; margin-bottom: 1rem; color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
.auth-panel .button { width: 100%; }
.auth-error { min-height: 1rem; margin: .7rem 0 0; color: var(--danger); font-size: .75rem; }

.toast { position: fixed; z-index: 120; right: 1.25rem; bottom: 1.25rem; max-width: min(28rem, calc(100vw - 2.5rem)); padding: .75rem 1rem; background: var(--ink); color: var(--paper); font-size: .75rem; opacity: 0; pointer-events: none; transform: translateY(.75rem); transition: opacity 180ms var(--ease), transform 180ms var(--ease); }
.toast.visible { opacity: 1; transform: none; }

@keyframes arrive { from { opacity: 0; transform: translateY(-.75rem); } }

@container (max-width: 680px) {
  .job { grid-template-columns: 6.8rem minmax(0, 1fr); }
  .job-meta { grid-column: 2; justify-content: space-between; }
  .job-actions { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  .topbar { padding: 0 1rem; }
  .health, .text-link { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); padding: 2.4rem 1.2rem 2.5rem; }
  .queue { padding: 2.4rem 1.2rem; }
  .agent-note { margin-top: 2rem; }
}

@media (max-width: 520px) {
  .topbar-actions { gap: .7rem; }
  .brand > span:last-child { display: none; }
  .section-heading { margin-bottom: 2rem; }
  .presets { display: grid; grid-template-columns: 1fr 1fr; }
  .presets button:first-child { grid-column: span 2; }
  .job { grid-template-columns: 1fr; gap: .55rem; }
  .job-meta { grid-column: 1; justify-content: space-between; }
  .job-time strong { display: inline; margin-right: .45rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
