:root {
    --gold: #b8860b;
    --gold-light: #f7ecd2;
    --silver: #71797e;
    --silver-light: #eef1f2;
    --ink: #2b2420;
    --muted: #6b645c;
    --border: #e2dac8;
    --danger: #9b2c2c;
    --danger-bg: #fdecec;
    --warning: #8a6d1d;
    --warning-bg: #fff6e0;
    --info: #1f5f5b;
    --info-bg: #e6f4f2;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #fbf8f1;
    color: var(--ink);
    line-height: 1.55;
}

.container {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-header {
    background: linear-gradient(135deg, #3a2f1c, #1f1a10);
    color: #fdf6e3;
    padding: 14px 0;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.brand {
    color: #f3d98b;
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
}
.site-header nav a {
    color: #fdf6e3;
    text-decoration: none;
    margin-left: 18px;
    font-size: 0.95rem;
    opacity: 0.85;
}
.site-header nav a:hover { opacity: 1; text-decoration: underline; }

main { padding: 28px 0 50px; }

h1 { font-size: 1.5rem; margin-bottom: 4px; }
.subtitle { color: var(--muted); margin-top: 0; margin-bottom: 24px; }

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px 16px;
    margin: 0 0 18px;
}
legend {
    font-weight: 600;
    padding: 0 6px;
    color: var(--ink);
}

.radio-row {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
}
.radio-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    cursor: pointer;
}
.radio-row .hint {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 4px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 5px;
}
.field select,
.field input[type="number"],
.field input[type="text"] {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fffdf8;
}
.field select:focus,
.field input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.field-note {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 4px;
}

.custom-inline {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}
.custom-inline .field { flex: 1; margin-bottom: 0; }

.hidden { display: none !important; }

button.btn-primary {
    background: var(--gold);
    color: #fff;
    border: none;
    padding: 12px 22px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
}
button.btn-primary:hover { background: #9c700a; }

.result-box {
    background: var(--gold-light);
    border: 1px solid #e6d29b;
    border-radius: var(--radius);
    padding: 20px;
}
.result-box.error { background: var(--danger-bg); border-color: #f3c2c2; }
.result-error { color: var(--danger); font-weight: 600; margin: 0; }

.tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    margin-bottom: 10px;
}
.tag-lower { background: #b03a2e; }
.tag-raise { background: #1e7a4c; }

.steps {
    padding-left: 20px;
    margin: 10px 0;
}
.steps li { margin-bottom: 8px; }

.conclusion {
    background: #fff;
    border-left: 4px solid var(--gold);
    padding: 10px 14px;
    margin: 14px 0;
    border-radius: 6px;
}

.chi-breakdown {
    background: #fffdf5;
    border: 1px dashed #d8c489;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
}
.chi-breakdown p { margin: 4px 0; }

.alert {
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 10px;
    font-size: 0.92rem;
}
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #f0dca0; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c2c2; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #b9ddd8; }

table.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
table.ref-table th, table.ref-table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
}
table.ref-table th { background: #f4ecd8; }
table.ref-table caption {
    text-align: left;
    font-weight: 600;
    margin-bottom: 6px;
}

.site-footer {
    background: #f1ead7;
    border-top: 1px solid var(--border);
    padding: 18px 0 26px;
    font-size: 0.85rem;
    color: var(--muted);
}
.muted { color: var(--muted); }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { border: 1px solid var(--border); padding: 8px 10px; font-size: 0.9rem; }
.admin-table th { background: #f4ecd8; text-align: left; }
.btn-small {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--ink);
    background: #fff;
}
.btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.flash {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.flash-success { background: #e6f4ec; color: #1e7a4c; border: 1px solid #b9e0c8; }
.flash-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3c2c2; }
