:root {
  color-scheme: light;
  --font-main: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --bg: #faf7f1;
  --paper: rgba(255, 254, 251, 0.96);
  --paper-soft: #fffaf3;
  --ink: #4b382f;
  --muted: #806d63;
  --line: #e8ddd2;
  --line-strong: #dbc7b5;
  --accent: #b8653f;
  --accent-dark: #924b2d;
  --accent-soft: #f7e5d4;
  --success: #397255;
  --success-bg: #edf7f0;
  --danger: #a2433b;
  --danger-bg: #fff0ed;
  --warning: #8c612a;
  --warning-bg: #fff7e8;
  --shadow: 0 8px 22px rgba(112, 73, 45, 0.05);
  font-family: var(--font-main);
  font-size: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(238, 196, 148, 0.14), transparent 32rem),
    var(--bg);
  line-height: 1.5;
}

body,
input,
select,
textarea,
button {
  font-family: var(--font-main);
}

button, input, select, textarea { font-size: inherit; }

button, select, input { color: inherit; }

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 60px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--font-main);
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.025em;
}

.lede {
  max-width: 690px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.local-badge {
  margin-top: 4px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  font-size: 0.76rem;
  font-weight: 700;
}

.head-badges {
  display: grid;
  justify-items: end;
  gap: 6px;
  flex: none;
}

.version-badge {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
}

.notice {
  margin-bottom: 18px;
  padding: 10px 13px;
  border: 1px solid #ebd7b9;
  border-radius: 9px;
  color: #755631;
  background: var(--warning-bg);
  font-size: 0.86rem;
}

.notice p { margin: 0; }

.panel {
  margin-top: 15px;
  padding: 19px 20px 21px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.section-head > div { display: flex; align-items: center; gap: 10px; }

.section-head h2 {
  margin: 0;
  font-family: var(--font-main);
  font-size: 1.48rem;
  font-weight: 700;
}

.section-head p { margin: 0; color: var(--muted); font-size: 0.8rem; }

.step {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 16px;
}

label { display: grid; gap: 6px; min-width: 0; }

label > span:first-child,
.publish-bar label > span {
  color: #675249;
  font-size: 0.86rem;
  font-weight: 720;
  letter-spacing: 0.025em;
}

label small {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: #fffefd;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus, select:focus, textarea:focus {
  border-color: #d69970;
  box-shadow: 0 0 0 3px rgba(202, 126, 79, 0.12);
}

input[type="file"] { padding: 6px; }

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  cursor: pointer;
}

.span-2 { grid-column: 1 / -1; }

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input { padding-right: 62px; }

button.password-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  min-height: 28px;
  padding: 3px 9px;
  border: 0;
  box-shadow: none;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 0.72rem;
}

.field-note { margin: 10px 0 0; color: var(--muted); font-size: 0.78rem; }
.field-note code { color: #704735; }

.actions { display: flex; align-items: center; gap: 8px; }
.actions.wrap { flex-wrap: wrap; margin-top: 16px; }

button {
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: #654a3d;
  background: #fffdf9;
  box-shadow: 0 2px 7px rgba(112, 73, 45, 0.045);
  cursor: pointer;
  font-size: 0.93rem;
  font-weight: 700;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover:not(:disabled) { border-color: #d5a47f; background: var(--paper-soft); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: 0.48; }

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

button.primary:hover:not(:disabled) { border-color: var(--accent-dark); background: var(--accent-dark); }
.compact-select { width: min(270px, 100%); }

.connection-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.connection-bar .actions.wrap { margin-top: 0; }
.connection-state { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; }
.connection-state::before { width: 8px; height: 8px; border-radius: 50%; background: currentColor; content: ""; }
.connection-state.connected { color: var(--success); }
.connection-state.disconnected { color: var(--muted); }
.connection-state.checking { color: var(--warning); }

.status { min-height: 0; margin-top: 12px; font-size: 0.84rem; }
.status:empty { display: none; }
.status.success, .status.error, .status.info, .status.warning { padding: 9px 11px; border-radius: 8px; }
.status.success { color: var(--success); background: var(--success-bg); }
.status.error { color: var(--danger); background: var(--danger-bg); }
.status.info { color: #5a5f65; background: #f3f4f5; }
.status.warning { color: var(--warning); background: var(--warning-bg); }

.api-log {
  margin-top: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffefd;
}

.api-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbf7f1;
}

.api-log-head strong { font-size: 0.78rem; }

.api-log-head button {
  min-height: 28px;
  padding: 3px 8px;
  font-size: 0.7rem;
}

.api-log ol,
#apiLog {
  max-height: 190px;
  margin: 0;
  padding: 8px 10px 8px 34px;
  overflow: auto;
  font: 0.76rem/1.55 "SFMono-Regular", Consolas, monospace;
}

#apiLog li { padding: 2px 0; overflow-wrap: anywhere; }
#apiLog .log-info { color: #665b55; }
#apiLog .log-success { color: var(--success); }
#apiLog .log-error { color: var(--danger); }
#apiLog .log-warning { color: var(--warning); }
#apiLog .log-muted { color: var(--muted); }

.summary-strip {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 0.82rem;
}

.summary-strip strong { color: var(--ink); }

.table-wrap {
  max-width: 100%;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #715c51; background: #fbf6ef; font-size: 0.72rem; letter-spacing: 0.025em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-index] { cursor: pointer; }
tbody tr[data-index]:hover { background: #fffaf4; }
td code { color: #8e4e31; font-size: 0.76rem; }
.result-error { color: var(--danger); }
.result-link { color: var(--accent-dark); overflow-wrap: anywhere; }
.action-pill { display: inline-block; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); font-size: 0.7rem; font-weight: 750; }
.publish-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 0.72rem; overflow-wrap: anywhere; }

.preview-panel { margin-top: 14px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; background: #fbf6ef; }
.preview-head strong { font-size: 0.8rem; }
.preview-head button { min-height: 30px; padding: 4px 9px; font-size: 0.73rem; }
pre { max-height: 440px; margin: 0; padding: 13px; overflow: auto; color: #493d38; background: #fff; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.55 "SFMono-Regular", Consolas, monospace; }

.publish-bar { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.publish-bar label { width: min(300px, 100%); }

.urls-output { margin-top: 14px; }

.urls-output textarea {
  width: 100%;
  min-height: 210px;
  padding: 11px 12px;
  resize: vertical;
  color: #493d38;
  background: #fffefd;
  font: 0.8rem/1.55 "SFMono-Regular", Consolas, monospace;
}

.progress-area { margin-top: 14px; }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: #eee4da; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #d78b59, var(--accent)); transition: width 180ms ease; }
.metrics { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 9px; color: var(--muted); font-size: 0.76rem; }
.metrics strong { margin-left: 3px; color: var(--ink); }

@media (max-width: 720px) {
  .shell { width: min(100% - 20px, 1120px); padding-top: 22px; }
  .page-head, .section-head, .publish-bar, .connection-bar { align-items: stretch; flex-direction: column; }
  .local-badge { align-self: flex-start; }
  .head-badges { justify-items: start; }
  .section-head { gap: 5px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel { padding: 17px 14px 19px; }
  .publish-bar label { width: 100%; }
  .actions { flex-wrap: wrap; }
  .compact-select { width: 100%; }
}
