:root {
  --page: #f4f7f5;
  --surface: #ffffff;
  --surface-muted: #f7faf8;
  --ink: #172326;
  --heading: #102b2c;
  --muted: #526467;
  --accent: #417175;
  --border: #cbdad5;
  --input-border: #aebfba;
  --topbar: #ffffff;
  --topbar-ink: #102b2c;
  --topbar-status: #526467;
  --button-hover: #e8f1ee;
  --logo-divider: #cbdad5;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --page: #142022;
  --surface: #1d2b2d;
  --surface-muted: #192628;
  --ink: #edf5f1;
  --heading: #ffffff;
  --muted: #b5c8c3;
  --accent: #9dcc3b;
  --border: #405553;
  --input-border: #5a706d;
  --topbar: #102b2c;
  --topbar-ink: #ffffff;
  --topbar-status: #c9dad6;
  --button-hover: #2a4141;
  --logo-divider: #42605c;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--page); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 32px; border-bottom: 1px solid var(--border); background: var(--topbar); color: var(--topbar-ink); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-logo { width: auto; height: 30px; object-fit: contain; }
.brand-logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo-dark { display: block; }
.brand-divider { width: 1px; height: 24px; background: var(--logo-divider); }
.brand-product { white-space: nowrap; }
.connection { display: flex; align-items: center; gap: 12px; }
.status { color: var(--topbar-status); font-size: 14px; }
.status.ready { color: var(--accent); }
.status.error { color: #ffc2b6; }
button { border: 1px solid var(--border); border-radius: 4px; padding: 9px 13px; background: var(--surface); color: var(--heading); font-weight: 650; }
button:hover { border-color: var(--accent); background: var(--button-hover); }
.topbar button { border-color: var(--border); background: var(--surface); }
.compact-select { width: auto; min-height: 36px; padding: 6px 8px; background: var(--surface); color: var(--heading); }
.icon-button { width: 36px; min-width: 36px; padding: 6px; font-size: 18px; line-height: 1; }

main { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 64px; }
.access-panel { max-width: 700px; padding: 28px 0 38px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
h1, h2 { margin: 0; color: var(--heading); letter-spacing: 0; }
h1 { font-size: 34px; line-height: 1.15; }
h2 { font-size: 20px; }
.access-panel > p:last-child { max-width: 600px; color: var(--muted); line-height: 1.55; }

.workspace { border-top: 1px solid var(--border); padding-top: 22px; }
.workspace-nav { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.workspace-nav button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; }
.workspace-nav button.active { border-bottom-color: var(--accent); color: var(--accent); }
.dao-page { min-height: 320px; }
.list-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.muted, .dao-index-status { color: var(--muted); }
.dao-groups { display: grid; gap: 24px; margin-top: 28px; }
.dao-group { border-top: 1px solid var(--border); padding-top: 18px; }
.dao-group h3, .detail-section h3 { margin: 0 0 8px; color: var(--heading); font-size: 17px; }
.dao-index-status { margin: 0 0 14px; font-size: 13px; }
.dao-list-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; align-items: center; gap: 14px; margin: 8px 0; padding: 14px; text-align: left; }
.dao-list-item span { overflow-wrap: anywhere; color: var(--muted); font-size: 13px; }
.dao-list-item span:last-child { color: var(--accent); font-weight: 700; }
.detail-heading { margin: 24px 0; }
.detail-heading h2 { font-size: 26px; overflow-wrap: anywhere; }
.detail-heading p:last-child { max-width: 760px; color: var(--muted); line-height: 1.5; }
.detail-section { border-top: 1px solid var(--border); padding: 20px 0; }
.detail-section summary { margin-bottom: 14px; color: var(--heading); cursor: pointer; font-weight: 700; }
.detail-fields { display: grid; grid-template-columns: minmax(130px, 220px) minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.detail-fields dt { color: var(--muted); font-size: 13px; }
.detail-fields dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 14px; }
.detail-fields .detail-fields { margin: 8px 0; }
.detail-array { display: grid; gap: 12px; }
.detail-array > .detail-fields { padding: 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-muted); }
.detail-token-panel { max-width: 520px; margin-top: 12px; padding-top: 24px; border-top: 1px solid var(--border); }
.token-selector { display: flex; gap: 0; width: max-content; border: 1px solid var(--border); }
.token-selector button { border: 0; border-right: 1px solid var(--border); border-radius: 0; min-width: 118px; background: transparent; }
.token-selector button:last-child { border-right: 0; }
.token-selector button.active { background: var(--heading); color: var(--surface); }
.type-note { min-height: 23px; margin: 14px 0 22px; color: var(--muted); font-size: 14px; }
.operator-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.surface { padding: 22px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.inspect-dao { grid-column: 1 / -1; }
.section-title { margin-bottom: 18px; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 14px; font-weight: 650; }
input, textarea { width: 100%; min-height: 40px; padding: 9px 10px; border: 1px solid var(--input-border); border-radius: 4px; background: var(--surface); color: var(--heading); }
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid #8fbfc0; outline-offset: 1px; border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 16px; min-height: 16px; }
.primary { border-color: var(--heading); background: var(--heading); color: var(--surface); }
.primary:hover { background: var(--accent); color: #102b2c; }
.danger { border-color: #bb6657; background: var(--surface); color: #c46c5e; }
.danger:hover { background: #fff0ec; }
.command-row { display: flex; gap: 10px; }
.inline-form { grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.result { min-height: 100px; max-height: 310px; overflow: auto; margin: 18px 0 0; padding: 14px; border: 1px solid var(--border); background: var(--surface-muted); color: var(--ink); font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.result.empty { color: var(--muted); }
.activity { position: fixed; right: 24px; bottom: 24px; width: min(460px, calc(100% - 48px)); padding: 14px 16px; border-left: 4px solid var(--accent); background: var(--heading); color: var(--surface); box-shadow: 0 10px 28px rgba(16, 43, 44, .25); line-height: 1.45; }
.activity.error { border-left-color: #ff9c87; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: rgba(16, 43, 44, .58); }
.modal[hidden] { display: none; }
.modal-dialog { width: min(560px, 100%); max-height: min(640px, calc(100vh - 48px)); overflow: auto; padding: 24px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); box-shadow: 0 20px 48px rgba(16, 43, 44, .35); }
.settings-dialog { width: min(440px, 100%); }
select { width: 100%; min-height: 40px; padding: 9px 10px; border: 1px solid var(--input-border); border-radius: 4px; background: var(--surface); color: var(--heading); }
.progress-track { height: 10px; overflow: hidden; border-radius: 2px; background: var(--border); }
.progress-value { width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.operation-message { min-height: 24px; margin: 16px 0 12px; color: var(--ink); }
.operation-events { display: grid; gap: 8px; max-height: 190px; overflow: auto; margin: 0 0 20px; padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.4; }
body.operation-active { overflow: hidden; }

@media (max-width: 760px) {
  .topbar { min-height: 112px; align-items: flex-start; flex-direction: column; padding: 16px 20px; }
  .brand-logo { height: 24px; }
  .brand-product { font-size: 14px; }
  .connection { width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
  .status { width: 100%; }
  main { width: min(100% - 32px, 1240px); padding-top: 34px; }
  h1 { font-size: 29px; }
  .operator-grid { grid-template-columns: 1fr; }
  .inspect-dao { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .token-selector { width: 100%; }
  .token-selector button { flex: 1; min-width: 0; padding-inline: 6px; }
  .dao-list-item { grid-template-columns: 1fr; gap: 4px; }
  .detail-fields { grid-template-columns: 1fr; gap: 3px; }
  .detail-fields dd { margin-bottom: 8px; }
}
