/* ============================================
   InsightTube Mysight — 내 예측 장부 (Macro 디자인 토큰 공유)
   원칙: 시간선은 흰 캔버스 위의 그림, 도구는 조용하게, 선택된 것만 색이 찬다.
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg: #f3f3f6;            /* 페이지 바탕 (회색) */
    --surface: #ffffff;       /* 카드·캔버스 (흰색) */
    --surface-2: #ebebf0;     /* 눌린 면 */
    --text: #1c1c21;
    --text-2: #4b4b55;
    --muted: #80808a;
    --border: #e3e3e8;
    --hair: rgba(28, 28, 33, 0.07);
    --accent: #2f6fd6;
    --accent-ink: #1f4fa3;
    --accent-soft: rgba(47, 111, 214, 0.10);
    --hit: #0e8f5b;  --hit-soft: rgba(14, 143, 91, 0.12);
    --miss: #c84a4a; --miss-soft: rgba(200, 74, 74, 0.12);
    --pending: #a2a2ac;
    --shadow-sm: 0 1px 2px rgba(20, 20, 40, 0.06), 0 2px 8px rgba(20, 20, 40, 0.04);
    --shadow: 0 14px 40px rgba(20, 20, 40, 0.12);
    --p0: #2f6fd6; --p1: #6b5ce7; --p2: #c2620a; --p3: #0e8f7e; --p4: #c0356b; --p5: #5d7a1f; --p6: #b8860b; --p7: #1f4fa3;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f0f12; --surface: #18181d; --surface-2: #26262d; --text: #ececf0; --text-2: #c2c2ca; --muted: #8e8e98;
        --border: #2a2a32; --hair: rgba(255,255,255,0.07);
        --accent: #6ea5ff; --accent-ink: #9cc0ff; --accent-soft: rgba(110, 165, 255, 0.14);
        --hit: #4cc38a; --hit-soft: rgba(76, 195, 138, 0.16);
        --miss: #f08080; --miss-soft: rgba(240, 128, 128, 0.16);
        --pending: #5d5d68;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.4); --shadow: 0 14px 40px rgba(0,0,0,0.55);
        --p0: #6ea5ff; --p1: #9d92ff; --p2: #f0a04b; --p3: #3cc4b0; --p4: #f07aa5; --p5: #a9c95a; --p6: #e0b84a; --p7: #8fb8ff;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0f0f12; --surface: #18181d; --surface-2: #26262d; --text: #ececf0; --text-2: #c2c2ca; --muted: #8e8e98;
    --border: #2a2a32; --hair: rgba(255,255,255,0.07);
    --accent: #6ea5ff; --accent-ink: #9cc0ff; --accent-soft: rgba(110, 165, 255, 0.14);
    --hit: #4cc38a; --hit-soft: rgba(76, 195, 138, 0.16);
    --miss: #f08080; --miss-soft: rgba(240, 128, 128, 0.16);
    --pending: #5d5d68;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4); --shadow: 0 14px 40px rgba(0,0,0,0.55);
    --p0: #6ea5ff; --p1: #9d92ff; --p2: #f0a04b; --p3: #3cc4b0; --p4: #f07aa5; --p5: #a9c95a; --p6: #e0b84a; --p7: #8fb8ff;
    color-scheme: dark;
}
/* Mysight 고유색: 라임 */
:root { --accent: #65a30d; --accent-ink: #4d7c0f; --accent-soft: rgba(101, 163, 13, 0.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --accent: #a3e635; --accent-ink: #bef264; --accent-soft: rgba(163, 230, 53, 0.14); } }
:root[data-theme="dark"] { --accent: #a3e635; --accent-ink: #bef264; --accent-soft: rgba(163, 230, 53, 0.14); }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }

/* 상단 */
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; }
.bar .back { font-size: 13px; color: var(--muted); }
.bar .back:hover { color: var(--text); }
.bar h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.bar .sub { font-size: 12.5px; color: var(--muted); }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.plain { font-size: 12.5px; color: var(--muted); padding: 5px 9px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
.plain:hover { background: var(--surface-2); color: var(--text); }
.btn { font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #1c1c21; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--miss); }

/* 본문 */
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 22px 60px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px 22px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card h2 { font-size: 15px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card h2 small, .card h3 small { font-size: 12px; color: var(--muted); font-weight: 500; }
.card h3 { font-size: 13px; font-weight: 700; margin: 6px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.chips button, .filters button { font-size: 12.5px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface); font-weight: 500; }
.chips button[aria-pressed="true"], .filters button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chips input[type=date] { font: inherit; font-size: 12.5px; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 18px; }
.tile { padding: 14px 16px; border-radius: 14px; background: var(--bg); border: 1px solid var(--hair); }
.tile .v { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.tile .v small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 4px; letter-spacing: 0; }
.tile .k { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile.good .v { color: var(--hit); } .tile.bad .v { color: var(--miss); }
.two { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl th { text-align: right; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 0 8px 7px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.tbl td:first-child { font-weight: 600; }
.tbl tr.sel td { background: var(--accent-soft); }
.tbl td.up { color: var(--hit); font-weight: 700; } .tbl td.dn { color: var(--miss); font-weight: 700; }
.tbl td.muted, .muted { color: var(--muted); }
.slider { margin: -4px 0 16px; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.slider .slider-lbls { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.slider .slider-lbls b { color: var(--accent-ink); font-weight: 700; }
.chart.since svg { height: 190px; }
.chart .hit { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.chart .half { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 4 4; opacity: 0.55; }
.chart .cmp { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .cmp-l { fill: var(--muted); }
.chart .few { fill: var(--surface); stroke: var(--accent); stroke-width: 1.2; }
.chart .sel { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.6; }
.chart .selpt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 5px; }
.chart .legend i.half { border-top-style: dashed; opacity: 0.6; } .chart .legend i.cmp { border-top: 1px dotted var(--muted); } .chart .legend i.few { width: 8px; height: 8px; border: 1.2px solid var(--accent); border-radius: 50%; }
.fold { margin-top: 10px; } .fold summary { font-size: 12.5px; color: var(--muted); cursor: pointer; list-style: none; }
.fold summary::before { content: '▸ '; } .fold[open] summary::before { content: '▾ '; }
.chart { min-height: 150px; }
.chart svg { width: 100%; height: 160px; display: block; }
.chart .bar { fill: var(--accent); opacity: 0.85; }
.chart .bar.few { opacity: 0.35; }
.chart .lbl { font-size: 10.5px; fill: var(--muted); }
.chart .val { font-size: 10.5px; fill: var(--text); font-weight: 600; }
.chart .grid { stroke: var(--hair); stroke-width: 1; }
.foot { font-size: 11.5px; color: var(--muted); margin-top: 14px; line-height: 1.55; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; padding: 0 4px; }

/* 검색 */
.search { margin: 0 6px 0 0; }
.search input { width: 240px; font: inherit; font-size: 13px; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; outline: none; transition: width 0.15s, border-color 0.15s; }
.search input:focus { border-color: var(--accent); width: 300px; background: var(--surface); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
/* 목록 — 묶음 */
.groups { border-top: 1px solid var(--hair); }
.grp summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 6px; cursor: pointer; border-bottom: 1px solid var(--hair); font-size: 13px; }
.grp summary::-webkit-details-marker { display: none; }
.grp summary::before { content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); margin: 0 4px 0 2px; transition: transform 0.15s; }
.grp[open] summary::before { transform: rotate(45deg); }
.grp summary .cnt { font-size: 12px; color: var(--muted); font-weight: 500; }
.grp .rows { border-top: 0; }
.grp .rows .row { padding-left: 22px; }
.more { display: block; width: 100%; text-align: center; padding: 10px; font-size: 12.5px; color: var(--accent); font-weight: 600; border-bottom: 1px solid var(--hair); }
.more:hover { background: var(--bg); }
.rows { border-top: 1px solid var(--hair); }
.row { display: grid; grid-template-columns: 78px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 6px; border-bottom: 1px solid var(--hair); cursor: pointer; }
.row .r .meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row .r .meta em { font-style: normal; color: var(--accent-ink); }
.row:hover { background: var(--bg); }
.row time { color: var(--muted); font-size: 12.5px; }
.row .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t span { font-size: 12.5px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t span em { font-style: normal; color: var(--accent); margin-right: 8px; }
.row .r { display: flex; align-items: center; gap: 8px; }
.row.empty { grid-template-columns: 1fr; color: var(--muted); font-size: 13px; cursor: default; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.correct { background: var(--hit-soft); color: var(--hit); }
.badge.wrong { background: var(--miss-soft); color: var(--miss); }
.badge.partial { background: rgba(194, 98, 10, 0.14); color: #b45a08; }
.badge.pending { background: var(--surface-2); color: var(--muted); }
.badge.soon { background: var(--accent-soft); color: var(--accent); }
.badge.over { background: var(--miss-soft); color: var(--miss); }
.prob { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 상세 */
.detail-bg { position: fixed; inset: 0; background: rgba(10, 10, 20, 0.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(2px); }
.detail-bg[hidden] { display: none; }
.detail { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 22px 24px; }
.detail .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.detail h2 { font-size: 18px; font-weight: 700; line-height: 1.4; letter-spacing: -0.01em; margin-bottom: 14px; word-break: keep-all; }
.detail .kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: 13px; margin-bottom: 14px; }
.detail .kv dt { color: var(--muted); } .detail .kv dd { margin: 0; }
.detail .kv a { color: var(--accent); }
.detail .ev { background: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.6; margin-bottom: 14px; white-space: pre-wrap; }
.detail h4 { font-size: 12px; color: var(--muted); font-weight: 600; margin: 14px 0 6px; }
.detail .judge { background: var(--bg); border-radius: 12px; padding: 12px 14px 14px; margin: 4px 0 12px; }
.detail .judge h4 { margin: 0 0 8px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; color: var(--text); }
.detail .judge h4 small { font-weight: 500; color: var(--muted); }
.detail .judge textarea { width: 100%; min-height: 56px; resize: vertical; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; outline: none; }
.detail .judge textarea:focus { border-color: var(--accent); }
.detail .judge-btns { display: flex; gap: 8px; margin-top: 10px; }
.detail .judge-btns .btn { flex: 1; text-align: center; padding: 9px 0; font-size: 14px; }
.detail .acts.manage { margin-top: 2px; }
.detail .acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.detail .acts .sp { flex: 1; }
.detail .acts input[type=date] { font: inherit; font-size: 13px; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; }
.detail .lock { background: var(--bg); border-left: 3px solid var(--border); border-radius: 0 10px 10px 0; padding: 9px 12px; font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.detail .edit { background: var(--bg); border-radius: 12px; padding: 12px 14px 14px; margin: 6px 0 14px; }
.detail .edit h4 { margin-top: 0; }
.detail .edit label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin: 8px 0 4px; }
.detail .edit textarea, .detail .edit input { width: 100%; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; outline: none; }
.detail .edit textarea { min-height: 70px; resize: vertical; }
.detail .edit textarea:focus, .detail .edit input:focus { border-color: var(--accent); }
.detail .edit-row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 10px; }
.btn.correct { color: var(--hit); border-color: var(--hit); } .btn.wrong { color: var(--miss); border-color: var(--miss); } .btn.partial { color: #b45a08; border-color: #b45a08; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 999px; font-size: 13px; z-index: 60; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.toast.on { opacity: 1; }

@media (max-width: 760px) {
    .wrap { padding: 14px 12px 60px; }
    .card { padding: 16px 14px; border-radius: 14px; }
    .bar { padding: 10px 14px; flex-wrap: wrap; } .bar .sub { display: none; }
    .bar-actions { margin-left: auto; }
    .search { order: 10; flex-basis: 100%; margin: 8px 0 0; }
    .search input, .search input:focus { width: 100%; }
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .two { grid-template-columns: 1fr; gap: 18px; }
    .row { grid-template-columns: 62px minmax(0, 1fr); }
    .row .r { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; }
    .grp .rows .row { padding-left: 6px; }
    .detail { padding: 18px 16px; }
}
