:root {
  --ink: #17201d;
  --muted: #65706b;
  --line: #d8dedb;
  --paper: #ffffff;
  --canvas: #f3f5f3;
  --accent: #244a3b;
  --accent-hover: #18372c;
  --error: #9b2c2c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont,
               "Segoe UI", sans-serif;
}
main {
  width: min(680px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(26px, 5vw, 48px);
  box-shadow: 0 18px 45px rgba(23, 32, 29, .08);
}
.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  max-width: 520px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 7vw, 54px);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: 1.02;
}
.intro {
  margin: 18px 0 30px;
  max-width: 540px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}
#uploadView[hidden],
#resultsView[hidden] {
  display: none;
}
.results-summary {
  margin: 18px 0 24px;
  max-width: 540px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.results-actions button { width: 100%; }
.upload-more {
  margin-top: 18px;
}
button.secondary {
  background: white;
  color: var(--accent);
  border: 1px solid var(--line);
}
button.secondary:hover:not(:disabled) {
  background: #f7faf8;
  transform: translateY(-1px);
}
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}
.file-item:first-child { border-top: 0; }
.merge-option {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}
.merge-option input {
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.file-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.file-meta strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 650;
}
.file-meta span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.file-item button {
  width: auto;
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
  white-space: nowrap;
}
.source-group {
  list-style: none;
  border-top: 1px solid var(--line);
}
.source-group:first-child { border-top: 0; }
.source-group-title {
  padding: 14px 16px 10px;
  background: #f7faf8;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
}
.source-group .file-item { border-top: 1px solid var(--line); }
.source-errors {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid #e8c4c4;
  border-radius: 10px;
  background: #fff7f7;
  color: var(--error);
  font-size: 13px;
  line-height: 1.5;
}
.source-errors ul {
  margin: 8px 0 0;
  padding-left: 18px;
}
.dropzone {
  display: block;
  padding: 34px 24px;
  border: 1.5px dashed #aeb8b3;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .18s, background .18s, transform .18s;
}
.dropzone:hover, .dropzone.dragging {
  border-color: var(--accent);
  background: #f7faf8;
  transform: translateY(-1px);
}
.dropzone strong { display: block; font-size: 16px; }
.dropzone span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}
input[type=file] { position: absolute; opacity: 0; pointer-events: none; }
.selected {
  min-height: 24px;
  margin: 13px 0 14px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 14px;
}
.upload-option {
  margin: 0 0 17px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7faf8;
}
button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background .18s, transform .18s, opacity .18s;
}
button:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: .6; }
.status {
  min-height: 24px;
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.status.error { color: var(--error); }
.privacy {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 27px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.dot {
  width: 7px;
  height: 7px;
  margin-top: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}
.preview-dialog {
  width: min(920px, calc(100vw - 32px));
  max-width: none;
  height: min(85vh, 900px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(23, 32, 29, .18);
}
.preview-dialog::backdrop {
  background: rgba(23, 32, 29, .45);
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f7faf8;
}
.preview-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 650;
}
.preview-header button {
  width: auto;
  min-height: 38px;
  padding: 0 14px;
  font-size: 14px;
}
.preview-dialog iframe {
  display: block;
  width: 100%;
  height: calc(100% - 63px);
  border: 0;
  background: white;
}
@media (max-width: 560px) {
  .file-item {
    grid-template-columns: 1fr;
  }
  .file-actions {
    justify-content: stretch;
  }
  .file-actions button {
    flex: 1 1 calc(50% - 4px);
  }
}
