:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --strong-border: #cbd5e1;
  --accent: #111827;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --success: #067647;
  --success-soft: #ecfdf3;
  --warning: #946300;
  --warning-soft: #fffaeb;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.055);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0;
}

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

.tool-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
}

.tab-button {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 780;
}

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

.tool-panel {
  display: none;
}

.tool-panel.is-active {
  display: block;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.controls-panel {
  position: sticky;
  top: 8px;
  z-index: 10;
  padding: 8px;
  margin-bottom: 8px;
}

.controls-row {
  display: grid;
  grid-template-columns: auto 92px minmax(180px, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: end;
}

.pdf-controls-row {
  display: grid;
  grid-template-columns: auto 100px 100px minmax(150px, 1fr) auto auto auto;
  gap: 8px;
  align-items: end;
}

.date-controls-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: end;
}

.case-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.notes-controls-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: end;
}

.upload-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px dashed var(--strong-border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 760;
  white-space: nowrap;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.upload-button input {
  display: none;
}

.upload-button.is-dragging {
  border-color: var(--accent);
  background: #eef2f7;
  transform: translateY(-1px);
}

.drop-note {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.field {
  display: grid;
  gap: 3px;
}

.field span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 760;
  line-height: 1;
}

.field input {
  width: 100%;
  height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.field input:focus {
  border-color: #9ca3af;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06);
}

.primary-button,
.secondary-button,
.ghost-danger-button,
.danger-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.86rem;
  font-weight: 760;
  white-space: nowrap;
}

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

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

.danger-button,
.ghost-danger-button {
  border-color: rgba(180, 35, 24, 0.14);
  background: var(--danger-soft);
  color: var(--danger);
}

.ghost-danger-button {
  background: transparent;
}

.files-panel {
  padding: 8px;
}

.inline-summary {
  margin: 7px 1px 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.file-list {
  display: grid;
  gap: 7px;
}

.empty-state {
  padding: 18px 12px;
  border: 1px dashed var(--border);
  border-radius: 11px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
  font-size: 0.9rem;
}

.file-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}

.thumb {
  width: 72px;
  height: 104px;
  border-radius: 9px;
  background: #eef0f2;
  object-fit: cover;
}

.file-title-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.file-title-row h3 {
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  letter-spacing: -0.01em;
}

.file-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.file-main {
  min-width: 0;
  align-self: start;
}

.name-action-row {
  display: grid;
  grid-template-columns: minmax(180px, 420px) auto;
  gap: 8px;
  align-items: end;
  margin-top: 7px;
}

.output-name-field {
  min-width: 0;
}

.file-card .field input {
  height: 31px;
  border-radius: 8px;
  font-size: 0.84rem;
}

.file-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: end;
}

.small {
  min-height: 31px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.file-meta strong {
  color: var(--text);
  font-weight: 720;
}

.status {
  display: inline-flex;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 7px;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
}

.status.done {
  background: var(--success-soft);
  color: var(--success);
}

.status.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.status.converting,
.status.best-effort {
  background: var(--warning-soft);
  color: var(--warning);
}

.progress {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.error {
  margin: 5px 0 0;
  color: var(--danger);
  font-size: 0.74rem;
  font-weight: 650;
}

.archive-card,
.date-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}

.archive-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.archive-title {
  margin: 0 0 2px;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.archive-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.archive-list {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.archive-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 80px;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
}

.date-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.date-result-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.date-result-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
}

.date-result-value {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 820;
  letter-spacing: -0.035em;
}

.date-result-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.date-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.archive-row:last-child {
  border-bottom: 0;
}

.archive-row strong {
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 920px) {
  .controls-row {
    grid-template-columns: auto 84px minmax(140px, 1fr) auto auto auto auto;
  }

  .pdf-controls-row {
    grid-template-columns: auto 90px 90px minmax(120px, 1fr) auto auto auto;
  }

  .date-controls-row {
    grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) auto auto auto auto;
  }

  .primary-button,
  .secondary-button,
  .ghost-danger-button,
  .danger-button {
    padding-inline: 9px;
  }

  .name-action-row {
    grid-template-columns: minmax(140px, 1fr) auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 16px, 1120px);
    padding: 10px 0;
  }

  .site-header {
    display: grid;
    gap: 8px;
    align-items: start;
  }

  .tool-tabs {
    width: 100%;
  }

  .tab-button {
    flex: 1;
  }

  .controls-panel {
    position: static;
  }

  .controls-row,
  .pdf-controls-row,
  .date-controls-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-button,
  .rename-field,
  .skip-field,
  .primary-button,
  .secondary-button,
  .ghost-danger-button {
    width: 100%;
  }

  .rename-field,
  .skip-field {
    grid-column: 1 / -1;
  }

  .date-result-grid {
    grid-template-columns: 1fr;
  }

  .file-card {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .thumb {
    width: 58px;
    height: 86px;
  }

  .file-title-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .status {
    width: fit-content;
  }

  .name-action-row {
    grid-template-columns: 1fr;
  }

  .file-actions {
    flex-wrap: wrap;
  }
}


.case-grid,
.notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.textarea-field {
  display: grid;
  gap: 5px;
}

.textarea-field span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 780;
}

.textarea-field textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  outline: none;
  font: inherit;
  line-height: 1.45;
}

.textarea-field textarea:focus {
  border-color: #9ca3af;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06);
}

.todo-panel {
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
  overflow: hidden;
}

.todo-list {
  display: grid;
  gap: 0;
}

.todo-empty {
  padding: 18px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.todo-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 8px 9px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.todo-item:last-child {
  border-bottom: 0;
}

.todo-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.todo-text {
  min-width: 0;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.todo-item.is-done .todo-text {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-remove {
  min-height: 26px;
  padding: 3px 7px;
  border: 1px solid rgba(180, 35, 24, 0.14);
  border-radius: 7px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 760;
}

@media (max-width: 760px) {
  .case-grid,
  .notes-grid {
    grid-template-columns: 1fr;
  }

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

  .todo-input-field {
    grid-column: 1 / -1;
  }

  .textarea-field textarea,
  .todo-panel {
    min-height: 240px;
  }
}
