:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #f9f8f5;
  --panel: rgba(255, 255, 255, 0.34);
  --panel-solid: #fbfaf7;
  --panel-soft: rgba(255, 255, 255, 0.26);
  --ink: #111111;
  --text: #24221f;
  --muted: #66615a;
  --soft: #918a80;
  --line: rgba(17, 17, 17, 0.12);
  --line-soft: rgba(17, 17, 17, 0.075);
  --line-strong: rgba(17, 17, 17, 0.22);
  --accent: #6f675f;
  --accent-strong: #5f5851;
  --accent-active: #544e48;
  --accent-text: #f7f5f2;
  --secondary-border: #cfc7bf;
  --secondary-text: #5f5851;
  --secondary-hover: #f4f1ed;
  --focus-ring: rgba(111, 103, 95, 0.18);
  --input-focus: #b9b1a8;
  --warn: #8a5b1c;
  --fail: #8d2c2c;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(17, 17, 17, 0.021) 1px, transparent 1px) 0 0 / 104px 104px,
    var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 16px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  line-height: 1.2;
}

button:hover {
  background: var(--accent-strong);
}

button:active {
  background: var(--accent-active);
}

button:disabled {
  border-color: var(--line);
  background: rgba(17, 17, 17, 0.04);
  color: var(--muted);
  cursor: not-allowed;
}

button.secondary {
  border-color: var(--secondary-border);
  background: rgba(255, 255, 255, 0.22);
  color: var(--secondary-text);
}

button.secondary:hover {
  border-color: var(--secondary-border);
  background: var(--secondary-hover);
  color: var(--secondary-text);
}

button.secondary:active {
  background: #ece7e1;
}

button.danger {
  border-color: var(--fail);
  background: var(--fail);
}

button.danger:hover {
  background: #6f2020;
}

button.danger-link {
  min-height: 32px;
  border-color: transparent;
  padding: 0;
  background: transparent;
  color: var(--fail);
  text-decoration: underline;
  text-underline-offset: 3px;
}

button.danger-link:hover {
  background: transparent;
  color: #6f2020;
}

.empty-actions button,
.product-row button,
.job-row button,
.workspace-section button.secondary {
  border-color: var(--secondary-border);
  background: rgba(255, 255, 255, 0.2);
  color: var(--secondary-text);
}

.empty-actions button:hover,
.product-row button:hover,
.job-row button:hover,
.workspace-section button.secondary:hover {
  border-color: var(--secondary-border);
  background: var(--secondary-hover);
  color: var(--secondary-text);
}

