/* ================================================================
   OpenCodex+ styles — dark terminal-inspired aesthetic
   ================================================================ */

:root {
    --bg:        #0a0b0d;
    --bg-elev:   #111316;
    --bg-card:   #15171c;
    --border:    #25282f;
    --border-soft: #1c1f25;
    --text:      #e8eaed;
    --text-dim:  #9aa0a6;
    --text-mute: #6b7075;
    --accent:    #10a37f;          /* OpenAI-ish teal */
    --accent-hi: #15c393;
    --accent-dim:#0a6b52;
    --warn:      #f59e0b;
    --danger:    #ef4444;
    --success:   #10a37f;
    --radius:    10px;
    --radius-sm: 6px;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
    --mono: 'JetBrains Mono', 'SF Mono', ui-monospace, 'Cascadia Mono', 'Roboto Mono', Consolas, Menlo, monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    overflow-x: hidden;
}

/* ====== background ====== */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at top, black 0%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at top, black 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}
.bg-glow {
    position: fixed;
    top: -20vh;
    left: 50%;
    width: 120vw;
    height: 70vh;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(16,163,127,.10) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    filter: blur(40px);
}

/* ====== header ====== */
.site-header {
    border-bottom: 1px solid var(--border-soft);
    background: rgba(10,11,13,.7);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    position: sticky; top: 0;
    z-index: 10;
}
.site-header .wrap,
.site-footer .wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}
.brand-mark {
    font-family: var(--mono);
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
    display: inline-block;
    animation: caret 1.2s steps(2) infinite;
}
@keyframes caret { 50% { opacity: .3; } }
.brand-name {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -.01em;
}
.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-elev); }
nav { display: flex; gap: 4px; }

/* ====== main ====== */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 60px 24px 80px;
}

/* hero */
.hero {
    text-align: center;
    margin-bottom: 48px;
}
.badge {
    display: inline-block;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .16em;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent);
    background: rgba(16,163,127,.06);
    margin-bottom: 24px;
}
.hero h1 {
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.15;
    letter-spacing: -.02em;
    margin: 0 0 16px;
    font-weight: 700;
}
.accent { color: var(--accent); }
.lead {
    color: var(--text-dim);
    font-size: 17px;
    margin: 0;
}

/* ====== stepper ====== */
.stepper {
    list-style: none;
    padding: 0;
    margin: 0 0 32px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
}
.stepper li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-mute);
    border-right: 1px solid var(--border-soft);
    position: relative;
    transition: color .2s, background .2s;
}
.stepper li:last-child { border-right: none; }
.stepper li span {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 11px;
    opacity: .6;
}
.stepper li em {
    font-style: normal;
    font-weight: 500;
}
.stepper li.active {
    color: var(--accent);
    background: rgba(16,163,127,.06);
}
.stepper li.active span { opacity: 1; }
.stepper li.done {
    color: var(--text-dim);
}
.stepper li.done::after {
    content: '✓';
    position: absolute;
    right: 14px;
    color: var(--accent);
    font-weight: 700;
}

/* ====== card ====== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 32px;
    animation: cardIn .4s cubic-bezier(.2,.8,.2,1);
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.card-head {
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--border-soft);
}
.card-head h2 {
    margin: 0 0 6px;
    font-size: 18px;
    letter-spacing: -.01em;
}
.card-head p {
    margin: 0;
    color: var(--text-dim);
    font-size: 14px;
}
.card-body {
    padding: 24px 28px 28px;
}
.hidden { display: none !important; }

/* ====== form ====== */
.field {
    display: block;
    margin-bottom: 20px;
}
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 8px;
    letter-spacing: .01em;
}
.field-hint {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-mute);
}
.input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    color: var(--text);
    font-size: 15px;
    font-family: var(--sans);
    transition: border-color .15s, box-shadow .15s, background .15s;
    outline: none;
}
.input.mono { font-family: var(--mono); font-size: 14px; letter-spacing: .02em; }
.input::placeholder { color: var(--text-mute); }
.input:hover { border-color: #333740; }
.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16,163,127,.15);
    background: #0e1012;
}
textarea.input { resize: vertical; min-height: 120px; line-height: 1.6; }

