:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #61717f;
  --line: #d8e0ea;
  --line-strong: #bec9d6;
  --panel: #ffffff;
  --page: #f6f8fb;
  --soft: #eef3f8;
  --accent: #1769e0;
  --accent-dark: #0f4da8;
  --accent-soft: #eaf2ff;
  --teal: #0f8f7c;
  --success: #116b45;
  --success-bg: #e8f6ef;
  --warn: #945500;
  --warn-bg: #fff6e5;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 16px 42px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #eef3f8 0, var(--page) 280px, var(--page) 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button,
.button-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

button:hover:not(:disabled),
.button-link:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

button:active:not(:disabled),
.button-link:active {
  transform: translateY(1px);
}

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

button.secondary,
.button-link.secondary {
  border-color: var(--line-strong);
  background: #ffffff;
  color: var(--accent-dark);
}

button.secondary:hover:not(:disabled),
.button-link.secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

button.danger,
button.secondary.danger,
.history-actions button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

button.secondary.danger,
.history-actions button.danger {
  border-color: #ebb2ad;
  background: #ffffff;
  color: var(--danger);
}

button.danger:hover:not(:disabled),
button.secondary.danger:hover:not(:disabled),
.history-actions button.danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: #971d14;
}

button.secondary.danger:hover:not(:disabled),
.history-actions button.danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-bg);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(23, 105, 224, 0.22);
  outline-offset: 2px;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 0 40px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.page-shell {
  width: min(900px, calc(100vw - 32px));
}

.app-bar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 900;
}

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

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

h1 {
  font-size: clamp(1.55rem, 4vw, 2rem);
  line-height: 1.08;
}

h2 {
  font-size: clamp(1.15rem, 3vw, 1.45rem);
  line-height: 1.16;
}

h3 {
  font-size: 1rem;
  line-height: 1.28;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.upload-panel,
.secondary-panel {
  min-width: 0;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.primary-panel {
  position: relative;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.panel-header.compact {
  align-items: center;
  margin-bottom: 16px;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 112px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 900;
}

.status-pill.ready {
  border: 1px solid #b9e4cc;
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.blocked {
  border: 1px solid #f2d08d;
  background: var(--warn-bg);
  color: var(--warn);
}

.folder-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #f0c66e;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.upload-form {
  display: grid;
  gap: 16px;
}

.drop-zone {
  min-height: 245px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 28px;
  border: 2px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfdff;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone.dragging {
  transform: translateY(-1px);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-title {
  max-width: 100%;
  color: var(--ink);
  font-size: clamp(1.45rem, 5vw, 2.25rem);
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
  overflow-wrap: anywhere;
}

.drop-meta {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 700;
  text-align: center;
}

.actions,
.result,
.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.download-actions {
  margin-bottom: 18px;
}

.folder-target {
  margin: 0;
  color: var(--teal);
  font-size: 0.94rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.progress-wrap {
  margin-top: 24px;
}

.progress-label {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 160ms ease;
}

.progress-detail {
  min-height: 22px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

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

.result div {
  min-width: 0;
}

.result a {
  display: block;
  max-width: 100%;
  color: var(--ink);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.history-accordion {
  min-width: 0;
}

.history-summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  list-style: none;
}

.history-summary::-webkit-details-marker {
  display: none;
}

.history-summary::after {
  content: "+";
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 1.1rem;
  font-weight: 900;
}

.history-accordion[open] .history-summary::after {
  content: "-";
}

.accordion-title {
  display: block;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.16;
}

.history-summary-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
  white-space: nowrap;
}

.history-content {
  padding-top: 14px;
}

.history-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.history-list,
.folder-picker-list {
  display: grid;
  gap: 0;
}

.history-item,
.folder-picker-item {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.history-item:last-child,
.folder-picker-item:last-child {
  border-bottom: 1px solid var(--line);
}

.history-item > div:first-child,
.folder-picker-item > div:first-child {
  min-width: 0;
}

.history-item h3,
.folder-picker-item h3 {
  color: var(--ink);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.history-item p,
.folder-picker-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.history-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.history-actions a,
.history-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--accent-dark);
  font-size: 0.9rem;
  font-weight: 850;
  text-decoration: none;
}

.history-actions a:hover,
.history-actions button:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 38, 0.5);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(23, 32, 38, 0.24);
}

.confirm-panel {
  display: grid;
  gap: 18px;
}

.confirm-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 850;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
}

.field input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 105, 224, 0.18);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.confirm-actions {
  justify-content: flex-end;
  margin-bottom: 0;
}

.folder-picker-item button {
  flex: 0 0 auto;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 14px 34px rgba(23, 32, 38, 0.16);
  font-size: 0.94rem;
  font-weight: 800;
  pointer-events: auto;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-info {
  border-left-color: var(--accent);
}

.toast-leaving {
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.clipboard-fallback {
  position: fixed;
  inset-inline-start: -100vw;
  top: 0;
  width: 1px;
  height: 1px;
}

@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .history-panel {
    order: 2;
  }
}

@media (max-width: 640px) {
  .shell,
  .page-shell {
    width: min(100vw - 20px, 1180px);
    padding: 10px 0 24px;
  }

  .app-bar,
  .panel-header,
  .folder-header-actions,
  .actions,
  .download-actions,
  .result,
  .history-item,
  .folder-picker-item {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    width: 100%;
  }

  .status-pill,
  button,
  .button-link,
  .history-actions,
  .history-actions a,
  .history-actions button,
  .folder-picker-item button {
    width: 100%;
  }

  .history-summary {
    align-items: flex-start;
  }

  .history-summary-meta {
    display: none;
  }

  .drop-zone {
    min-height: 190px;
    padding: 22px;
  }

  .modal-panel {
    padding: 18px;
  }

  .modal-actions,
  .confirm-actions {
    flex-direction: column;
  }

  .toast-region {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

.file-summary {
  margin: 0 0 18px;
  overflow-wrap: anywhere;
}

.file-summary h2 {
  margin-bottom: 4px;
}

.info-panel {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.info-panel summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.info-panel ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.login-form {
  display: grid;
  gap: 14px;
  max-width: 420px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.workspace-grid.single {
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}
