/* SubMela — plain CSS, no build step. Proposed visual direction (UI_UX_DESIGN.md), not approved branding. */
:root {
    --bg: #f7f7fb;
    --surface: #ffffff;
    --ink: #17142b;
    --muted: #5b5873;
    --line: #e3e1ee;
    --primary: #6d28d9;
    --primary-ink: #ffffff;
    --primary-soft: #efe8fd;
    --success: #166534;
    --success-soft: #e7f6ec;
    --pending: #92400e;
    --pending-soft: #fdf3e2;
    --error: #b91c1c;
    --error-soft: #fdecec;
    --radius: 12px;
    --focus: 3px solid #a78bfa;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12101c; --surface: #1c1929; --ink: #f1effa; --muted: #b3afc8; --line: #2f2b42;
        --primary: #a78bfa; --primary-ink: #15112a; --primary-soft: #2a2244;
        --success: #86efac; --success-soft: #16301f; --pending: #fcd34d; --pending-soft: #33280f;
        --error: #fca5a5; --error-soft: #3a1717;
    }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: var(--primary); }
:focus-visible { outline: var(--focus); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 24px 0 12px; }
h2 { font-size: 1.2rem; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.inline { display: inline; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.3rem; text-decoration: none; color: var(--ink); }
.brand span { color: var(--primary); }
.top-nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.top-nav a { text-decoration: none; color: var(--ink); min-height: 44px; display: inline-flex; align-items: center; }
.dev-banner { margin: 0; padding: 8px 16px; text-align: center; background: var(--pending-soft); color: var(--pending); font-size: .9rem; }

.button, button.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px;
    background: var(--primary); color: var(--primary-ink); border: 0; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.button.secondary { background: var(--primary-soft); color: var(--primary); }
.button.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.button[disabled] { opacity: .55; cursor: not-allowed; }
.link-button { background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; min-height: 44px; padding: 0; }

.notice { padding: 12px 14px; border-radius: var(--radius); margin: 16px 0; }
.notice p { margin: 0; }
.notice.success { background: var(--success-soft); color: var(--success); }
.notice.error { background: var(--error-soft); color: var(--error); }
.notice.pending { background: var(--pending-soft); color: var(--pending); }

.search { display: flex; gap: 8px; margin: 8px 0 12px; }
.search input { flex: 1; min-width: 0; }
input, select { font: inherit; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
.check label { display: inline; font-weight: 400; }
.check input { width: auto; min-height: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.chips a { display: inline-flex; min-height: 36px; align-items: center; padding: 0 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); text-decoration: none; font-size: .9rem; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere; }
.card h3 { margin: 0; font-size: 1.05rem; }
.card .price { font-size: 1.25rem; font-weight: 700; }
.card .terms { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: .92rem; }
.card .actions { margin-top: auto; padding-top: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.narrow { max-width: 460px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 600; }
.badge.in_stock, .badge.delivered, .badge.fulfilled, .badge.credited { background: var(--success-soft); color: var(--success); }
.badge.checking, .badge.pending, .badge.reserved, .badge.procuring, .badge.purchase_unknown, .badge.pending_delivery, .badge.creating { background: var(--pending-soft); color: var(--pending); }
.badge.out_of_stock, .badge.unavailable, .badge.failed_released, .badge.manual_review, .badge.on_hold, .badge.mismatch, .badge.expired, .badge.problem { background: var(--error-soft); color: var(--error); }

dl.summary { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.summary dt { color: var(--muted); }
dl.summary dd { margin: 0; overflow-wrap: anywhere; }
.balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.balances .amount { font-size: 1.5rem; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px dashed var(--line); padding: 10px; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }

.site-footer { margin-top: 48px; padding: 24px 0 96px; border-top: 1px solid var(--line); color: var(--muted); font-size: .92rem; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; display: none; background: var(--surface); border-top: 1px solid var(--line); }
.bottom-nav a { flex: 1; text-align: center; padding: 12px 4px; min-height: 48px; text-decoration: none; color: var(--ink); font-size: .85rem; }

@media (max-width: 720px) {
    .top-nav a:not(.button), .top-nav form { display: none; }
    .bottom-nav { display: flex; }
    h1 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Forms and admin */
textarea { font: inherit; width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; padding: 8px 12px; }
legend { font-weight: 600; padding: 0 4px; }
details.panel > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.admin-nav { gap: 12px; font-size: .95rem; }
.admin .site-footer { display: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.pagination { display: flex; gap: 12px; list-style: none; padding: 0; margin: 12px 0; }
@media (max-width: 720px) { .admin .top-nav a:not(.button), .admin .top-nav form { display: inline-flex; } }

/* Chat */
.chat { margin-bottom: 16px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; }
.chat-log:empty { display: none; }
.chat-bubble { padding: 10px 12px; border-radius: 12px; max-width: 90%; overflow-wrap: anywhere; }
.chat-bubble.user { align-self: flex-end; background: var(--primary); color: var(--primary-ink); }
.chat-bubble.bot { align-self: flex-start; background: var(--primary-soft); color: var(--ink); }
.chat-bubble .chips { margin: 8px 0 0; }
.chat-bubble button.chip { display: inline-flex; min-height: 36px; align-items: center; padding: 0 12px; border-radius: 999px; border: 1px solid var(--primary); background: var(--surface); color: var(--primary); font: inherit; font-size: .9rem; cursor: pointer; }
.chat-cards { margin-top: 8px; }
.chat-note { font-size: .85rem; margin: 4px 0 0; }
.badge.refunded, .badge.partially_refunded { background: var(--primary-soft); color: var(--primary); }