/* ====== buttons ====== */
.btn-primary, .btn-ghost, .btn-accent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    user-select: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,163,127,.2);
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hi);
    box-shadow: 0 4px 12px rgba(16,163,127,.3);
    transform: translateY(-1px);
}
.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border-color: var(--border);
}
.btn-ghost:hover {
    color: var(--text);
    border-color: #333740;
    background: var(--bg-elev);
}
.btn-accent { background: var(--accent); color: #fff; padding: 14px 28px; font-size: 15px; }

.actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}
.actions.center { justify-content: center; }

/* ====== notice ====== */
.notice {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    margin: 16px 0;
}
.notice strong {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}
.notice.warn {
    background: rgba(245,158,11,.08);
    border: 1px solid rgba(245,158,11,.25);
    color: #fbbf24;
}
.notice.warn strong { color: var(--warn); }
.notice.danger {
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.25);
    color: #fca5a5;
}
.notice.danger strong { color: var(--danger); }
.notice ul {
    margin: 8px 0 0;
    padding-left: 20px;
    color: var(--text-dim);
}
.notice ul li { margin: 4px 0; }
.notice ul b { color: var(--text); }

/* ====== CDK chip ====== */
.cdk-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.chip-label { color: var(--text-mute); font-size: 13px; }
.cdk-chip code {
    flex: 1;
    font-size: 14px;
    color: var(--text);
    min-width: 140px;
}
.chip-plan {
    padding: 4px 10px;
    background: rgba(16,163,127,.12);
    color: var(--accent);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-family: var(--mono);
}
.chip-plan.plan-pro {
    background: rgba(168,85,247,.12);
    color: #c084fc;
}
.chip-plan.plan-plus-1y {
    background: rgba(245,158,11,.12);
    color: #fbbf24;
}

/* ====== guide ====== */
.guide {
    margin: 0 0 24px;
    padding: 0;
    list-style: none;
    counter-reset: step;
}
.guide li {
    position: relative;
    padding: 12px 12px 12px 44px;
    margin-bottom: 8px;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.7;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    counter-increment: step;
}
.guide li::before {
    content: counter(step);
    position: absolute;
    left: 14px;
    top: 13px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 50%;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
}
.guide li b { color: var(--text); }

.link-outline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 3px 10px;
    border: 1px solid var(--accent-dim);
    color: var(--accent);
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
    transition: all .15s;
}
.link-outline:hover {
    background: rgba(16,163,127,.1);
    border-color: var(--accent);
}

kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
}

/* ====== confirm list ====== */
.confirm-list {
    margin: 0 0 20px;
    padding: 0;
}
.confirm-list div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
    gap: 16px;
}
.confirm-list div:last-child { border-bottom: none; }
.confirm-list dt {
    color: var(--text-dim);
    font-size: 14px;
    margin: 0;
}
.confirm-list dd {
    margin: 0;
    font-size: 15px;
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

/* ====== result states ====== */
.result-body {
    padding: 48px 28px;
    text-align: center;
}
.result-body h2 {
    margin: 16px 0 8px;
    font-size: 22px;
    letter-spacing: -.01em;
}
.result-body p.muted {
    color: var(--text-dim);
    margin: 0 0 24px;
    font-size: 14px;
}
.result-body .confirm-list {
    text-align: left;
    max-width: 440px;
    margin: 20px auto;
}
.result-body .notice { text-align: left; max-width: 440px; margin-left: auto; margin-right: auto; }
.result-body .actions { flex-wrap: wrap; }

.spinner-big {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    margin: 0 auto;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: popIn .4s cubic-bezier(.34,1.6,.64,1);
}
@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}
.status-icon.success {
    background: rgba(16,163,127,.14);
    color: var(--accent);
    box-shadow: 0 0 40px rgba(16,163,127,.25);
}
.status-icon.failed {
    background: rgba(239,68,68,.14);
    color: var(--danger);
    box-shadow: 0 0 40px rgba(239,68,68,.25);
}

