/* Arcui layout. Colors come from tokens.css — never re-derive them. */

:root {
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-display);
    line-height: 1.5;
}

body {
    overflow-x: hidden;
}

button:not(:disabled),
[role="button"]:not(:disabled) {
    cursor: pointer;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

a {
    color: var(--sheen);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

::selection {
    background: color-mix(in oklab, var(--sheen) 28%, transparent);
}

.iridescence {
    height: 4px;
    background: var(--iridescence);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--hairline);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
}

.header-inner,
.page,
.site-footer {
    width: min(1120px, calc(100% - 32px));
    margin-inline: auto;
    max-width: 100%;
}

.header-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
}

.mark {
    width: 32px;
    height: 32px;
    flex: none;
    color: var(--ink);
}

.brand {
    min-width: 0;
    flex: 1 1 auto;
}

.eyebrow {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-faint);
}

h1 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: none;
}

.header-actions #network {
    width: auto;
    max-width: 120px;
    margin-top: 0;
    flex: none;
    padding: 0 10px;
}

.wallet-menu {
    position: relative;
    flex: none;
}

#wallet-btn {
    width: auto;
    max-width: 160px;
    padding: 0 12px;
    flex: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

#wallet-btn.connected {
    border-color: var(--sheen);
    color: var(--sheen);
    font-family: var(--font-mono);
    font-size: 12px;
}

#wallet-btn img,
.wallet-choice img {
    width: 18px;
    height: 18px;
    border-radius: 3px;
}

.wallet-pop {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 30;
    min-width: 208px;
    padding: 4px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.wallet-choice,
.wallet-account,
.wallet-disconnect {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.wallet-choice.active,
.wallet-account.active {
    color: var(--sheen);
}

.wallet-choice:hover:not(:disabled),
.wallet-account:hover,
.wallet-disconnect:hover {
    background: color-mix(in oklab, var(--sheen) 8%, transparent);
}

.wallet-disconnect {
    border-top: 1px solid var(--hairline);
    color: var(--text-muted);
    margin-top: 4px;
}

.page {
    display: grid;
    gap: 24px;
    padding: 24px 0 16px;
}

@media (min-width: 900px) {
    .page {
        grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
        align-items: start;
    }
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-width: 0;
}

.card.dashed {
    border-style: dashed;
}

.card.accent {
    border-color: color-mix(in oklab, var(--sheen) 40%, var(--hairline));
}

.lede {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.chip,
.btn,
select,
input,
textarea {
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-sm);
}

.chip,
.btn,
select,
input[type="text"],
input:not([type]),
input[inputmode],
.filter-methods {
    min-height: 44px;
}

.chip,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}

.chip:hover,
.btn:hover:not(:disabled) {
    border-color: var(--sheen);
    text-decoration: none;
}

.chip.active {
    background: var(--sheen);
    border-color: var(--sheen);
    color: var(--paper);
}

.btn.active {
    border-color: var(--sheen);
    color: var(--sheen);
}

.btn-ink {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}
.btn-ink:hover:not(:disabled) {
    opacity: 0.9;
    border-color: var(--ink);
}

.btn-ghost {
    background: transparent;
}

.btn-icon {
    width: 44px;
    min-width: 44px;
    padding: 0;
    flex: none;
}
.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-selector {
    flex: none;
    padding: 0 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
    font-weight: 400;
}

.row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    min-width: 0;
}

.row > input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    margin-top: 0;
}

.row > .btn {
    flex: none;
}

.row.extra {
    margin-top: 12px;
}

.grow {
    flex: 1;
    min-width: 0;
}

label.field {
    display: block;
    margin-top: 16px;
}

/* ABI arg names stay lowercase (beats not BEATS). Shouting is .eyebrow / .eyebrow-lbl only. */
.lbl {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
}

.lbl .type {
    color: var(--text-muted);
}

.eyebrow-lbl {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-faint);
}

label.field input,
label.field select,
.filter-methods {
    width: 100%;
    padding: 0 12px;
    margin-top: 4px;
}