.empty-actions button:first-child {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.empty-actions button:first-child:hover {
  background: var(--accent-strong);
  color: var(--accent-text);
}

.empty-actions button:first-child:active {
  background: var(--accent-active);
  color: var(--accent-text);
}

button:disabled,
.empty-actions button:disabled,
.product-row button:disabled,
.job-row button:disabled {
  border-color: var(--line);
  background: rgba(17, 17, 17, 0.04);
  color: var(--muted);
  cursor: not-allowed;
}

a,
button,
input,
select,
textarea {
  outline-color: transparent;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 1px solid var(--input-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 10px 11px;
  background: rgba(255, 255, 255, 0.44);
  color: var(--ink);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--input-focus);
}

input::placeholder,
textarea::placeholder {
  color: #8c867d;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.35;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-weight: 400;
}

h1 {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.08;
}

h3 {
  font-size: 15px;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  width: min(100%, 1540px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
}

.sidebar {
  border-right: 1px solid var(--line-soft);
  background: rgba(249, 248, 245, 0.74);
  padding: 42px 40px;
}

.brand {
  display: inline-block;
  margin-bottom: 58px;
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  line-height: 1.3;
}

.panel {
  display: grid;
  gap: 20px;
}

.auth-panel {
  max-width: 380px;
  gap: 22px;
}

.auth-panel .eyebrow {
  margin-bottom: -10px;
}

.auth-panel h1 {
  max-width: 360px;
  font-size: clamp(42px, 4vw, 56px);
  line-height: 1.02;
}

.auth-copy {
  max-width: 350px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.52;
}

.auth-access-note {
  border-top: 1px solid var(--line-soft);
  padding-top: 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.auth-access-note a {
  color: var(--secondary-text);
  text-underline-offset: 0.22em;
}

.auth-benefits {
  width: min(100%, 520px);
  display: grid;
  gap: 0;
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.auth-benefits p {
  border-bottom: 1px solid var(--line-soft);
  padding: 15px 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.panel-header,
.section-header,
.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-header {
  min-height: 42px;
}

.panel-header h2 {
  font-size: 18px;
  line-height: 1.25;
}

.stack,
.workspace-form {
  display: grid;
  gap: 14px;
}

.auth-panel .stack {
  gap: 16px;
}

.workspace-list {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line-soft);
}

.workspace-list button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 14px;
}

.workspace-list button:hover {
  background: transparent;
  color: var(--ink);
}

.workspace-list button.active {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--accent);
  padding-left: 14px;
}

.workspace-main {
  display: grid;
  align-content: start;
  min-width: 0;
  padding: 52px 64px 64px;
}

.status-banner {
  min-height: 24px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.status-banner.error {
  color: var(--fail);
}

.validation-notice {
  display: grid;
  gap: 4px;
  width: min(100%, 1080px);
  margin-bottom: 24px;
  border: 1px solid rgba(138, 91, 28, 0.28);
  border-radius: 4px;
  padding: 12px 14px;
  background: rgba(138, 91, 28, 0.055);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.validation-notice strong {
  color: var(--warn);
  font-weight: 500;
}

.empty-state {
  min-height: calc(100vh - 80px);
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 22px;
  max-width: 760px;
}

#auth-app-state,
#loading-app-state,
#error-app-state,
#empty-app-state {
  min-height: calc(100vh - 128px);
}

.loading-ring {
  width: 28px;
  height: 28px;
  border: 1px solid var(--secondary-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-ring-rotate 1.1s linear infinite;
}

@keyframes loading-ring-rotate {
  to {
    transform: rotate(360deg);
  }
}

.empty-state h2 {
  max-width: 680px;
  font-family: var(--serif);
  font-size: 58px;
  font-weight: 400;
  line-height: 1.02;
}

.supporting-copy {
  max-width: 560px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
}

.empty-state > p:not(.eyebrow) {
  max-width: 560px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
}

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

.auth-panel a {
  width: fit-content;
  color: var(--muted);
  font-size: 14px;
  text-underline-offset: 0.22em;
}

.eyebrow {
  color: var(--soft);
  font-size: 12px;
  line-height: 1.5;
  text-transform: uppercase;
}

.workspace-view {
  display: grid;
  width: min(100%, 1080px);
  gap: 34px;
}

.workspace-header {
  min-height: 82px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--line-soft);
}

.workspace-header > div:first-child {
  min-width: 0;
}

.workspace-header h2 {
  font-family: var(--serif);
  font-size: clamp(38px, 4vw, 52px);
  font-weight: 400;
  line-height: 1.06;
  overflow-wrap: anywhere;
}

.workspace-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.workspace-stats .pill {
  color: var(--muted);
}

.workspace-header-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.confirmation-dialog,
.report-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
}

.report-dialog {
  width: min(760px, calc(100vw - 32px));
}

.confirmation-dialog::backdrop,
.report-dialog::backdrop {
  background: rgba(22, 24, 26, 0.28);
}

.confirmation-dialog-body,
.report-dialog-body {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.confirmation-dialog-body h3,
.report-dialog-body h3 {
  font-family: var(--serif);
  font-size: 28px;
}

.confirmation-dialog-body p,
.report-dialog-body p {
  color: var(--muted);
  line-height: 1.45;
}

.report-dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 14px;
}

.report-content {
  display: grid;
  max-height: min(68vh, 720px);
  gap: 18px;
  overflow: auto;
}

.report-section {
  display: grid;
  gap: 9px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 16px;
}

.report-section ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.report-section li,
.report-section pre {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.report-section pre {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.28);
  white-space: pre-wrap;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.workspace-empty-state {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 28px;
  background: var(--panel);
}

.workspace-empty-state h3 {
  font-family: var(--serif);
  font-size: 32px;
  line-height: 1.12;
}

.stat,
.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 0 0 3px;
  background: transparent;
  color: var(--soft);
  font-size: 12px;
  white-space: nowrap;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px 34px;
}

.workspace-section {
  display: grid;
  gap: 18px;
  align-content: start;
  border-top: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 28px 0 0;
  background: transparent;
}

.workspace-section h3 {
  color: var(--ink);
}

.workspace-section.wide {
  grid-column: 1 / -1;
}

.archive-section {
  color: var(--muted);
}

.archive-section h3 {
  color: var(--secondary-text);
}

.inline-empty {
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 15px 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.2);
  font-size: 14px;
}

.product-list,
.context-list,
.jobs-list,
.results-home {
  display: grid;
  gap: 10px;
}

.product-row,
.context-row,
.job-row,
.result-row {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 0 0 13px;
  background: transparent;
}

.product-row {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 210px) auto;
  align-items: center;
}

