/* Magnetic Hyperthermia Simulator — responsive stylesheet (no build step) */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #1b2430;
    --muted: #5b6676;
    --border: #dde3ea;
    --primary: #1e5aa8;
    --primary-hover: #17498a;
    --accent: #c2410c;
    --ok: #15803d;
    --ok-bg: #ecfdf3;
    --warn: #9a3412;
    --warn-bg: #fff7ed;
    --err: #b91c1c;
    --err-bg: #fef2f2;
    --info-bg: #eef4fc;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141b;
        --surface: #171e27;
        --surface-2: #1c2530;
        --text: #e6ebf1;
        --muted: #9aa6b5;
        --border: #2b3643;
        --primary: #4b8fe0;
        --primary-hover: #6aa3e8;
        --accent: #f97316;
        --ok: #4ade80;
        --ok-bg: #0f2a1b;
        --warn: #fdba74;
        --warn-bg: #2b1d10;
        --err: #f87171;
        --err-bg: #2c1414;
        --info-bg: #152234;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.app-header {
    background: linear-gradient(120deg, #13294b, #1e5aa8);
    color: #fff;
    padding: 22px 0 18px;
    margin-bottom: 20px;
}
.app-header h1 { margin: 0; font-size: 1.6rem; letter-spacing: .02em; text-transform: uppercase; }
.subtitle { margin: 4px 0 0; opacity: .85; font-size: .92rem; }

.app-footer { color: var(--muted); font-size: .82rem; padding: 24px 0 32px; text-align: center; }

h2 { font-size: 1.18rem; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 1.02rem; margin: 18px 0 10px; }
.card h3:first-child { margin-top: 0; }

.step {
    display: inline-grid; place-items: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: .85rem;
}
.optional { color: var(--muted); font-weight: 400; font-size: .9rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}

.notice { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 18px; font-size: .9rem; }
.notice-info { background: var(--info-bg); border: 1px solid var(--border); }
.notice-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(194, 65, 12, .25); }

.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }
code, .mono { font-family: var(--mono); font-size: .86em; }

/* ---------- forms ---------- */
.upload-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.inline-field.grow { flex: 1 1 260px; }

input[type="number"], input[type="text"], select {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 0;
    width: 100%;
}
input:focus, select:focus, button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}
input.invalid { border-color: var(--err); background: var(--err-bg); }

.file-drop {
    flex: 1 1 300px;
    display: flex; align-items: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    cursor: pointer;
    background: var(--surface-2);
    min-height: 46px;
    position: relative;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-drop-text { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }

.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px 18px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-weight: 600; font-size: .9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.symbol { font-weight: 400; color: var(--muted); font-style: italic; }
.field-help { color: var(--muted); font-size: .78rem; }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.unit {
    display: grid; place-items: center;
    padding: 0 10px;
    min-width: 64px;
    border: 1px solid var(--border); border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--surface-2);
    color: var(--muted);
    font-size: .85rem;
    white-space: nowrap;
}

.badge { display: inline-block; font-size: .64rem; font-weight: 700; letter-spacing: .04em; padding: 2px 6px; border-radius: 4px; }
.badge-assumption { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(194, 65, 12, .3); }

details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
details > summary::-webkit-details-marker { display: none; }
details > summary h2 { margin: 0; }
.summary-hint { color: var(--primary); font-size: .9rem; }
details[open] .summary-hint::after { content: " ▲"; }
details:not([open]) .summary-hint::after { content: " ▼"; }
details[open] > summary { margin-bottom: 14px; }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 14px; }
.mode-option {
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px; cursor: pointer; font-size: .88rem; background: var(--surface-2);
}
.mode-option:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.mode-option input { margin-top: 4px; }

.run-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }

/* ---------- buttons ---------- */
.btn {
    font: inherit; font-weight: 600;
    border-radius: 8px; padding: 9px 16px;
    border: 1px solid transparent; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover:not(:disabled) { background: var(--info-bg); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-large { padding: 13px 40px; font-size: 1.05rem; letter-spacing: .04em; }
.btn-icon { padding: 4px 10px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }

.spinner {
    width: 22px; height: 22px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--primary);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- messages / status ---------- */
.messages:empty { display: none; }
.messages { margin-top: 12px; }
.msg { border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; font-size: .88rem; }
.msg ul { margin: 6px 0 0; padding-left: 20px; }
.msg-error { background: var(--err-bg); color: var(--err); border: 1px solid rgba(185, 28, 28, .25); }
.msg-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(194, 65, 12, .25); }
.msg-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(21, 128, 61, .25); }

.file-status:empty { display: none; }
.file-status { margin-top: 14px; }
.status-line { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.status-valid { color: var(--ok); }
.status-invalid { color: var(--err); }
.status-partial { color: var(--warn); }

/* ---------- results ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.kpi-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: .82rem; color: var(--muted); font-weight: 400; margin-left: 3px; }
.kpi-note { font-size: .72rem; color: var(--muted); }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th, .data-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table thead th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); white-space: nowrap; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .src-assumption { color: var(--warn); font-weight: 600; }
.scenario-table input { min-width: 80px; }

.chart-card h3 { margin-top: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h3 { margin: 0; }
.chart-box { position: relative; width: 100%; height: 340px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }

.assumption-list { columns: 2 280px; margin: 0; padding-left: 20px; font-size: .9rem; }
.assumption-list li { break-inside: avoid; margin-bottom: 4px; }
.disclaimer { font-size: .9rem; background: var(--warn-bg); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
    .app-header h1 { font-size: 1.2rem; }
    .card { padding: 14px; }
    .chart-box { height: 260px; }
    .btn-large { width: 100%; }
    .upload-row > * { flex: 1 1 100%; }
}
