/* 浅色（默认） */
:root,
[data-theme="light"] {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-elevated: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --nav-hover-bg: #eef6ff;
  --nav-active-bg: #e7f3ff;
  --danger: #dc2626;
  --radius: 8px;
  --radius-sm: 8px;
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
  --btn-primary-text: #ffffff;
  --tab-active-bg: #ffffff;
}

[data-theme="dark"] {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-elevated: #243044;
  --border: rgba(255, 255, 255, 0.1);
  --text: #e8ecf4;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.15);
  --nav-hover-bg: rgba(96, 165, 250, 0.1);
  --nav-active-bg: rgba(96, 165, 250, 0.16);
  --danger: #f87171;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  --btn-primary-text: #0f172a;
  --tab-active-bg: var(--bg);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

[data-theme="light"] body {
  background-image: none;
}

[data-theme="dark"] body {
  background-image: none;
}

.layout-shell {
  min-height: 100vh;
}

.side-menu {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 200px;
  padding: 1rem 0.875rem;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.03);
}

.side-menu-brand {
  min-height: 55px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.2rem 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.side-brand-mark {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: block;
  border-radius: 8px;
  object-fit: contain;
}

.side-menu-brand strong {
  display: block;
  font-size: 1rem;
  line-height: 1.25;
  color: var(--text);
}

.side-menu-brand span {
  display: block;
  margin-top: 0.125rem;
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--text-muted);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.side-nav-item {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.side-nav-item svg {
  flex: 0 0 auto;
}

.side-nav-item:hover {
  color: var(--accent);
  background: var(--nav-hover-bg);
}

.side-nav-item.active {
  color: var(--accent);
  background: var(--nav-active-bg);
  border-color: transparent;
}

.app {
  min-width: 0;
  max-width: none;
  margin-left: 200px;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  margin-bottom: 0;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  color: var(--text-muted);
  display: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.logo img {
  width: 32px;
  height: 32px;
  display: block;
}

.header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
}

.subtitle {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-theme {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.btn-theme:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.btn-theme:active {
  transform: scale(0.96);
}

.btn-theme .theme-icon {
  display: block;
}

[data-theme="light"] .theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-icon-light {
  display: none;
}

.main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  flex: 1;
  align-items: start;
  width: 100%;
  max-width: none;
  padding: 1.5rem;
}

.tool-page[hidden] {
  display: none;
}

@media (max-width: 768px) {
  .main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .layout-shell {
    display: block;
  }

  .side-menu {
    position: static;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 0.65rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .side-menu-brand {
    display: none;
  }

  .side-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .side-nav-item {
    justify-content: center;
    min-height: 40px;
    padding: 0.55rem 0.5rem;
    font-size: 0.875rem;
  }

  .app {
    margin-left: 0;
  }

  .header {
    position: static;
  }

  .main {
    padding: 1rem;
  }
}

@media (max-width: 560px) {
  .side-nav-item {
    flex-direction: column;
    gap: 0.25rem;
    min-height: 58px;
    font-size: 0.75rem;
    text-align: center;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2,
.aa-section-head h3,
.aa-result-block h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.panel-heading p,
.aa-section-head p {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.panel-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 0.6rem;
  border-radius: 999px;
  background: var(--surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
}

.panel-badge.success {
  color: #047857;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.22);
}

.panel-input {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.node-section {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--surface-elevated), transparent);
}

.node-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.node-btn {
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.node-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.node-panel label {
  margin-top: 0;
}

.node-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.25rem;
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.tab {
  flex: 1 1 auto;
  min-width: 4.5rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--tab-active-bg);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

.tab-panels label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  margin-top: 0.75rem;
}

.tab-panels label:first-child {
  margin-top: 0;
}

.tab-panels input[type="text"],
.tab-panels input[type="url"],
.tab-panels input[type="email"],
.tab-panels input[type="tel"],
.tab-panels input[type="password"],
.tab-panels select,
.tab-panels textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tab-panels input:focus,
.tab-panels select:focus,
.tab-panels textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tab-panels textarea {
  resize: vertical;
  min-height: 4rem;
}

.btn-generate {
  width: 100%;
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  background: var(--accent);
  color: var(--btn-primary-text);
  transition: background 0.15s, transform 0.1s;
}

.btn-generate:hover {
  background: var(--accent-hover);
}

.btn-generate:active {
  transform: scale(0.99);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-row input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.advanced {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.advanced summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.advanced summary:hover {
  color: var(--text);
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

@media (max-width: 480px) {
  .advanced-grid {
    grid-template-columns: 1fr;
  }
}

.field label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field select {
  width: 100%;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  font-family: inherit;
}

.field-colors {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.field-colors input[type="color"] {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}

.hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.hint.error {
  color: var(--danger);
}

.panel-preview {
  position: sticky;
  top: 96px;
}

.preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.preview-frame {
  width: 100%;
  max-width: 320px;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  padding: 1rem;
}

.qr-host {
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-host img,
.qr-host canvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.preview-empty {
  text-align: center;
  color: var(--text-muted);
}

.preview-empty span {
  display: block;
  font-weight: 600;
  color: var(--text);
  opacity: 0.45;
}

.preview-empty small {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8125rem;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  width: 100%;
}

.btn {
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, opacity 0.15s, background 0.15s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--btn-primary-text);
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-success {
  background: #10b981;
  color: #ffffff;
  border: 1px solid #10b981;
}

.btn-success:not(:disabled):hover {
  background: #059669;
  border-color: #059669;
}

.btn-small {
  min-height: 32px;
  padding: 0.45rem 0.75rem;
  font-size: 0.8125rem;
}

.aa-page {
  grid-template-columns: minmax(520px, 1fr) minmax(420px, 0.72fr);
}

.aa-form-panel,
.aa-result-panel {
  min-width: 0;
}

.aa-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.aa-field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.aa-field input,
.aa-field select,
.amount-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
}

.aa-field input,
.aa-field select {
  padding: 0.6rem 0.75rem;
}

.aa-field input:focus,
.aa-field select:focus,
.amount-input:focus-within,
.aa-person-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.amount-input {
  display: flex;
  align-items: center;
  overflow: hidden;
}

.amount-input span {
  flex: 0 0 auto;
  padding-left: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
}

.amount-input input {
  min-height: 38px;
  padding-left: 0.35rem;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.amount-input input:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}

.aa-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.aa-participants {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.aa-person-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 96px 88px 34px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.aa-person-row input {
  width: 100%;
  min-height: 34px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.aa-toggle {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.aa-toggle input {
  width: 0.95rem;
  height: 0.95rem;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
}

.aa-remove-person {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.aa-remove-person:hover {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
}

.aa-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.aa-stat {
  min-height: 74px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.aa-stat span,
.aa-detail-item span,
.aa-settlement-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.aa-detail-item span {
  line-height: 1.55;
}

.aa-detail-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.aa-detail-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  margin-left: auto;
  flex-shrink: 0;
}

.aa-detail-money {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem 0.75rem;
  min-width: max-content;
}

.aa-amount-owed {
  color: #991b1b !important;
  font-weight: 700;
}

.aa-amount-paid {
  color: #1e3a8a !important;
  font-weight: 700;
}

.aa-net {
  color: #047857 !important;
  font-weight: 800;
  white-space: nowrap;
}

.aa-transfer-title {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.aa-transfer-name {
  color: var(--accent) !important;
}

.aa-transfer-action {
  color: #ea580c !important;
  font-weight: 900;
}

.aa-transfer-amount {
  color: var(--accent) !important;
}

.aa-stat strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.05rem;
  color: var(--text);
}

.aa-result-block {
  margin-top: 1.25rem;
}

.aa-detail-list,
.aa-settlement-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.aa-detail-item,
.aa-settlement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.aa-detail-item strong,
.aa-settlement-item strong {
  color: var(--text);
  font-size: 0.9375rem;
}

.aa-settlement-item strong {
  color: var(--accent);
}

.aa-settlement-note {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(245, 158, 11, 0.24);
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.12);
  color: #92400e;
  font-size: 0.8125rem;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.aa-page {
  grid-template-columns: minmax(520px, 0.92fr) minmax(0, 1.08fr);
  align-items: start;
}

.aa-project-panel,
.aa-people-panel,
.aa-result-panel {
  min-width: 0;
}

.aa-project-panel,
.aa-people-panel {
  grid-column: 1;
}

.aa-result-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 96px;
}

.aa-projects {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.aa-project-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(118px, 0.75fr) minmax(120px, 0.95fr) 34px;
  gap: 0.65rem;
  align-items: end;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.amount-input input::-webkit-outer-spin-button,
.amount-input input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.amount-input input {
  appearance: textfield;
}

.aa-remove-project {
  width: 34px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.aa-remove-project:hover {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.3);
}

.aa-person-row {
  grid-template-columns: 34px 60px 64px minmax(0, 1fr);
  align-items: center;
}

.aa-person-main {
  display: contents;
}

.aa-person-row .aa-person-name {
  grid-column: 2;
  width: 60px;
}

.aa-person-row .aa-person-weight {
  grid-column: 3;
  width: 64px;
}

.aa-person-projects {
  grid-column: 4;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  min-width: 0;
  padding-top: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.aa-person-row .aa-remove-person {
  grid-column: 1;
  grid-row: 1;
}

.aa-project-check-pill {
  flex: 0 0 auto;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.aa-project-check-pill input {
  width: 0.9rem;
  height: 0.9rem;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
}

.aa-project-check-pill:has(input:checked) {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: var(--nav-active-bg);
}

#aa-result-capture {
  background: var(--surface);
}

.aa-detail-item strong:first-child {
  color: var(--text);
}

.aa-detail-item strong:last-child {
  white-space: nowrap;
}

.empty-page {
  grid-template-columns: minmax(0, 1fr);
}

.empty-panel {
  min-height: 240px;
}

.key-page {
  grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.18fr);
  align-items: start;
}

.key-control-panel,
.key-result-panel {
  min-width: 0;
}

.key-type-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  padding: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.key-type {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.key-type.active {
  color: var(--accent);
  border-color: var(--border);
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.key-range {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.key-range-head,
.key-count-row,
.key-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.key-range-head label,
.key-count-row label {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
}

.key-range-head output {
  min-width: 56px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
  font-weight: 800;
}

.key-range input[type="range"] {
  width: 100%;
  margin-top: 1rem;
  accent-color: var(--accent);
}

.key-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.key-option {
  min-height: 48px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  cursor: pointer;
}

.key-option input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.key-option span {
  min-width: 0;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 700;
}

.key-option strong {
  color: var(--accent);
  font-size: 0.8125rem;
}

.key-option:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.key-option-wide {
  grid-column: 1 / -1;
}

.key-exclude-field {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.key-exclude-field label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 700;
}

.key-exclude-field input {
  width: 100%;
  min-height: 38px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}

.key-exclude-field input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.key-exclude-field p,
.key-result-head p {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.key-count-row {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.key-count-row input {
  width: 86px;
  min-height: 38px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
}

.key-output-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.key-output {
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 800;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.key-output-actions {
  display: flex;
  gap: 0.5rem;
}

.key-strength-meter {
  height: 8px;
  margin-top: 0.85rem;
  border-radius: 999px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
}

.key-strength-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #dc2626;
  transition: width 0.2s, background 0.2s;
}

.key-result-block {
  margin-top: 1.25rem;
}

.key-result-head h3 {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text);
}

.key-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.key-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.key-list-item code {
  min-width: 0;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.key-history-block {
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.key-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.key-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
}

.key-history-main {
  min-width: 0;
}

.key-history-main code {
  display: block;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.key-history-main span {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.key-history-empty {
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--surface-elevated);
  font-size: 0.8125rem;
}

.key-list-copy {
  min-width: 52px;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .aa-page {
    grid-template-columns: 1fr;
  }

  .aa-result-panel {
    grid-column: 1;
    grid-row: auto;
    position: static;
  }

  .key-page {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    gap: 0.85rem;
    padding: 0.75rem;
  }

  .panel {
    padding: 1rem;
  }

  .panel-heading,
  .aa-section-head {
    align-items: center;
    gap: 0.75rem;
  }

  .aa-page {
    grid-template-columns: 1fr;
  }

  .aa-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .aa-stat {
    min-height: 68px;
  }

  .aa-project-row {
    position: relative;
    grid-template-columns: 1fr;
    gap: 0.7rem;
    padding: 0.75rem;
  }

  .aa-project-row .aa-field:first-child {
    padding-right: 40px;
  }

  .aa-remove-project {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
  }

  .aa-person-main {
    display: grid;
    grid-template-columns: minmax(72px, 96px) 64px;
    gap: 0.5rem;
    grid-column: 1 / -1;
    padding-right: 40px;
  }

  .aa-person-row {
    position: relative;
    grid-template-columns: 1fr;
    gap: 0.7rem;
    align-items: start;
    padding: 0.75rem;
  }

  .aa-person-row .aa-person-name,
  .aa-person-row .aa-person-weight {
    grid-column: auto;
    width: 100%;
  }

  .aa-person-row .aa-remove-person {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    grid-column: auto;
    width: 32px;
    height: 32px;
  }

  .aa-person-projects {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .aa-toggle {
    justify-content: flex-start;
  }

  .aa-detail-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.75rem;
  }

  .aa-detail-info {
    gap: 0.15rem;
  }

  .aa-detail-projects {
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .aa-detail-side {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    margin-left: 0;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border);
  }

  .aa-detail-money {
    flex: 1 1 auto;
    justify-content: flex-start;
    min-width: 0;
  }

  .aa-net {
    margin-left: auto;
  }

  .aa-settlement-item {
    min-height: 46px;
    padding: 0.65rem 0.75rem;
  }

  .aa-transfer-title {
    flex-wrap: wrap;
    row-gap: 0.15rem;
  }

  .key-options {
    grid-template-columns: 1fr;
  }

  .key-output-card {
    grid-template-columns: 1fr;
  }

  .key-output-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .key-output-actions .btn,
  .key-result-head .btn {
    width: 100%;
  }

  .key-result-head {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 360px) {
  .aa-stats {
    grid-template-columns: 1fr;
  }

  .key-type-tabs {
    grid-template-columns: 1fr;
  }
}

.footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}