.context-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.context-actions,
.product-actions,
.job-actions,
.context-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.context-actions {
  justify-self: end;
}

.product-actions {
  justify-content: flex-end;
}

.product-title,
.job-title,
.context-title {
  color: var(--ink);
  font-weight: 400;
}

.product-url,
.meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.context-form .span-2 {
  grid-column: 1 / -1;
}

.context-form-actions {
  grid-column: 1 / -1;
}

.context-form button {
  width: fit-content;
}

.job-row {
  grid-template-columns: minmax(0, 1fr) auto minmax(220px, auto);
  align-items: center;
}

.job-actions {
  justify-content: end;
}

.status-queued,
.status-running,
.status-retrying {
  border-color: #9ab1bb;
  color: #245466;
}

.status-completed,
.status-reused,
.status-ready,
.status-analyzed {
  border-color: var(--secondary-border);
  color: var(--secondary-text);
}

.status-failed,
.status-cancelled {
  border-color: #d8adad;
  color: var(--fail);
}

.status-partial {
  border-color: #d9bc7a;
  color: var(--warn);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-panel {
    max-width: 520px;
  }

  .workspace-main {
    padding: 44px 40px 58px;
  }

  #auth-app-state,
  #loading-app-state,
  #error-app-state,
  #empty-app-state {
    min-height: auto;
  }

  .workspace-grid,
  .context-form {
    grid-template-columns: 1fr;
  }

  .product-row,
  .context-row,
  .job-row {
    grid-template-columns: 1fr;
  }

  .context-actions,
  .product-actions,
  .job-actions {
    justify-self: start;
    justify-content: start;
  }
}

@media (max-width: 560px) {
  .workspace-main,
  .sidebar {
    padding: 18px;
  }

  .brand {
    margin-bottom: 44px;
  }

  .auth-panel {
    max-width: none;
    gap: 18px;
  }

  .auth-panel h1 {
    font-size: 38px;
  }

  .auth-copy,
  .empty-state > p:not(.eyebrow),
  .supporting-copy {
    font-size: 17px;
  }

  .empty-state {
    min-height: auto;
    align-content: start;
    padding: 36px 0 72px;
  }

  .empty-state h2 {
    font-size: 34px;
  }

  .workspace-empty-state {
    padding: 20px;
  }

  .workspace-header,
  .panel-header,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-stats {
    justify-content: flex-start;
  }

  .workspace-header-actions {
    justify-items: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-ring {
    animation: none;
  }
}
