/* ===== CSS Variables ===== */
:root {
    --bg: #faf8f3;
    --bg-card: #ffffff;
    --bg-muted: #f3f0e8;
    --text: #1a1a2e;
    --text-secondary: #5a5a72;
    --accent: #b91c1c;
    --accent-hover: #991818;
    --teal: #0d7377;
    --teal-light: #e8f4f4;
    --border: #e0dcd0;
    --border-light: #eae7de;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --radius: 6px;
    --radius-lg: 10px;
    --font-display: 'DM Serif Display', 'Noto Serif SC', Georgia, serif;
    --font-body: 'Noto Serif SC', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    background-image:
        linear-gradient(rgba(0,0,0,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.02) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* ===== Navigation ===== */
.top-nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 1.25rem;
}
.brand-icon { font-size: 1.4rem; }
.brand-text { letter-spacing: 0.02em; }
.nav-links { display: flex; gap: 0.25rem; }
.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--accent); background: var(--bg-muted); }

/* ===== Main Content ===== */
.main-content { max-width: 1100px; margin: 0 auto; padding: 2rem 2rem 4rem; }

/* ===== Hero (Home) ===== */
.hero { text-align: center; padding: 3rem 0 2rem; }
.hero-title {
    font-family: var(--font-display);
    font-size: 2.8rem;
    color: var(--text);
    letter-spacing: 0.03em;
    margin-bottom: 0.5rem;
}
.hero-subtitle {
    font-size: 1.15rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 1rem;
}
.hero-desc { color: var(--text-secondary); max-width: 560px; margin: 0 auto; font-size: 0.95rem; }

/* ===== Cards ===== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}
.card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.75rem;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.card-icon { font-size: 2.2rem; margin-bottom: 0.75rem; }
.card-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    margin-bottom: 0.2rem;
    color: var(--text);
}
.card-chapter { font-size: 0.85rem; color: var(--accent); font-weight: 500; margin-bottom: 0.75rem; }
.card-desc { font-size: 0.92rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 1rem; }
.card-features { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.feature-tag {
    display: inline-block;
    background: var(--bg-muted);
    color: var(--teal);
    padding: 0.15rem 0.6rem;
    border-radius: 100px;
    font-size: 0.8rem;
    border: 1px solid var(--border-light);
}

/* ===== Page Header ===== */
.page-header { margin-bottom: 2rem; padding-top: 1rem; }
.page-title { font-family: var(--font-display); font-size: 2rem; color: var(--text); margin-bottom: 0.25rem; }
.page-subtitle { color: var(--text-secondary); font-size: 0.95rem; }

/* ===== Panels ===== */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.panel-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}
.panel-hint { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 1rem; }
.sub-title { font-family: var(--font-display); font-size: 1.05rem; margin: 1rem 0 0.5rem; color: var(--text); }
.divider { border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ===== Forms ===== */
.form-row { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.form-label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; color: var(--text-secondary); flex: 1; }
.form-input {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(185,28,28,0.1); }
.form-textarea { resize: vertical; font-family: var(--font-mono); }
.btn-row { display: flex; gap: 0.75rem; margin-top: 0.75rem; }

/* ===== Buttons ===== */
.btn {
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-weight: 500;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: rgba(185,28,28,0.06); }

/* ===== Result Blocks ===== */
.result-block { margin-top: 1rem; }
.result-block.hidden { display: none; }
.kv-pair {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-light);
}
.kv-pair:last-child { border-bottom: none; }
.kv-key { font-size: 0.85rem; color: var(--text-secondary); min-width: 120px; flex-shrink: 0; }
.kv-val { font-size: 0.85rem; color: var(--text); word-break: break-all; }
.kv-val.mono { font-family: var(--font-mono); font-size: 0.8rem; color: var(--teal); }
.kv-val.highlight { color: var(--accent); font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 0.8rem; }
.mono-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
    background: rgba(185,28,28,0.08);
    padding: 0.1rem 0.5rem;
    border-radius: 100px;
}

/* ===== Accordion (Details) ===== */
.accordion { margin-top: 0.75rem; }
.accordion summary {
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
    transition: color 0.2s;
}
.accordion summary:hover { color: var(--accent); }
.accordion-body {
    background: var(--bg-muted);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
}
.accordion-body .kv-pair { border-bottom-color: var(--border); }

/* ===== Steps Table ===== */
.steps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin: 0.75rem 0;
}
.steps-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    background: var(--bg-muted);
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 2px solid var(--border);
    font-size: 0.78rem;
}
.steps-table td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}
.steps-table td.mono { font-family: var(--font-mono); font-size: 0.72rem; color: var(--teal); }

/* ===== Verify ===== */
.verify-ok {
    color: #0d7377;
    font-weight: 600;
    padding: 0.5rem 0;
    font-size: 1rem;
}
.verify-fail {
    color: #b91c1c;
    font-weight: 600;
    padding: 0.5rem 0;
    font-size: 1rem;
}

/* ===== Hash Display ===== */
.hash-display { margin-bottom: 1rem; }
.hash-label { font-size: 0.9rem; color: var(--text-secondary); }
.hash-hex {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--teal);
    background: var(--bg-muted);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    word-break: break-all;
    margin-top: 0.25rem;
    border: 1px solid var(--border-light);
}

/* ===== Hex Row ===== */
.hex-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0.25rem 0 0.5rem;
}
.hex-row code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    background: var(--bg-muted);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    color: var(--teal);
}
.mono-label {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-weight: 500;
}
.word-break { word-break: break-all; }

/* ===== Step Detail ===== */
.step-detail {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}
.step-detail:last-child { border-bottom: none; }
.step-detail p { font-size: 0.85rem; margin-bottom: 0.15rem; }
.step-detail p.mono { font-family: var(--font-mono); font-size: 0.75rem; color: var(--teal); }

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-inner { flex-direction: column; height: auto; padding: 0.75rem 0; gap: 0.5rem; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .hero-title { font-size: 2rem; }
    .form-grid { grid-template-columns: 1fr; }
    .cards-grid { grid-template-columns: 1fr; }
    .panel { padding: 1.25rem; }
    .form-row { flex-direction: column; }
}

@media (max-width: 480px) {
    .main-content { padding: 1rem; }
    .hero { padding: 1.5rem 0; }
    .hero-title { font-size: 1.6rem; }
}
