/* Truthy — clean light design system (devbay family, emerald accent) */

:root {
    --bg: #f8fafc;
    --bg-soft: #f1f5f9;
    --text: #0f172a;
    --text-dim: #64748b;
    --text-faint: #94a3b8;
    --card: #ffffff;
    --card-strong: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --accent-1: #059669;
    --accent-2: #047857;
    --accent-3: #10b981;
    --accent-soft: rgba(5, 150, 105, 0.09);
    --good: #10b981;
    --danger: #dc2626;
    --danger-soft: rgba(220, 38, 38, 0.08);
    --radius: 0.625rem;
    --shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 4px 12px 0 rgba(15, 23, 42, 0.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
            "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
            "Courier New", monospace;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-soft: #1e293b;
    --text: #f1f5f9;
    --text-dim: #94a3b8;
    --text-faint: #64748b;
    --card: #1e293b;
    --card-strong: #0f172a;
    --border: #334155;
    --border-strong: #475569;
    --accent-1: #34d399;
    --accent-2: #6ee7b7;
    --accent-3: #10b981;
    --accent-soft: rgba(52, 211, 153, 0.14);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
}
.container { width: min(1100px, 92vw); margin: 0 auto; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-accent { color: var(--accent-1); }
.nav-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 0.5rem;
    background: var(--card); border: 1px solid var(--border);
    color: var(--text-dim); cursor: pointer;
    transition: all 0.15s ease; font-family: inherit;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.lang-select {
    padding: 8px 30px 8px 12px;
    background-color: var(--card);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.lang-select:hover { color: var(--text); }
.lang-select:focus { outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- layout ---------- */
main { min-height: calc(100vh - 220px); }
.tool-wrap { max-width: 860px; margin: 0 auto; padding: 40px 0 64px; }

.hero h1 {
    font-size: clamp(1.7rem, 4vw, 2.3rem);
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.15;
}
.hero-sub {
    margin-top: 10px;
    max-width: 60ch;
    color: var(--text-dim);
    font-size: 1.02rem;
}

/* ---------- panels / buttons / inputs ---------- */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.tool-panel { margin-top: 28px; }

.btn {
    padding: 10px 20px;
    background: var(--accent-1);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent-3); outline-offset: 2px; }
.btn-small { padding: 8px 14px; font-size: 0.85rem; }
.btn-ghost {
    padding: 8px 14px;
    background: var(--card);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-strong); }
.btn-ghost:focus-visible { outline: 2px solid var(--accent-3); outline-offset: 2px; }

.input {
    width: 100%;
    padding: 10px 12px;
    background: var(--card-strong);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus { outline: none; border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--accent-soft); }

.field-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.expr-row { display: flex; gap: 10px; }
.expr-input {
    flex: 1;
    min-width: 0;
    font-family: var(--mono);
    font-size: 1rem;
    letter-spacing: 0.01em;
    color: var(--text);
}
.gen-btn { white-space: nowrap; padding: 10px 24px; }

/* ---------- chips / hints ---------- */
.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.chip {
    padding: 5px 13px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.chip:hover { color: var(--accent-1); border-color: var(--accent-1); background: var(--accent-soft); }

.hint {
    margin-top: 14px;
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 2;
}
.var-note { margin-top: 4px; line-height: 1.6; }
.op-list { white-space: normal; }
.op-grp { display: inline-block; margin-right: 14px; }
.kbd {
    display: inline-block;
    padding: 1px 8px;
    margin-right: 4px;
    background: var(--card-strong);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--text);
}

/* ---------- errors ---------- */
.err-box {
    margin-top: 16px;
    padding: 11px 14px;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid transparent;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ---------- result ---------- */
.result-block { margin-top: 22px; }
.result-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.result-status {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 0.88rem;
    color: var(--text-dim);
}
.status-label { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.status-good { color: var(--good); }
.status-good .status-dot { background: var(--good); }
.status-danger { color: var(--danger); }
.status-danger .status-dot { background: var(--danger); }
.status-accent { color: var(--accent-1); }
.status-accent .status-dot { background: var(--accent-1); }
.rows-meta { font-size: 0.85rem; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}
table.truth-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    min-width: 420px;
}
.truth-table thead th {
    background: var(--card-strong);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dim);
    padding: 11px 18px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.truth-table thead th.result-head { font-family: var(--mono); color: var(--text); font-weight: 600; }
.truth-table tbody td {
    padding: 8px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}
.truth-table tbody tr:last-child td { border-bottom: none; }
.truth-table tbody tr { transition: background 0.12s ease; }
.truth-table tbody tr:hover { background: var(--card-strong); }
.truth-table tbody th {
    font-weight: 700;
    color: var(--text);
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    text-align: center;
    background: transparent;
}
.v-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 800;
}
.v-true { background: var(--accent-soft); color: var(--accent-1); }
.v-false { background: var(--bg-soft); color: var(--text-faint); }

/* ---------- footer ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--bg);
    padding: 26px 0 32px;
}
.footer-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}
.footer-name { color: var(--text); }
.footer-tag { margin-top: 4px; font-size: 0.85rem; color: var(--text-dim); }
.footer-right { text-align: right; }
.footer-meta { font-size: 0.82rem; color: var(--text-faint); }
.footer-copy { margin-top: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 600px) {
    .expr-row { flex-direction: column; }
    .gen-btn { width: 100%; }
    .footer-right { text-align: left; }
    .tool-wrap { padding: 28px 0 48px; }
    .tool-panel { padding: 18px; }
}

/* ---------- print ---------- */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; color: #000; }
    .tool-wrap { padding: 0; max-width: none; }
    .result-block { margin-top: 0; }
    .table-wrap { border: 1px solid #999; border-radius: 0; box-shadow: none; }
    .truth-table thead th { background: #f1f5f9; color: #000; }
    .v-true { background: transparent; color: #000; border: 1px solid #059669; }
    .v-false { background: transparent; color: #000; border: 1px solid #cbd5e1; }
}
