:root {
  color-scheme: light;
  --bg: #f6f6f2;
  --surface: #ffffff;
  --surface-subtle: #f8f8f4;
  --surface-muted: #efefe8;
  --line: #e5e5dd;
  --line-strong: #d6d6cb;
  --text: #171917;
  --text-soft: #6f756f;
  --accent: #1d5f49;
  --accent-soft: #edf4f1;
  --warn: #8b6a1f;
  --warn-soft: #f7f1e1;
  --danger: #b64231;
  --danger-soft: #f9efec;
  --success: #1f7b58;
  --success-soft: #edf6f1;
  --shadow: 0 1px 2px rgba(15, 22, 17, 0.03);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --font-sans: "Avenir Next", "SF Pro Text", "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Menlo", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--text);
  background: #fbfbf8;
}

::selection {
  background: rgba(31, 109, 83, 0.14);
}

body.popup-body {
  width: 400px;
  min-height: 560px;
}

a {
  color: var(--accent);
}

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

.page-shell,
.popup-shell {
  padding: 20px;
}

.page-shell {
  max-width: 1080px;
  margin: 0 auto;
}

.popup-shell {
  padding: 14px;
}

.topbar {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.topbar__meta {
  display: none;
}

.topbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__actions--page {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar__title {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.topbar__subtitle {
  margin: 6px 0 0;
  max-width: 640px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.topbar__desc {
  margin: 0;
  max-width: 760px;
  color: var(--text-soft);
  line-height: 1.6;
}

.popup-shell .topbar {
  position: relative;
  margin-bottom: 14px;
  min-height: 38px;
}

.popup-shell .topbar__title {
  font-size: 22px;
}

.popup-shell .topbar__row--popup {
  align-items: flex-start;
  padding-right: 132px;
}

.popup-shell .topbar__actions--popup {
  position: absolute;
  top: 0;
  right: 0;
  justify-content: flex-end;
}

.popup-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  margin-bottom: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 16px;
  padding-right: 18px;
  border-right: 1px solid var(--line);
}

.content-stack,
.section-stack,
.panel-stack {
  display: grid;
  gap: 0;
}

.content-stack {
  padding-left: 20px;
}

.section-block {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.section-block--detail {
  padding-top: 12px;
}

.guide-strip,
.guide-list {
  display: grid;
  gap: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.guide-strip__item,
.guide-list__item {
  padding: 10px 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
  border-bottom: 1px solid var(--line);
}

.guide-strip__item:last-child,
.guide-list__item:last-child {
  border-bottom: 0;
}

.panel {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.panel--subtle,
.panel--muted {
  background: var(--surface-subtle);
}

.panel__inner {
  padding: 0 0 18px;
}

.popup-body .panel__inner {
  padding: 0;
}

.panel__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel__heading--stack {
  align-items: flex-start;
}

.panel__eyebrow {
  display: none;
}

.panel__title {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 700;
}

.panel__subtitle {
  margin: 6px 0 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill--accent {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(31, 109, 83, 0.16);
}

.pill--warm {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(139, 106, 31, 0.14);
}

.pill--danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(182, 66, 49, 0.14);
}

.pill--success {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(31, 123, 88, 0.14);
}

.nav-list {
  display: grid;
  gap: 2px;
}

.nav-button {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 9px 0 9px 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.nav-button:hover {
  transform: none;
  color: var(--accent);
}

.nav-button.is-active {
  border-left-color: var(--accent);
  background: transparent;
}

.nav-button__title {
  font-size: 13px;
  font-weight: 700;
}

.nav-button__desc {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.45;
}

.sidebar__hint {
  margin-top: 16px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.settings-section {
  display: none;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-section.is-active {
  display: block;
}

.form-grid,
.stack-sm {
  display: grid;
  gap: 12px;
}

.field-grid,
.split-grid,
.action-grid {
  display: grid;
  gap: 12px;
}

.field-grid,
.split-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-grid--priority > .button--large {
  grid-column: 1 / -1;
  min-height: 50px;
}

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

.field--full {
  grid-column: 1 / -1;
}

.field--inline-actions {
  padding-top: 2px;
}

.field__toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.field__status {
  min-height: auto;
  font-size: 13px;
}

.field__status[hidden] {
  display: none;
}

.field label {
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.whitelist-picker {
  display: grid;
  gap: 12px;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.whitelist-picker__section {
  display: grid;
  gap: 10px;
}

.whitelist-picker__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.whitelist-picker__selected {
  min-height: 34px;
  margin-bottom: 0;
}

.whitelist-picker__list {
  display: grid;
  gap: 0;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.whitelist-option {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: color 160ms ease;
}

.whitelist-option:hover {
  transform: none;
  color: var(--accent);
}

.whitelist-option.is-selected {
  border-bottom-color: rgba(31, 109, 83, 0.2);
  background: transparent;
}

.whitelist-option__domain {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
}

.whitelist-option__meta {
  flex: 0 0 auto;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.button:focus,
.nav-button:focus {
  outline: none;
  border-color: rgba(31, 109, 83, 0.4);
  box-shadow: 0 0 0 4px rgba(31, 109, 83, 0.08);
}

.field__hint,
.meta,
.meta-list {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.meta-list {
  display: grid;
  gap: 8px;
}

.info-card,
.callout,
.metric {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.info-card,
.callout {
  padding: 12px 0;
}

.info-card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.info-card__desc {
  margin: 6px 0 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.actions--end {
  justify-content: flex-end;
}

.button {
  appearance: none;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

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

.button--secondary {
  background: transparent;
  color: var(--accent);
  border-color: rgba(31, 109, 83, 0.12);
}

.button--ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}

.button--danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(182, 66, 49, 0.12);
}

.button--compact {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
}

.button--tiny {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 12px;
}

.footer-bar {
  display: grid;
  gap: 14px;
}

.status-text {
  min-height: 20px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.status-text.is-error {
  color: var(--danger);
}

.summary-list {
  display: grid;
  gap: 4px;
}

.summary-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

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

.summary-item__label {
  color: var(--text-soft);
  font-size: 13px;
}

.summary-item__value {
  font-weight: 700;
  text-align: right;
  word-break: break-word;
}

.progress-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-head__value {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.progress-head__summary,
.progress-head__meta {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
}

.results-workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: start;
}

.progress {
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress__bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #235b49 0%, #2d7c5d 100%);
  transition: width 220ms ease;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: 10px;
}

.metrics--spaced {
  margin-top: 12px;
}

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 4px;
}

.stat-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.stat-inline__label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.stat-inline__value {
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}

.metric {
  padding: 12px;
}

.metric--button {
  appearance: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.metric--button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.metric--button.is-active {
  border-color: rgba(31, 109, 83, 0.2);
  background: var(--accent-soft);
}

.result-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.result-nav__button {
  appearance: none;
  width: auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 0 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.result-nav__button:hover {
  transform: none;
  color: var(--accent);
}

.result-nav__button.is-active {
  background: transparent;
  border-bottom-color: var(--accent);
}

.result-nav__label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.result-nav__value {
  flex: none;
  min-width: 22px;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-align: right;
}

.result-detail {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.metric__label {
  display: block;
  color: var(--text-soft);
  font-size: 12px;
}

.metric__value {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.callout--spaced {
  margin-top: 16px;
}

.meta--top-gap {
  margin-top: 6px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.detail-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-switch__button,
.chip {
  appearance: none;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.detail-switch__button:hover,
.chip:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.detail-switch__button.is-active,
.chip.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(31, 109, 83, 0.18);
}

.chip--interactive {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chip__remove {
  font-size: 14px;
  line-height: 1;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.advanced-block {
  grid-column: 1 / -1;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}

.advanced-block__summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
}

.advanced-block__summary::-webkit-details-marker {
  display: none;
}

.advanced-block__content {
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.detail-panel {
  min-height: 220px;
  max-height: 320px;
  overflow-y: auto;
  padding-top: 10px;
  padding-right: 2px;
}

.detail-stack,
.record-list {
  display: grid;
  gap: 0;
}

.detail-group,
.record-item,
.empty-state {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.detail-group,
.record-item {
  padding: 12px 0;
}

.detail-group__title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

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

.bookmark-item {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.bookmark-item:hover {
  color: var(--accent);
}

.bookmark-item__title {
  font-size: 13px;
  font-weight: 700;
}

.bookmark-item__meta {
  color: var(--text-soft);
  font-size: 12px;
}

.record-item__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.record-item__title {
  font-size: 14px;
  font-weight: 700;
}

.record-item__meta,
.record-item__suggestion {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.6;
}

.record-item__reason {
  margin-top: 10px;
  line-height: 1.6;
}

.record-item__suggestion {
  margin-top: 8px;
}

.record-item__link {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  word-break: break-all;
}

.record-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.result-table th,
.result-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.result-table th {
  color: var(--text-soft);
  font-weight: 700;
}

.result-table td:last-child,
.result-table th:last-child {
  text-align: right;
}

.result-table tbody tr:last-child td {
  border-bottom: 0;
}

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

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.backup-row__meta {
  min-width: 0;
}

.backup-row__title {
  font-size: 14px;
  font-weight: 700;
  word-break: break-word;
}

.backup-row__desc {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.backup-row__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 12px 0;
}

.hidden {
  display: none !important;
}

.sidebar.panel {
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.sidebar .panel__inner {
  padding: 0;
}

.sidebar .panel__heading {
  display: none;
}

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

  .sidebar {
    position: static;
    padding-right: 0;
    padding-bottom: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content-stack {
    padding-left: 0;
    padding-top: 14px;
  }
}

@media (max-width: 720px) {
  .page-shell,
  .popup-shell {
    padding: 16px;
  }

  .field-grid,
  .split-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .topbar__row:not(.topbar__row--popup) {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar__actions--page {
    justify-content: flex-start;
  }

  .popup-shell .topbar__row--popup {
    padding-right: 132px;
  }

  .summary-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .summary-item__value {
    text-align: left;
  }

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

  .popup-body .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .popup-body .action-grid--priority > .button--large {
    grid-column: 1 / -1;
  }

  .popup-body .summary-item {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
  }

  .backup-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .backup-row__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .popup-body .summary-item__value {
    text-align: right;
  }

  .popup-body .progress-head,
  .popup-body .record-item__row {
    align-items: flex-start;
  }

  .popup-body .results-workspace {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-strip {
    gap: 12px;
  }

  .popup-body .result-nav__button {
    width: auto;
    min-width: 78px;
    padding: 8px 10px;
  }

  .popup-body .result-nav__value {
    font-size: 15px;
  }
}
