:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fffefa;
  --surface-strong: #ffffff;
  --ink: #191917;
  --muted: #6a6860;
  --line: #d9d6cc;
  --line-strong: #bbb7aa;
  --add-bg: #e6f4ea;
  --add-line: #8ab895;
  --add-ink: #174f2a;
  --del-bg: #f8e7e3;
  --del-line: #d49a8f;
  --del-ink: #742519;
  --focus: #2457d6;
  --shadow: 0 10px 30px rgba(28, 26, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

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

.topbar {
  margin-bottom: 18px;
}

.landing-shell {
  min-height: 100vh;
  padding-top: 48px;
}

.landing-topbar {
  margin-bottom: 22px;
}

.kicker,
h1,
.privacy-note,
.status-text,
.drop-title,
.file-meta,
.error-text,
.empty-state p {
  margin: 0;
}

.kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin-top: 2px;
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1.05;
}

h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.08;
}

.privacy-note {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  padding: 7px 11px;
  font-size: 13px;
  white-space: nowrap;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 520px);
  gap: 14px;
}

.tool-card {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  min-height: 190px;
  padding: 22px;
  text-decoration: none;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.tool-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 14px 34px rgba(28, 26, 20, 0.11);
  transform: translateY(-1px);
}

.tool-card:focus-visible {
  outline: 3px solid rgba(36, 87, 214, 0.22);
  outline-offset: 3px;
}

.tool-card p {
  margin: 0;
}

.tool-card h2 {
  margin: 5px 0 10px;
}

.tool-card div > p:last-child {
  color: var(--muted);
  max-width: 390px;
}

.tool-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 12px;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.file-panel,
.diff-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.file-panel {
  padding: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-weight: 650;
}

.small-button,
.segment {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  cursor: pointer;
  min-height: 34px;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.small-button {
  padding: 6px 12px;
}

.small-button:hover,
.segment:hover {
  border-color: var(--line-strong);
  background: #fbfaf6;
}

.small-button:disabled {
  color: #9a978d;
  cursor: not-allowed;
  opacity: 0.6;
}

.small-button:active,
.segment:active {
  transform: translateY(1px);
}

.drop-zone {
  position: relative;
  display: grid;
  min-height: 122px;
  place-content: center;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfaf6;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  outline: none;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--focus);
  background: #f4f7ff;
}

.drop-zone:focus-visible,
.small-button:focus-visible,
.segment:focus-visible {
  outline: 3px solid rgba(36, 87, 214, 0.22);
  outline-offset: 2px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.drop-title {
  font-weight: 650;
}

.file-meta {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.error-text {
  min-height: 20px;
  margin-top: 8px;
  color: var(--del-ink);
  font-size: 13px;
}

.result-toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.78);
  margin-bottom: 12px;
  padding: 10px 12px;
}

.status-text {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.control-group,
.segmented,
.export-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 3px;
}

.segment {
  border-color: transparent;
  background: transparent;
  min-height: 30px;
  padding: 4px 10px;
}

.segment.is-active {
  border-color: var(--line);
  background: #f1efe7;
}

.diff-shell {
  background: #e9e6dc;
  overflow: hidden;
}

.diff-head {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 12px 18px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.diff-head span {
  padding: 0 6px 8px;
}

.diff-rows {
  min-height: 280px;
  max-height: calc(100vh - 330px);
  overflow: auto;
  background: #e9e6dc;
}

.doc-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 18px;
}

.redline-shell {
  display: grid;
  justify-items: center;
  padding: 18px;
}

.doc-page {
  background: var(--surface-strong);
  border: 1px solid #d8d2c3;
  box-shadow: 0 8px 24px rgba(28, 26, 20, 0.08);
  min-height: 520px;
  padding: 34px 42px 44px;
}

.redline-page {
  width: min(820px, 100%);
}

.doc-page-header {
  border-bottom: 1px solid #eee9dc;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: -10px 0 22px;
  padding-bottom: 10px;
}

.doc-page-header p,
.doc-page-header span {
  margin: 0;
}

.doc-page-header p {
  color: var(--ink);
  font-weight: 700;
}

.doc-page-header span {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.doc-body {
  display: grid;
  gap: 8px;
}

.doc-block {
  border-left: 3px solid transparent;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  min-height: 30px;
  padding: 3px 0 3px 8px;
  position: relative;
}

.doc-block.is-replace {
  border-left-color: #d7c27d;
}

.doc-block.is-delete {
  border-left-color: var(--del-line);
}

.doc-block.is-insert {
  border-left-color: var(--add-line);
}

.doc-block.is-placeholder {
  color: var(--muted);
  opacity: 0.54;
}

.doc-marker {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.65;
  user-select: none;
}

.doc-content {
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.doc-block.is-replace .doc-content,
.doc-block.is-delete .doc-content,
.doc-block.is-insert .doc-content {
  padding-right: 92px;
}

.doc-content.is-title {
  font-size: 21px;
  font-weight: 750;
  line-height: 1.2;
  margin-bottom: 2px;
}

.doc-content.is-subtitle {
  color: var(--muted);
  font-style: italic;
}

.doc-content.is-heading {
  font-weight: 740;
  margin-top: 6px;
}

.doc-content.is-list {
  padding-left: 16px;
}

.doc-content.is-table {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.doc-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  position: absolute;
  right: 0;
  top: 2px;
  white-space: nowrap;
}

.doc-status.is-replace {
  border-color: #d7c27d;
  background: #fff6cf;
  color: #624b00;
}

.doc-status.is-delete {
  border-color: var(--del-line);
  background: var(--del-bg);
  color: var(--del-ink);
}

.doc-status.is-insert {
  border-color: var(--add-line);
  background: var(--add-bg);
  color: var(--add-ink);
}

.mark-added,
.mark-removed {
  border-radius: 4px;
  padding: 1px 2px;
}

.mark-added {
  background: var(--add-bg);
  color: var(--add-ink);
  font-weight: 650;
}

.mark-removed {
  background: var(--del-bg);
  color: var(--del-ink);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--del-ink);
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: var(--muted);
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .topbar,
  .result-toolbar,
  .control-group {
    align-items: stretch;
    flex-direction: column;
  }

  .privacy-note {
    align-self: flex-start;
  }

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

  .tool-card {
    align-items: flex-start;
    flex-direction: column;
    min-height: 0;
  }

  .upload-grid,
  .diff-head,
  .doc-compare {
    grid-template-columns: 1fr;
  }

  .diff-head {
    gap: 8px;
    padding: 12px 12px 0;
  }

  .diff-head span:nth-child(2) {
    display: none;
  }

  .doc-compare {
    gap: 12px;
    padding: 12px;
  }

  .doc-page {
    min-height: 0;
    padding: 26px 20px 32px;
  }

  .doc-block.is-replace .doc-content,
  .doc-block.is-delete .doc-content,
  .doc-block.is-insert .doc-content {
    padding-right: 0;
  }

  .doc-status {
    grid-column: 2;
    justify-self: start;
    margin-top: 4px;
    position: static;
  }

  .diff-rows {
    max-height: none;
  }
}
