:root {
  color-scheme: light;
  --ink: #20242a;
  --muted: #69717d;
  --line: #d7dde5;
  --paper: #f7f3eb;
  --panel: #fffdfa;
  --accent: #176b69;
  --accent-dark: #0f4f4d;
  --warning: #b94e22;
  --warning-soft: #fff0e8;
  --ok: #2d7653;
  --ok-soft: #e8f4ee;
  --focus: #f2b84b;
  --shadow: 0 18px 48px rgba(40, 45, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(23, 107, 105, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 107, 105, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 48px 48px;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: wait;
  opacity: 0.68;
}

button:focus-visible,
textarea:focus-visible,
label:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 24px;
  min-height: calc(100vh - 56px);
}

.input-panel,
.output-panel {
  background: rgba(255, 253, 250, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.input-panel {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.output-panel {
  display: flex;
  flex-direction: column;
  padding: 26px;
  overflow: hidden;
}

.topbar,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

h1 {
  max-width: 720px;
  font-size: clamp(2rem, 4vw, 4.4rem);
}

h2 {
  font-size: clamp(1.55rem, 2vw, 2.2rem);
}

h3 {
  font-size: 0.96rem;
}

.ghost-button,
.secondary-button {
  color: var(--accent-dark);
  background: #e8f3f2;
  border: 1px solid #c5dddd;
}

.ghost-button {
  min-width: 112px;
  padding: 10px 13px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  margin: 32px 0 16px;
  background: #eef1ef;
  border: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}

.tab.is-active {
  color: #fff;
  background: var(--accent);
}

.mode-view {
  display: none;
  min-height: 0;
}

.mode-view.is-active {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

textarea {
  width: 100%;
  min-height: min(52vh, 620px);
  resize: vertical;
  padding: 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  line-height: 1.5;
}

textarea::placeholder {
  color: #8a929d;
}

textarea[readonly] {
  color: #4d5661;
  background: #f8fafb;
}

.upload-zone {
  display: flex;
  min-height: 164px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 22px;
  text-align: center;
  background: #fff;
  border: 2px dashed #aebbc8;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-title {
  color: var(--accent-dark);
  font-size: 1.08rem;
  font-weight: 850;
}

.upload-note {
  max-width: 320px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.image-preview {
  margin: 16px 0 0;
  min-height: 260px;
  display: grid;
  place-items: center;
  gap: 12px;
  background: #f4f6f7;
  border: 1px solid var(--line);
  overflow: hidden;
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #fff;
}

.image-preview figcaption {
  color: var(--muted);
  font-size: 0.86rem;
}

.ocr-panel {
  margin-top: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.ocr-status-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.ocr-progress-track {
  height: 8px;
  margin: 10px 0 14px;
  background: #edf1f2;
  overflow: hidden;
}

.ocr-progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

#extractedText {
  min-height: 150px;
  resize: vertical;
}

.empty-page {
  width: 150px;
  aspect-ratio: 0.72;
  padding: 22px 18px;
  background: #fff;
  border: 1px solid #cfd6df;
  box-shadow: 0 10px 20px rgba(40, 45, 52, 0.08);
}

.empty-page span {
  display: block;
  height: 10px;
  margin-bottom: 15px;
  background: #cfd8dc;
}

.empty-page span:nth-child(2) {
  width: 74%;
}

.empty-page span:nth-child(3) {
  width: 90%;
}

.empty-page span:nth-child(4) {
  width: 62%;
}

.actions {
  display: flex;
  gap: 10px;
  padding-top: 14px;
}

.article-panel {
  margin-top: auto;
  padding-top: 18px;
}

.article-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.article-heading .eyebrow {
  margin-bottom: 0;
}

.article-heading h2 {
  max-width: 260px;
  color: var(--ink);
  font-size: 1.05rem;
  text-align: right;
}

.article-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.article-link {
  display: block;
  padding: 12px 13px;
  color: inherit;
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
}

.article-link:hover,
.article-link:focus-visible {
  background: #f2f8f7;
}

.article-link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.article-link strong,
.article-link span {
  display: block;
}

.article-link strong {
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.article-link span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 0 18px;
  font-weight: 850;
}

.primary-button {
  flex: 1;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover,
.tab.is-active:hover {
  background: var(--accent-dark);
}

.risk-pill {
  flex: 0 0 auto;
  min-width: 96px;
  padding: 8px 10px;
  color: #4c5360;
  background: #eef1f3;
  border: 1px solid #d8dde3;
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
}

.risk-pill.is-watch {
  color: #803412;
  background: var(--warning-soft);
  border-color: #efc4af;
}

.risk-pill.is-clear {
  color: #1f5c40;
  background: var(--ok-soft);
  border-color: #b6d7c7;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0;
}

.summary-strip div {
  min-height: 78px;
  padding: 14px;
  background: #f1f6f5;
  border-left: 4px solid var(--accent);
}

.summary-strip strong,
.summary-strip span {
  display: block;
}

.summary-strip strong {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.summary-strip span {
  font-size: 1.08rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.result-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.result-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.plain-item,
.risk-item,
.question-item {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.plain-item strong,
.risk-item strong {
  display: block;
  margin-bottom: 6px;
}

.plain-item p,
.risk-item p,
.question-item p,
.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.risk-item {
  border-left: 4px solid var(--warning);
}

.question-item {
  border-left: 4px solid var(--focus);
}

.legal-note {
  margin: auto 0 0;
  padding-top: 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

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

  .input-panel,
  .output-panel {
    min-height: auto;
  }

  textarea {
    min-height: 340px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 0;
  }

  .workspace {
    gap: 0;
  }

  .input-panel,
  .output-panel {
    border-left: 0;
    border-right: 0;
    box-shadow: none;
    padding: 18px;
  }

  .topbar,
  .result-header,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-strip,
  .compact {
    grid-template-columns: 1fr;
  }
}
