* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --accent: #ea580c;
    --accent-soft: #fff7ed;
    --ink: #1f2937;
    --muted: #6b7280;
    --faint: #9ca3af;
    --line: #e5e7eb;
    --mono: 'Consolas', 'Monaco', 'Meiryo', monospace;
    --sidebar-w: 340px;
}

body {
    font-family: 'Segoe UI', 'Meiryo', sans-serif;
    font-size: 14px;
    color: var(--ink);
    overflow: hidden;
}

#app { display: flex; height: 100vh; }

/* ================= サイドバー ================= */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--line);
    overflow-y: auto;
    padding-bottom: 24px;
}

.sidebar-top { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }

.back-link {
    display: inline-block;
    font-size: 12px;
    color: var(--muted);
    text-decoration: none;
    margin-bottom: 8px;
}
.back-link:hover { color: var(--accent); }

.sidebar h1 { font-size: 17px; color: var(--accent); margin-bottom: 3px; }
.lead { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.block h2 { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stepno {
    flex-shrink: 0; width: 19px; height: 19px; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

.field { display: block; margin-bottom: 10px; }
.field-label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.field-label em { font-style: normal; color: var(--faint); }

input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: var(--mono);
}
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(234,88,12,.12);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 9px 14px; border: none; border-radius: 6px;
    font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color .15s;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #c2410c; }
.btn-secondary { background: #64748b; color: #fff; margin-top: 10px; }
.btn-secondary:hover { background: #475569; }

.hint { margin-top: 7px; font-size: 11px; color: var(--faint); line-height: 1.55; }
.empty { font-size: 12px; color: var(--faint); font-style: italic; padding: 6px 0; }

/* ================= ミッション ================= */
.mission {
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 7px;
    padding: 10px 11px;
    margin-bottom: 9px;
    background: #fff;
}

.mission-head {
    display: flex; align-items: flex-start; gap: 6px; margin-bottom: 7px;
}
.mission-name {
    flex: 1; min-width: 0;
    font-size: 12.5px; font-weight: 600;
    word-break: break-all; line-height: 1.4;
}
.icon-btn {
    flex-shrink: 0;
    width: 22px; height: 22px;
    border: 1px solid #d1d5db; border-radius: 4px;
    background: #fff; color: var(--muted);
    font-size: 12px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.mission-meta { font-size: 11px; color: var(--muted); line-height: 1.6; margin-bottom: 8px; }
.mission-meta .mode { color: var(--faint); }

.mission-speed { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.mission-speed span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.mission-speed input { flex: 1; padding: 6px 8px; font-size: 13px; }

.mission-result {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
    padding-top: 8px; border-top: 1px dashed var(--line);
}
.mr-label { font-size: 10.5px; color: var(--faint); }
.mr-value { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.mr-sub { font-size: 10px; color: var(--faint); grid-column: 1 / -1; line-height: 1.5; }

.vis-toggle { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); cursor: pointer; margin-top: 9px; }

/* ---- 計測タイプの選択 ---- */
.seg {
    display: flex; margin-top: 9px;
    border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; background: #f3f4f6;
}
.seg label { flex: 1; position: relative; cursor: pointer; }
.seg label + label { border-left: 1px solid #d1d5db; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
    display: block; padding: 6px 4px; font-size: 11.5px;
    text-align: center; color: var(--muted); white-space: nowrap; transition: .15s;
}
.seg label:hover span { background: #e9eaec; }
.seg input:checked + span { background: var(--accent); color: #fff; font-weight: 600; }
.seg-mini span { padding: 4px 7px; font-size: 10.5px; }
.seg-mini { margin-top: 0; }

/* ---- タイプ別の設定ブロック ---- */
.sub-block {
    margin-top: 9px; padding: 9px 10px;
    background: #f9fafb; border: 1px solid var(--line); border-radius: 6px;
}
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.sub-head > span, .sub-head-plain { font-size: 11px; color: var(--muted); font-weight: 600; }
.sub-head-plain { margin-bottom: 6px; }

.sub-block select {
    width: 100%; padding: 6px 8px; font-size: 12px;
    border: 1px solid #d1d5db; border-radius: 5px; background: #fff; margin-bottom: 7px;
}

.inline-num { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.in-label { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 44px; }
.inline-num input { flex: 1; min-width: 0; padding: 5px 7px; font-size: 12.5px; }
.in-unit { font-size: 10.5px; color: var(--faint); white-space: nowrap; }

.btn-sub { background: #fff; border: 1px solid var(--accent); color: var(--accent); padding: 6px 10px; font-size: 12px; margin-top: 4px; }
.btn-sub:hover:not(:disabled) { background: var(--accent-soft); }
.btn-sub:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: #fff; border: 1px solid #d1d5db; color: var(--muted); margin-top: 10px; }
.btn-ghost:hover { border-color: #dc2626; color: #dc2626; }

.sub-divider { margin: 10px 0 8px; border-top: 1px dashed #d1d5db; }
.agl-info { margin-top: 7px; font-family: var(--mono); font-size: 12px; color: #9a3412; }
.agl-note, .spec-note { margin-top: 4px; font-size: 10px; color: var(--faint); line-height: 1.5; }
.spec-line { margin-top: 7px; font-family: var(--mono); font-size: 11.5px; color: #374151; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip {
    padding: 3px 8px; border: 1px solid #d1d5db; border-radius: 999px;
    background: #fff; color: #4b5563; font-size: 10.5px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.mission.type-photo { background: linear-gradient(90deg, #fff7ed 0%, #fff 60%); }
.mission.type-laser { background: linear-gradient(90deg, #eff6ff 0%, #fff 60%); }

/* ---- 詳細設定 ---- */
.adv { margin: 12px 16px 0; border: 1px solid var(--line); border-radius: 7px; background: #fafafa; }
.adv summary { padding: 8px 12px; font-size: 12px; color: var(--muted); cursor: pointer; }
.adv summary:hover { color: var(--accent); }
.adv-body { padding: 4px 12px 12px; border-top: 1px solid var(--line); }
.adv-body select { width: 100%; padding: 7px 9px; font-size: 12.5px; border: 1px solid #d1d5db; border-radius: 5px; background: #fff; }

/* ================= 範囲 ================= */
.area-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; padding: 5px 0;
    border-bottom: 1px dashed var(--line);
}
.area-item:last-child { border-bottom: none; }
.area-name { flex: 1; min-width: 0; word-break: break-all; }

/* ================= 地図 ================= */
.main { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

.sidebar-toggle {
    position: absolute; top: 10px; left: 10px; z-index: 1000;
    width: 34px; height: 34px;
    border: 1px solid var(--line); border-radius: 6px;
    background: #fff; cursor: pointer; font-size: 15px;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    display: none;
}

/* ================= 地図上のパネル ================= */
.map-panel {
    position: absolute; z-index: 1000;
    background: #fff; border: 1px solid var(--line); border-radius: 9px;
    padding: 11px 13px;
    box-shadow: 0 3px 14px rgba(0,0,0,.16);
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-size: 11px; color: var(--faint); letter-spacing: .05em; margin-bottom: 8px;
}
.sw { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); cursor: pointer; letter-spacing: 0; }

/* 凡例 */
.legend { right: 10px; top: 10px; width: 210px; }
.legend-row { display: flex; align-items: center; gap: 7px; padding: 3px 0; }
.legend-swatch { width: 15px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.legend-label { flex: 1; font-size: 11.5px; color: var(--ink); }
.legend-area { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.legend-total { margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink); }
.legend-note { margin-top: 4px; font-size: 10px; color: var(--faint); line-height: 1.5; }
.opacity-row { display: flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.opacity-row input { flex: 1; min-width: 0; }

/* 合計 */
.summary { right: 10px; bottom: 10px; width: 250px; }
.sum-row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; }
.sum-row + .sum-row { border-top: 1px dashed var(--line); }
.sum-label { font-size: 11.5px; color: var(--muted); }
.sum-value { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.sum-value.big { font-size: 20px; color: var(--accent); }
.sum-note { font-size: 10px; color: var(--faint); line-height: 1.5; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); }

/* ================= ドロップ ================= */
.drop-overlay {
    position: fixed; inset: 0; z-index: 3000;
    background: rgba(234,88,12,.13);
    border: 3px dashed var(--accent);
    display: none; align-items: center; justify-content: center;
    pointer-events: none;
}
.drop-overlay.on { display: flex; }
.drop-overlay div {
    background: #fff; padding: 18px 28px; border-radius: 10px;
    font-size: 16px; font-weight: 600; color: var(--accent);
}

/* ================= トースト ================= */
.toast-container {
    position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
    z-index: 4000; display: flex; flex-direction: column; gap: 7px; align-items: center;
}
.toast {
    padding: 9px 16px; border-radius: 6px; font-size: 13px; color: #fff;
    background: #334155; box-shadow: 0 2px 10px rgba(0,0,0,.24);
    transition: opacity .3s;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.warn { background: #d97706; }

/* ================= レスポンシブ ================= */
@media (max-width: 860px) {
    .sidebar {
        position: absolute; top: 0; bottom: 0; left: 0; z-index: 1200;
        transform: translateX(-100%); transition: transform .25s;
        box-shadow: 3px 0 16px rgba(0,0,0,.2);
    }
    #app.nav-open .sidebar { transform: translateX(0); }
    .sidebar-toggle { display: block; }
    .summary { width: 210px; right: 8px; bottom: 8px; padding: 10px; }
    .sum-value.big { font-size: 17px; }
}