textarea {
    width: 100%;
    padding: 10px 12px;
    margin-top: 12px;
    min-height: 88px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.45;
}

select,
input {
    font-family: var(--font-mono);
    font-size: 13px;
}

.header-actions select,
.header-actions input,
.header-actions .btn {
    margin-top: 0;
}

.filter-methods {
    margin: 0;
    background: var(--surface);
}

.msg {
    margin: 12px 0 0;
    font-size: 0.875rem;
}
.msg.error { color: var(--danger); }
.msg.muted { color: var(--text-muted); }
.msg.success { color: var(--success); }

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

.app-head h2 {
    margin: 4px 0 0;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.app-head-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex: none;
}

.meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.meta dt {
    color: var(--text-faint);
}
.meta dd {
    margin: 4px 0 0;
    overflow-wrap: anywhere;
}

.state-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
}

.state-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--hairline);
    font-family: var(--font-mono);
    font-size: 12px;
}

.state-list .k { color: var(--text-muted); min-width: 0; overflow-wrap: anywhere; }
.state-list .v { overflow-wrap: anywhere; text-align: right; }

.box-btn {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    background: none;
    border: none;
    border-top: 1px solid var(--hairline);
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    color: inherit;
    text-align: left;
}
.box-btn .name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}
.box-btn .open {
    color: var(--sheen);
    flex: none;
}

.box-value {
    margin: 8px 0 0;
    padding: 10px 12px;
    background: var(--paper);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    white-space: pre-wrap;
    overflow-x: auto;
    overflow-wrap: anywhere;
}

.method-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.method-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.method h3 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.sig {
    margin: 4px 0 0;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
    overflow-wrap: anywhere;
}

.desc {
    margin: 12px 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    white-space: pre-line;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
    vertical-align: middle;
    flex: none;
}

.warn {
    color: var(--warning);
    font-family: var(--font-mono);
    font-size: 11px;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

@media (min-width: 640px) {
    .actions {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .actions .btn {
        flex: 1 1 140px;
    }
}

.result {
    margin: 12px 0 0;
    padding: 10px 12px;
    background: var(--paper);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
    overflow-x: auto;
    overflow-wrap: anywhere;
}
.result.ok { color: var(--success); }
.result.fail { color: var(--danger); }

.grid-3 {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.grid-3 > .field {
    margin-top: 0;
}

@media (min-width: 640px) {
    .grid-3 {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.kv {
    display: grid;
    gap: 8px;
    margin-top: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
}
.kv div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
@media (min-width: 640px) {
    .kv div {
        flex-direction: row;
        justify-content: space-between;
        gap: 16px;
    }
}
.kv dt { color: var(--text-faint); flex: none; }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0 40px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
}

.site-footer nav {
    display: flex;
    gap: 16px;
}

/* Official sun/moon toggle, 44px tap target */
.corvid-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: 1px solid var(--ink-12);
    color: var(--ink-70);
    cursor: pointer;
    flex: none;
    transition: border-color 0.2s, color 0.2s;
}
.corvid-theme-toggle:hover {
    border-color: var(--sheen);
    color: var(--sheen);
}
.corvid-theme-toggle:focus-visible {
    outline: 2px solid var(--sheen);
    outline-offset: 2px;
}
.corvid-theme-toggle svg {
    width: 17px;
    height: 17px;
}
.corvid-theme-toggle .moon { display: none; }
:root[data-theme="dark"] .corvid-theme-toggle .sun { display: none; }
:root[data-theme="dark"] .corvid-theme-toggle .moon { display: inline; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .corvid-theme-toggle .sun { display: none; }
    :root:not([data-theme="light"]) .corvid-theme-toggle .moon { display: inline; }
}
:root[data-theme="light"] .corvid-theme-toggle .sun { display: inline; }
:root[data-theme="light"] .corvid-theme-toggle .moon { display: none; }

@media (max-width: 420px) {
    .header-inner {
        gap: 8px;
    }
    .header-actions {
        gap: 6px;
    }
    #wallet-btn {
        max-width: 132px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .chip, .btn, .corvid-theme-toggle {
        transition: none;
    }
}
