/* Chart のスタイル。色は道具共通の約束（強調 #2962FF、青に寄せたニュートラル。color・hub と同じ値）。
   試作のあいだはライトだけ。 */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1a1c20;
    --muted: #646a75;
    --border: #dadde3;
    --border-strong: #c5cad3;
    --accent: #2962ff;
    --accent-hover: #1e4fd8;
    --accent-soft: #e5ecff;
    --accent-text: #1e4fd8;
    --warn: #8a5a00;
    --toast-bg: #1a1c20;
    --toast-text: #ffffff;
    --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
    --radius-lg: 14px;
    --radius-md: 8px;
    --radius-sm: 6px;
    --ease: 0.15s ease;
    color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    font: 14px/1.6 var(--font-sans);
    background: var(--bg);
    color: var(--text);
}

.app { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }

.app-header { margin-bottom: 20px; }
.app-header h1 { font-size: 20px; line-height: 1.4; }
.app-header h1 small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.subtitle { color: var(--muted); }
.ut-home { color: inherit; font-size: 12px; font-weight: 400; text-decoration: none; white-space: nowrap; }
.ut-home span { opacity: 0.6; }
.ut-home span::after { content: " /"; }
.ut-home:hover span { opacity: 1; text-decoration: underline; }
.uc-mark { width: 20px; height: 20px; margin-right: 6px; vertical-align: -5px; }

.layout { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.side, .side-group { display: grid; gap: 16px; min-width: 0; }

/* --- 切り替え --- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); }
.seg button { height: 32px; font: 600 14px/1 var(--font-sans); color: var(--muted); background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    min-width: 0;
}
.card h2 { font-size: 14px; margin-bottom: 8px; }
.help { font-size: 12px; color: var(--muted); }
.status { font-size: 12px; color: var(--warn); min-height: 0; }
.status:not(:empty) { margin-top: 8px; }

/* --- 入力 --- */
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
input[type="text"], input[type="number"], select {
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 0 8px;
    font: 14px/1 var(--font-sans);
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card > .grid + *, .card > div + div, .card > .check + *, .card > .inline { margin-top: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin-top: 12px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.inline span { display: flex; align-items: center; gap: 8px; }
.inline input { width: 72px; }
.color-field { display: flex; gap: 6px; }
.color-field input[type="text"] { font-family: var(--font-mono); font-size: 13px; }
input[type="color"] {
    flex: none;
    width: 34px; height: 34px;
    padding: 2px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { height: 26px; padding: 0 10px; font: 12px/1 var(--font-sans); font-variant-numeric: tabular-nums; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9999px; cursor: pointer; }
.chips button:hover { background: var(--surface-2); }
.chips button[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent); }

/* --- データの表 --- */
.rows { width: 100%; border-collapse: collapse; margin-top: 12px; }
.rows th { font-size: 12px; font-weight: 400; color: var(--muted); text-align: left; padding: 0 4px 4px; }
.rows td { padding: 2px; vertical-align: middle; }
.rows .c-sw { width: 36px; }
.rows .c-val { width: 104px; }
.rows .c-del { width: 30px; }
.rows td.c-sw { position: relative; }
.rows input[type="color"] { width: 30px; height: 30px; display: block; }
.rows input[type="text"] { height: 30px; }
.rows .vl { text-align: right; font-variant-numeric: tabular-nums; }
.rows tr.off input[type="text"] { color: var(--muted); }
.rows tr.off .vl { border-color: var(--warn); }
.rows .auto {
    position: absolute; left: 2px; bottom: -3px;
    width: 30px; height: 12px;
    font: 9px/12px var(--font-sans);
    color: var(--accent-text); background: var(--accent-soft);
    border: 0; border-radius: 3px; cursor: pointer;
}
.rows .del {
    width: 28px; height: 28px;
    font-size: 16px; line-height: 1;
    color: var(--muted); background: none;
    border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.rows .del:hover { background: var(--surface-2); color: var(--text); }
.row-actions { display: flex; gap: 8px; margin-top: 12px; }
#data-panel.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }

/* --- ボタン --- */
.btn {
    height: 36px; padding: 0 16px;
    font: 600 14px/1 var(--font-sans);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--accent-text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* --- プレビュー --- */
.preview-card { position: sticky; top: 16px; }
.preview-head { display: flex; align-items: baseline; justify-content: space-between; }
.size { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.preview {
    display: grid; place-items: center;
    min-height: 360px;
    padding: 24px;
    margin: 4px 0 12px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.preview svg { max-width: 100%; height: auto; }
.preview .empty { color: var(--muted); }
.preview-actions { display: flex; gap: 8px; margin-bottom: 8px; }

/* --- トースト --- */
.toast-container { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 10; }
.toast {
    display: flex; align-items: center; gap: 16px;
    padding: 10px 16px;
    background: var(--toast-bg); color: var(--toast-text);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-size: 13px;
}
.toast button { background: none; border: 0; color: #9db6ff; font: 600 13px var(--font-sans); cursor: pointer; }

@media (max-width: 820px) {
    .layout { grid-template-columns: 1fr; }
    .preview-card { position: static; order: -1; }
    .preview { min-height: 240px; padding: 12px; }
}
