:root {
  color-scheme: light;
  --ink: #17201f;
  --muted: #62706d;
  --line: #dbe2df;
  --surface: #ffffff;
  --wash: #f4f7f5;
  --brand: #147d64;
  --brand-dark: #0d604d;
  --accent: #d86045;
  --danger: #b42318;
  --shadow: 0 16px 50px rgba(23, 32, 31, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--wash);
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.site-header {
  height: 68px;
  padding: 0 max(24px, calc((100vw - 880px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
}

.brand img { width: 32px; height: 32px; object-fit: contain; }
.brand strong { color: var(--brand); font-weight: 650; }

.secure-label, .expiry, .transport-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.secure-label svg, .expiry svg, .transport-status svg { width: 16px; height: 16px; }

main {
  width: min(880px, calc(100% - 32px));
  min-height: calc(100vh - 132px);
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 44px 0;
}

.pair-panel, .transport-panel, .upload-panel, .success-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.pair-panel { max-width: 660px; padding: 40px; }
.transport-panel, .upload-panel { padding: 0 40px 40px; }
.success-panel { max-width: 600px; padding: 56px 40px; text-align: center; }

.section-heading {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 30px;
}

.step-index {
  flex: 0 0 auto;
  min-width: 38px;
  padding-top: 4px;
  color: var(--accent);
  font: 650 13px/1.4 ui-monospace, "Cascadia Mono", monospace;
}

h1 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 650; }
.section-heading p, .success-panel p { margin: 7px 0 0; color: var(--muted); line-height: 1.6; }

#code-form { display: flex; align-items: center; gap: 18px; }

.code-fields {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(3, 58px) 18px repeat(3, 58px);
  gap: 8px;
}

.code-input {
  width: 58px;
  height: 62px;
  padding: 0;
  border: 1px solid #b9c5c1;
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
  text-align: center;
  font: 650 25px/1 ui-monospace, "Cascadia Mono", monospace;
  text-transform: uppercase;
  caret-color: var(--brand);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.code-input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.14);
}

.code-separator { width: 12px; height: 2px; align-self: center; justify-self: center; background: #9eaaa6; }

.primary-button, .secondary-button {
  min-height: 46px;
  border-radius: 6px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 20px;
  font-weight: 600;
}

.primary-button { color: #fff; background: var(--brand); }
.primary-button:hover { background: var(--brand-dark); }
.primary-button:disabled { cursor: wait; opacity: 0.58; }
.secondary-button { color: var(--ink); border-color: var(--line); background: #fff; }
.primary-button svg, .secondary-button svg { width: 18px; height: 18px; }

.form-message { margin: 18px 0 0; font-size: 14px; }
.error-message { color: var(--danger); }

.session-bar {
  min-height: 58px;
  margin: 0 -40px 36px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: #fafbfa;
  border-radius: 8px 8px 0 0;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
}

.icon-button:hover { color: var(--ink); background: #edf1ef; }
.icon-button svg { width: 19px; height: 19px; }

.session-identity { min-width: 0; display: flex; align-items: baseline; gap: 9px; font-size: 13px; color: var(--muted); }
.session-identity strong { color: var(--ink); font: 650 15px/1 ui-monospace, "Cascadia Mono", monospace; }
.transport-status { margin-left: auto; }
.transport-status.local { color: var(--brand); }
.transport-status.cloud { color: var(--muted); }
.expiry { margin-left: auto; }
.request-heading { margin-bottom: 22px; }

.choice-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.choice-file {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: #fafbfa;
  font-size: 13px;
}

.choice-file span:last-child { color: var(--muted); font-size: 12px; }
.transport-options { margin-top: 26px; }
.endpoint-field { display: grid; gap: 8px; margin-bottom: 18px; color: var(--muted); font-size: 13px; }
.endpoint-field select {
  width: 100%;
  min-height: 44px;
  padding: 0 38px 0 12px;
  border: 1px solid #b9c5c1;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}
.endpoint-field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.14); }
.transport-buttons { display: flex; justify-content: flex-end; gap: 12px; }
.transport-buttons .primary-button, .transport-buttons .secondary-button { min-width: 150px; }

.file-list { border-top: 1px solid var(--line); }

.file-row {
  min-height: 82px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(200px, 1.4fr) auto;
  align-items: center;
  gap: 20px;
}

.file-meta { min-width: 0; }
.file-label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.required-badge { color: var(--accent); font-size: 12px; font-weight: 600; }
.optional-badge { color: var(--muted); font-size: 12px; }
.file-accept, .file-selection { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.file-selection { margin: 0; text-align: right; }
.file-selection.has-file { color: var(--ink); }

.file-picker {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-picker label {
  width: 42px;
  height: 42px;
  border: 1px solid #b9c5c1;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: #fff;
  cursor: pointer;
}
.file-picker label:hover { border-color: var(--brand); background: #f2faf7; }
.file-picker svg { width: 19px; height: 19px; }

.upload-actions { margin-top: 28px; display: flex; align-items: flex-end; gap: 24px; }
.upload-actions .primary-button { margin-left: auto; flex: 0 0 auto; }
.progress-wrap { flex: 1 1 auto; min-width: 160px; }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 9px; color: var(--muted); font-size: 13px; }
.progress-copy strong { color: var(--ink); }
.progress-track { width: 100%; height: 7px; overflow: hidden; border-radius: 4px; background: #e5ebe8; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--brand); transition: width 120ms linear; }

.success-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
}
.success-mark svg { width: 28px; height: 28px; }
.success-panel .secondary-button { margin-top: 26px; }

footer {
  min-height: 64px;
  padding: 0 max(24px, calc((100vw - 880px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 12px;
}

[hidden] { display: none !important; }

@media (max-width: 720px) {
  .site-header { height: 60px; padding: 0 16px; }
  .secure-label span { display: none; }
  main { width: min(100% - 20px, 600px); min-height: calc(100vh - 116px); padding: 24px 0; }
  .pair-panel, .transport-panel, .upload-panel { padding: 26px 18px; }
  .success-panel { padding: 44px 20px; }
  .section-heading { gap: 8px; margin-bottom: 24px; }
  .step-index { min-width: 30px; }
  h1 { font-size: 21px; }
  #code-form { display: block; }
  .code-fields { grid-template-columns: repeat(3, minmax(36px, 1fr)) 12px repeat(3, minmax(36px, 1fr)); gap: 5px; }
  .code-input { width: 100%; height: 54px; font-size: 21px; }
  #connect-button { width: 100%; margin-top: 18px; }
  .session-bar { margin: -26px -18px 28px; padding: 0 12px; }
  .transport-buttons { flex-direction: column; }
  .transport-buttons .primary-button, .transport-buttons .secondary-button { width: 100%; }
  .transport-status { margin-left: auto; }
  .transport-status span { display: none; }
  .expiry { margin-left: 0; }
  .expiry span { display: none; }
  .file-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .file-selection { grid-column: 1; grid-row: 2; text-align: left; }
  .file-picker { grid-column: 2; grid-row: 1 / span 2; }
  .upload-actions { align-items: stretch; flex-direction: column; }
  .upload-actions .primary-button { width: 100%; margin-left: 0; }
  footer { min-height: 56px; padding: 0 16px; }
  footer span:last-child { text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