.progress-log {
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 12px;
    color: var(--text-dim);
    max-width: 440px;
    margin: 24px auto 0;
    text-align: left;
    max-height: 160px;
    overflow-y: auto;
}
.progress-log div { margin: 2px 0; }
.progress-log div span { color: var(--accent); }

/* ====== faq ====== */
.faq {
    margin-top: 48px;
    padding: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}
.faq h3 {
    margin: 0 0 20px;
    font-size: 16px;
    color: var(--text-dim);
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.faq details {
    border-top: 1px solid var(--border-soft);
    padding: 14px 0;
}
.faq details:first-of-type { border-top: none; padding-top: 0; }
.faq summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    transition: color .15s;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
    content: '+';
    font-family: var(--mono);
    color: var(--accent);
    font-size: 18px;
    transition: transform .2s;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq summary:hover { color: var(--accent); }
.faq details p {
    margin: 8px 0 0;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.7;
}
.faq code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid var(--border-soft);
    font-size: 13px;
    color: var(--text);
}

/* ====== toast ====== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    color: var(--text);
    font-size: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,.5);
    z-index: 100;
    opacity: 0;
    transition: transform .3s, opacity .3s;
    max-width: 90vw;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast.error { border-color: rgba(239,68,68,.4); }
.toast.error::before { content: '✕'; color: var(--danger); margin-right: 8px; font-weight: 700; }
.toast.success { border-color: rgba(16,163,127,.4); }
.toast.success::before { content: '✓'; color: var(--accent); margin-right: 8px; font-weight: 700; }

/* ====== footer ====== */
.site-footer {
    border-top: 1px solid var(--border-soft);
    margin-top: 40px;
    color: var(--text-mute);
    font-size: 13px;
}
.site-footer .wrap {
    padding: 24px;
}
.mono { font-family: var(--mono); }
.muted { color: var(--text-mute); }
.small { font-size: 12px; }

/* ====== button spinner ====== */
.btn-primary .spinner,
.btn-accent .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* ====== responsive ====== */
@media (max-width: 640px) {
    .container { padding: 36px 16px 60px; }
    .card-head, .card-body { padding-left: 20px; padding-right: 20px; }
    .hero h1 { font-size: 28px; }
    .stepper { grid-template-columns: repeat(4, 1fr); }
    .stepper li { padding: 10px 6px; font-size: 11px; flex-direction: column; gap: 2px; text-align: center; }
    .stepper li.done::after { top: 4px; right: 4px; font-size: 10px; }
    .actions { flex-direction: column-reverse; }
    .actions button, .actions a { width: 100%; }
    .confirm-list div { flex-direction: column; align-items: flex-start; gap: 4px; }
    .confirm-list dd { text-align: left; }
    .site-header .wrap { padding: 12px 16px; }
    .site-footer .wrap { flex-direction: column; gap: 8px; text-align: center; }
}

/* ====== query page ====== */
.query-results {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.query-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.query-row .q-code { font-family: var(--mono); color: var(--text); }
.query-row .q-meta { color: var(--text-dim); font-size: 12px; }
.q-badge {
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.q-badge.unused     { background: rgba(148,163,184,.15); color: #94a3b8; }
.q-badge.processing { background: rgba(59,130,246,.15); color: #60a5fa; }
.q-badge.used       { background: rgba(16,163,127,.15); color: var(--accent); }
.q-badge.failed     { background: rgba(239,68,68,.15); color: var(--danger); }
.q-badge.not_found  { background: rgba(107,112,117,.15); color: var(--text-mute); }
