/* ===========================================================
   InfoDesk – 1920x1080 기준 꽉 찬 반응형 바탕화면
   기본 폰트 크기는 화면 폭·높이에 비례 → 1080p≈16px, 4K≈32px
   =========================================================== */
:root {
  /* 바탕화면 아이콘 공간 (왼쪽/오른쪽) – 설정에서 조절 */
  --il: 0px; --ir: 0px;
  --aw: calc(100vw - var(--il) - var(--ir));
  --fs: clamp(11px, min(calc(var(--aw) * 0.0085), 1.5vh), 40px);
  --gap: calc(var(--fs) * 0.75);
  --radius: calc(var(--fs) * 0.9);
  --font: 'Pretendard Variable', Pretendard, -apple-system, 'Malgun Gothic', sans-serif;
  --ok: #22c55e; --mid: #eab308; --bad: #f97316; --worst: #ef4444;
  --blue: #3b82f6;
}
html[data-theme='dark'] {
  --bg: #000; --panel: #0a0a0a; --panel2: #141414; --line: #1f1f1f;
  --text: #f4f4f5; --sub: #a1a1aa; --mute: #52525b; --accent: #fafafa;
  --hover: #1a1a1a; --shadow: none; color-scheme: dark;
}
html[data-theme='light'] {
  --bg: #fff; --panel: #fafafa; --panel2: #f1f1f2; --line: #e4e4e7;
  --text: #09090b; --sub: #52525b; --mute: #a1a1aa; --accent: #000;
  --hover: #ececee; --shadow: 0 1px 2px rgba(0,0,0,.04); color-scheme: light;
}

/* 컬러 테마: 시안 / 분홍 / 연빨강 / 연하늘 */
html[data-theme='cyan'] {
  --bg: #cffafe; --panel: #ecfeff; --panel2: #cffafe; --line: #a5f3fc;
  --text: #083344; --sub: #155e75; --mute: #5f9fb0; --accent: #0e7490;
  --hover: #d5f9fd; --shadow: 0 1px 3px rgba(8,51,68,.06); color-scheme: light;
}
html[data-theme='pink'] {
  --bg: #fce7f3; --panel: #fdf2f8; --panel2: #fce7f3; --line: #fbcfe8;
  --text: #500724; --sub: #9d174d; --mute: #c97aa2; --accent: #db2777;
  --hover: #fbe3f0; --shadow: 0 1px 3px rgba(80,7,36,.06); color-scheme: light;
}
html[data-theme='lightred'] {
  --bg: #fee2e2; --panel: #fef2f2; --panel2: #fee2e2; --line: #fecaca;
  --text: #450a0a; --sub: #991b1b; --mute: #c98585; --accent: #dc2626;
  --hover: #fde4e4; --shadow: 0 1px 3px rgba(69,10,10,.06); color-scheme: light;
}
html[data-theme='sky'] {
  --bg: #e0f2fe; --panel: #f0f9ff; --panel2: #e0f2fe; --line: #bae6fd;
  --text: #082f49; --sub: #075985; --mute: #6b9fc0; --accent: #0284c7;
  --hover: #e3f3fd; --shadow: 0 1px 3px rgba(8,47,73,.06); color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; background: var(--bg); color: var(--text); }
body { font-family: var(--font); font-size: var(--fs); line-height: 1.4; overflow: hidden;
  -webkit-font-smoothing: antialiased; transition: background .4s, color .4s; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* ---------------- 메인 그리드 ---------------- */
#desk {
  width: 100vw; height: 100vh; gap: var(--gap);
  padding: var(--gap) calc(var(--gap) + var(--ir)) var(--gap) calc(var(--gap) + var(--il));
  transition: padding .25s;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.12fr);
  grid-template-rows: auto minmax(0, 1.15fr) minmax(0, 1fr) auto;
  grid-template-areas:
    'top top top top top'
    'weather news news ott disaster'
    'fortune air lotto events market'
    'ticker ticker ticker ticker ticker';
}
#top-bar { grid-area: top; }
#weather-panel { grid-area: weather; }
#news-panel { grid-area: news; }
#disaster-panel { grid-area: disaster; }
#fortune-panel { grid-area: fortune; }
#air-panel { grid-area: air; }
#lotto-panel { grid-area: lotto; }
#ott-panel { grid-area: ott; }
#events-panel { grid-area: events; }
#market-panel { grid-area: market; }
#ticker { grid-area: ticker; }
.panel.hidden { display: none !important; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; transition: background .4s, border-color .4s;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: .6em;
  padding: .85em 1.1em .5em; flex: none;
}
.panel-head h2 { font-size: 1em; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.panel-head h2 i { color: var(--sub); margin-right: .35em; width: 1.1em; text-align: center; }
.panel-sub { font-size: .8em; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { flex: 1; min-height: 0; padding: .3em 1.1em 1em; overflow: auto; scrollbar-width: none; }
.panel-body::-webkit-scrollbar { display: none; }
.loading, .error { color: var(--mute); font-size: .9em; padding: 1em 0; }
.error { color: var(--worst); }
.muted { color: var(--sub); }
.tiny { font-size: .72em; color: var(--mute); }

.tabs { display: flex; gap: .25em; overflow: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { font-size: .75em; padding: .3em .6em; border-radius: 999px; color: var(--sub); white-space: nowrap;
  border: 1px solid transparent; transition: .2s; }
.tab:hover { background: var(--hover); }
.tab.active { background: var(--accent); color: var(--bg); font-weight: 600; }

/* ---------------- 상단 바 ---------------- */
#top-bar { flex-direction: row; align-items: center; padding: .55em 1.2em; gap: 1.5em; }
#clock-block { display: flex; align-items: center; gap: 1em; flex: none; }
#clock-time { font-size: 3.3em; font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
#clock-sec { font-size: .45em; color: var(--mute); font-weight: 600; margin-left: .1em; }
#clock-sec.off { display: none; }
#clock-date { font-size: 1.05em; font-weight: 600; }
#clock-greet { font-size: .85em; color: var(--sub); }
#status-chips { flex: 1; display: flex; gap: .5em; justify-content: center; flex-wrap: wrap; overflow: hidden; max-height: 4.2em; }
.chip { display: inline-flex; align-items: center; gap: .45em; padding: .45em .9em; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); font-size: .88em; white-space: nowrap; }
.chip i { color: var(--sub); }
.chip b { font-weight: 700; }
.dot { width: .6em; height: .6em; border-radius: 50%; display: inline-block; }
#toolbar { display: flex; gap: .3em; flex: none; opacity: .35; transition: opacity .3s; }
#top-bar:hover #toolbar { opacity: 1; }
.tool-btn { width: 2.4em; height: 2.4em; border-radius: 50%; display: grid; place-items: center; color: var(--sub); }
.tool-btn:hover { background: var(--hover); color: var(--text); }
.tool-btn.spin i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 날씨 ---------------- */
.wx-now { display: flex; align-items: center; gap: 1em; }
.wx-icon { font-size: 4.2em; line-height: 1; width: 1.2em; text-align: center; }
.wx-temp { font-size: 4em; font-weight: 800; letter-spacing: -.05em; line-height: 1; }
.wx-temp sup { font-size: .4em; font-weight: 600; vertical-align: top; color: var(--sub); }
.wx-desc { font-size: 1.15em; font-weight: 600; }
.wx-range { font-size: .85em; color: var(--sub); }
.wx-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45em; margin: .9em 0; }
.wx-cell { background: var(--panel2); border-radius: .6em; padding: .45em .6em; }
.wx-cell .k { font-size: .7em; color: var(--sub); }
.wx-cell .v { font-size: .95em; font-weight: 700; }
.wx-hourly { display: grid; grid-template-columns: repeat(8, 1fr); gap: .2em; text-align: center;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .55em 0; }
.wx-hourly .h { font-size: .7em; color: var(--sub); }
.wx-hourly .i { font-size: 1.15em; margin: .15em 0; }
.wx-hourly .t { font-size: .85em; font-weight: 700; }
.wx-hourly .p { font-size: .62em; color: var(--blue); }
.wx-daily { margin-top: .5em; }
.wx-day { display: grid; grid-template-columns: 3.2em 1.6em 2.8em 1fr 2.8em; align-items: center; gap: .5em; padding: .22em 0; font-size: .88em; }
.wx-day .d { font-weight: 600; }
.wx-day .lo { color: var(--sub); text-align: right; }
.wx-day .hi { font-weight: 700; }
.wx-bar { height: .35em; border-radius: 999px; background: var(--panel2); position: relative; }
.wx-bar span { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, #60a5fa, #fbbf24, #f87171); }

/* ---------------- 뉴스 ---------------- */
#news-body { display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: min-content; gap: .2em 1.4em; align-content: start; }
.news-item { display: grid; grid-template-columns: 5.4em 1fr; gap: .75em; padding: .6em .4em; border-bottom: 1px solid var(--line);
  border-radius: .4em; transition: background .2s; animation: fadeIn .5s both; }
.news-item:hover { background: var(--hover); }
.news-item.no-thumb { grid-template-columns: 1fr; }
.news-thumb { width: 5.4em; height: 3.7em; border-radius: .45em; object-fit: cover; background: var(--panel2); }
.news-title { font-weight: 650; font-size: .95em; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news-lede { font-size: .76em; color: var(--sub); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; margin-top: .15em; }
.news-press { font-size: .7em; color: var(--mute); margin-top: .1em; }
.news-progress { height: 2px; background: var(--line); flex: none; }
#news-progress-bar { height: 100%; width: 0; background: var(--accent); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- 미세먼지 ---------------- */
.air-main { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6em; }
.air-gauge { background: var(--panel2); border-radius: .8em; padding: .7em .8em; text-align: center; }
.air-gauge .label { font-size: .75em; color: var(--sub); }
.air-gauge .grade { font-size: 1.6em; font-weight: 800; margin: .1em 0; }
.air-gauge .val { font-size: .85em; color: var(--sub); }
.air-gauge .val b { color: var(--text); font-size: 1.15em; }
.ring { width: 5.2em; height: 5.2em; margin: .35em auto .2em; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .face { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2em; }
.air-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4em; margin-top: .6em; }
.air-mini div { background: var(--panel2); border-radius: .5em; padding: .35em .3em; text-align: center; }
.air-mini .k { font-size: .65em; color: var(--sub); }
.air-mini .v { font-size: .85em; font-weight: 700; }
.air-chart { display: flex; align-items: flex-end; gap: 2px; height: 3.2em; margin-top: .7em; }
.air-chart span { flex: 1; border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.air-chart-label { display: flex; justify-content: space-between; font-size: .65em; color: var(--mute); margin-top: .2em; }

/* ---------------- 행운 ---------------- */
.ft-zodiac { display: flex; align-items: center; gap: .8em; }
.ft-emoji { font-size: 3.2em; line-height: 1; }
.ft-zname { font-size: 1.2em; font-weight: 800; }
.ft-msg { font-size: .85em; color: var(--sub); line-height: 1.45; }
.ft-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45em; margin-top: .7em; }
.ft-box { background: var(--panel2); border-radius: .6em; padding: .5em .7em; }
.ft-box .k { font-size: .7em; color: var(--sub); }
.ft-box .v { font-size: 1em; font-weight: 700; display: flex; align-items: center; gap: .4em; }
.swatch { width: 1em; height: 1em; border-radius: .3em; border: 1px solid var(--line); display: inline-block; }
.ft-nums { display: flex; gap: .3em; margin-top: .25em; flex-wrap: wrap; }
.ft-nums span { width: 1.9em; height: 1.9em; border-radius: 50%; display: grid; place-items: center; font-size: .82em; font-weight: 700;
  border: 1.5px solid var(--accent); }
.stars { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3em; margin-top: .6em; text-align: center; }
.stars div { font-size: .7em; color: var(--sub); }
.stars b { display: block; font-size: 1.1em; color: #f59e0b; letter-spacing: -.1em; }

/* ---------------- 로또 ---------------- */
.lt-sec + .lt-sec { margin-top: .8em; padding-top: .7em; border-top: 1px solid var(--line); }
.lt-title { display: flex; justify-content: space-between; align-items: baseline; font-size: .85em; }
.lt-title b { font-size: 1.1em; }
.balls { display: flex; align-items: center; gap: .3em; margin: .45em 0; flex-wrap: wrap; }
.ball { width: 2.25em; height: 2.25em; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff;
  font-size: .95em; text-shadow: 0 1px 1px rgba(0,0,0,.25); box-shadow: inset -2px -3px 5px rgba(0,0,0,.18); flex: none; }
.ball.sm { width: 1.85em; height: 1.85em; font-size: .78em; }
.b1 { background: #fbc400; } .b2 { background: #69c8f2; } .b3 { background: #ff7272; } .b4 { background: #aaa; } .b5 { background: #b0d840; }
.plus { color: var(--mute); font-weight: 700; }
.pen { background: var(--panel2); color: var(--text); text-shadow: none; box-shadow: none; border: 1.5px solid var(--line); }
.pen.grp { background: var(--accent); color: var(--bg); }
.lt-info { font-size: .76em; color: var(--sub); }
.lt-info b { color: var(--text); }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.gen-row { display: flex; align-items: center; gap: .3em; }
.gen-btn { font-size: .72em; padding: .25em .7em; border-radius: 999px; border: 1px solid var(--line); color: var(--sub); }
.gen-btn:hover { background: var(--hover); color: var(--text); }
.gen-list .balls { margin: .25em 0; }

/* ---------------- 비트코인 · 주식 패널 ---------------- */
#market-panel .panel-body { display: flex; flex-direction: column; padding-top: 0; }
.mk-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mk-row { flex: 1 1 0; min-height: 2.3em; display: grid; grid-template-columns: 6.5em minmax(0, 1fr) auto; align-items: center; gap: .6em;
  border-bottom: 1px solid var(--line); padding: 0 .15em; overflow: hidden; font-variant-numeric: tabular-nums; animation: fadeIn .4s both; }
.mk-row:last-child { border-bottom: 0; }
.mk-row:hover { background: var(--hover); }
.mk-id { min-width: 0; display: flex; align-items: center; gap: .45em; }
.mk-ic { width: 1.55em; height: 1.55em; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: .7em; font-weight: 900; color: #fff; }
.mk-nm { font-size: .78em; letter-spacing: -.02em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.mk-pr { font-size: .62em; font-weight: 600; white-space: nowrap; display: block; }
.mk-spark { width: 100%; height: 72%; max-height: 2.6em; display: block; overflow: visible; }
.mk-val { text-align: right; white-space: nowrap; line-height: 1.2; }
.mk-val b { display: block; font-size: .82em; font-weight: 800; }
.mk-val span { font-size: .68em; font-weight: 700; }
.mk-shut { display: inline-block; width: .38em; height: .38em; border-radius: 50%; background: var(--mute); margin-left: .3em; vertical-align: middle; }
.c-up { color: #ef4444; } .c-down { color: #3b82f6; } .c-flat { color: var(--mute); }
#disaster-panel .world { max-height: 42%; object-fit: contain; }

/* ---------------- 재난 ---------------- */
.ds-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45em; margin-bottom: .7em; }
.ds-card { background: var(--panel2); border-radius: .7em; padding: .55em .75em; min-width: 0; }
.ds-card .k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-card .k { font-size: .7em; color: var(--sub); }
.ds-card .v { font-size: 1.35em; font-weight: 800; }
.ds-card .s { font-size: .68em; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-item { display: grid; grid-template-columns: 2.8em 1fr; gap: .7em; align-items: center; padding: .5em .2em; border-bottom: 1px solid var(--line); }
.ds-item:hover { background: var(--hover); }
.ds-badge { width: 2.8em; height: 2.8em; border-radius: .6em; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: .9em; }
.ds-title { font-size: .86em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds-meta { font-size: .7em; color: var(--sub); }
.ds-near { outline: 1.5px solid var(--worst); outline-offset: -1.5px; border-radius: .5em; }
.kp-bars { display: flex; gap: .3em; align-items: flex-end; height: 6em; margin: .6em 0; }
.kp-bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: .2em; }
.kp-bars span { width: 100%; border-radius: .3em .3em 0 0; }
.kp-bars small { font-size: .62em; color: var(--mute); }
.world { width: 100%; aspect-ratio: 2 / 1; background: var(--panel2); border-radius: .7em; margin-bottom: .6em; display: block; }

/* ---------------- OTT TOP 10 ---------------- */
#ott-panel .panel-body { display: flex; flex-direction: column; padding-top: .1em; }
.ott-tabs { display: flex; flex-wrap: wrap; gap: .25em; padding: 0 1.1em .45em; flex: none; }
.ott-tab { font-size: .7em; padding: .22em .6em; border-radius: 999px; border: 1px solid var(--line); color: var(--sub); white-space: nowrap; }
.ott-tab:hover { background: var(--hover); }
.ott-tab.active { color: #fff; border-color: transparent; font-weight: 700; }
.ott-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ott-item { flex: 1 1 0; min-height: 2.1em; display: grid; grid-template-columns: 1.5em 3.2em minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr); align-items: center; gap: .55em;
  border-bottom: 1px solid var(--line); padding: 0 .2em; overflow: hidden; animation: fadeIn .4s both; }
.ott-item:last-child { border-bottom: 0; }
.ott-item:hover { background: var(--hover); }
.ott-rank { font-size: 1.15em; font-weight: 900; text-align: center; font-style: italic; letter-spacing: -.05em; }
.ott-item.top .ott-rank { color: var(--accent); }
.ott-thumb { width: 3.2em; height: 2em; max-height: 100%; border-radius: .35em; object-fit: cover; background: var(--panel2); display: block; }
.ott-title { font-size: .86em; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ott-meta { font-size: .66em; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ott-chg { font-size: .7em; font-weight: 700; min-width: 2.6em; text-align: right; white-space: nowrap; }
.ott-chg.up { color: #ef4444; } .ott-chg.down { color: #3b82f6; } .ott-chg.same { color: var(--mute); }
.ott-chg.new { color: #fff; background: #f59e0b; border-radius: .3em; padding: .05em .35em; min-width: 0; font-size: .6em; }
.ott-progress { height: 2px; background: var(--line); flex: none; }
#ott-progress-bar { height: 100%; width: 0; background: var(--accent); }

/* ---------------- 특별한 날 ---------------- */
.head-btn { font-size: .75em; padding: .2em .65em; border-radius: 999px; border: 1px solid var(--line); color: var(--sub); white-space: nowrap; }
.head-btn:hover { background: var(--hover); color: var(--text); }
.ev-today { border-radius: .7em; padding: .55em .8em; margin-bottom: .55em; background: var(--panel2); border-left: .3em solid var(--accent); }
.ev-today.holiday { border-left-color: #ef4444; }
.ev-today .k { font-size: .68em; color: var(--sub); }
.ev-today .v { font-size: 1.05em; font-weight: 800; }
.ev-today .v small { font-size: .7em; font-weight: 600; color: var(--sub); margin-left: .3em; }
.ev-item { display: grid; grid-template-columns: 1.6em 1fr auto; align-items: center; gap: .5em; padding: .32em .15em; border-bottom: 1px solid var(--line); }
.ev-item .ic { font-size: 1.05em; text-align: center; }
.ev-item .nm { font-size: .85em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-item .dt { font-size: .66em; color: var(--sub); }
.ev-item .dd { font-size: .78em; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev-item.holiday .nm, .ev-item.holiday .dd { color: #ef4444; }
.ev-item.term .nm { color: var(--sub); font-weight: 500; }
.ev-item.mine .nm::after { content: '내 일정'; font-size: .65em; margin-left: .4em; padding: .05em .4em; border-radius: .3em; background: var(--accent); color: var(--bg); vertical-align: middle; }
.ev-item .del { color: var(--mute); font-size: .8em; padding: .2em .4em; border-radius: .3em; }
.ev-item .del:hover { color: #ef4444; background: var(--hover); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: .1em; text-align: center; margin-bottom: .5em; }
.cal .wd { font-size: .65em; color: var(--mute); padding-bottom: .2em; }
.cal .wd:first-child, .cal .d.sun, .cal .d.hol { color: #ef4444; }
.cal .wd:last-child, .cal .d.sat { color: #3b82f6; }
.cal .d { font-size: .78em; padding: .25em 0 .35em; border-radius: .4em; position: relative; font-variant-numeric: tabular-nums; }
.cal .d.other { opacity: .3; }
.cal .d.today { background: var(--accent); color: var(--bg) !important; font-weight: 800; }
.cal .d.has::after { content: ''; position: absolute; left: 50%; bottom: .12em; width: .3em; height: .3em; margin-left: -.15em; border-radius: 50%; background: var(--accent); }
.cal .d.today.has::after { background: var(--bg); }
.cal-title { display: flex; justify-content: space-between; align-items: center; font-size: .85em; font-weight: 700; margin-bottom: .3em; }
.cal-title button { color: var(--sub); padding: 0 .5em; }
.empty-hint { text-align: center; color: var(--mute); font-size: .82em; padding: 1.2em 0; line-height: 1.7; }

/* 테마 스와치 */
.theme-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4em; }
.theme-opt { display: flex !important; flex-direction: column !important; align-items: center; gap: .25em !important; cursor: pointer; font-size: .8em; color: var(--text) !important; }
.theme-opt input { display: none; }
.theme-opt span.sw { width: 2.4em; height: 2.4em; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8em; }
.theme-opt input:checked + span.sw { outline: 2.5px solid var(--accent); outline-offset: 2px; }
#events-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6em; }
#events-form-grid .full { grid-column: 1 / -1; }
#settings-form input[type=text], #settings-form input[type=date], #events-form input[type=text], #events-form input[type=date], #events-form select {
  font: inherit; font-size: 1em; padding: .5em .7em; border-radius: .5em; border: 1px solid var(--line); background: var(--panel2); color: var(--text); width: 100%; }
#events-form { padding: 1.4em; display: flex; flex-direction: column; gap: .8em; }
#events-form h3 { font-size: 1.2em; }
#events-form label { display: flex; flex-direction: column; gap: .3em; font-size: .85em; color: var(--sub); }
#events-form label.inline { flex-direction: row; align-items: center; gap: .45em; color: var(--text); }
#my-events-list { max-height: 14em; overflow: auto; border: 1px solid var(--line); border-radius: .6em; padding: .2em .6em; }

#toast { position: fixed; left: 50%; bottom: 4em; transform: translate(-50%, 1em); background: var(--accent); color: var(--bg); padding: .6em 1.2em;
  border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: .3s; z-index: 99; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 아이콘 공간 미리보기 (설정 중에만 표시) */
html.show-zones body::before, html.show-zones body::after {
  content: '아이콘 공간'; position: fixed; top: 0; bottom: 0; z-index: 50; display: grid; place-items: center;
  writing-mode: vertical-rl; font-size: 14px; font-weight: 700; letter-spacing: .3em; color: #fff;
  background: repeating-linear-gradient(45deg, rgba(59,130,246,.35) 0 12px, rgba(59,130,246,.18) 12px 24px);
  border: 2px dashed #3b82f6; pointer-events: none; overflow: hidden; }
html.show-zones body::before { left: 0; width: var(--il); }
html.show-zones body::after { right: 0; width: var(--ir); }
.zone-row { display: grid; grid-template-columns: 3em 1fr 4.2em; align-items: center; gap: .6em; font-size: .85em; margin: .2em 0; }
.zone-row input[type=range] { width: 100%; accent-color: var(--accent); }
.zone-row b { text-align: right; font-variant-numeric: tabular-nums; }
.zone-presets { display: flex; flex-wrap: wrap; gap: .3em; margin-top: .45em; }
.zone-presets button { font-size: .75em; padding: .25em .7em; border-radius: 999px; border: 1px solid var(--line); color: var(--sub); }
.zone-presets button:hover { background: var(--hover); color: var(--text); }

#net-badge { display: inline-flex; align-items: center; gap: .35em; margin-top: .2em; font-size: .75em; font-weight: 700; color: #fff;
  background: #ef4444; padding: .1em .6em; border-radius: 999px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* 데스크톱 프로그램 · 팝업 창 (설정 / 특별한 날) */
html.popup-mode, html.popup-mode body { overflow: hidden; background: var(--panel); }
html.popup-mode #desk { display: none; }
html.popup-mode.show-zones body::before, html.popup-mode.show-zones body::after { display: none; }
html.popup-mode dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; margin: 0; border: 0; border-radius: 0; font-size: 15px; overflow: auto; }
html.popup-mode dialog::backdrop { background: var(--panel); backdrop-filter: none; }
html.popup-mode #toast { bottom: 1.5em; }

/* 데스크톱 프로그램 */
.quit-btn:hover { background: #ef4444 !important; color: #fff !important; }
html.wallpaper-mode #toolbar { opacity: .25; }

/* ---------------- 티커 ---------------- */
#ticker { flex-direction: row; align-items: center; padding: .45em 1em; gap: 1em; }
#ticker-label { font-weight: 800; font-size: .82em; flex: none; color: var(--worst); }
#ticker-track { flex: 1; overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent); }
#ticker-inner { display: inline-block; padding-left: 100%; animation: ticker 120s linear infinite; font-size: .88em; }
#ticker-inner span { margin-right: 3em; }
#ticker-inner span::before { content: '•'; margin-right: .6em; color: var(--mute); }
#ticker:hover #ticker-inner { animation-play-state: paused; }
#credit-badge { flex: none; font-size: .75em; color: var(--sub); padding: .15em .7em; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
#credit-badge b { color: var(--accent); font-weight: 800; }
@keyframes ticker { to { transform: translateX(-100%); } }

/* ---------------- 설정 다이얼로그 ---------------- */
dialog { margin: auto; border: 1px solid var(--line); border-radius: 1em; background: var(--panel); color: var(--text);
  width: min(32em, 92vw); max-height: 90vh; font-size: var(--fs); }
dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
#settings-form { padding: 1.4em; display: flex; flex-direction: column; gap: .9em; }
#settings-form h3 { font-size: 1.2em; }
#settings-form label { display: flex; flex-direction: column; gap: .3em; font-size: .85em; color: var(--sub); }
#settings-form label.inline { flex-direction: row; align-items: center; gap: .5em; color: var(--text); }
#settings-form input[type=number], #settings-form select { font: inherit; font-size: 1.05em; padding: .5em .7em; border-radius: .5em;
  border: 1px solid var(--line); background: var(--panel2); color: var(--text); width: 100%; }
#settings-form .row { display: flex; gap: .4em; }
fieldset { border: 1px solid var(--line); border-radius: .6em; padding: .6em .8em; }
legend { font-size: .8em; color: var(--sub); padding: 0 .3em; }
.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35em; font-size: .85em; }
.check-grid label { flex-direction: row !important; align-items: center; color: var(--text) !important; gap: .35em !important; }
.sm-btn { padding: .5em 1em; border-radius: .5em; border: 1px solid var(--line); background: var(--panel2); white-space: nowrap; font-size: .9em; }
.sm-btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 700; }
.sm-btn.ghost { background: none; }
menu { display: flex; justify-content: flex-end; gap: .5em; }
.hint { font-size: .75em; color: var(--mute); }

/* ---------------- 반응형: 작은 화면 ---------------- */
@media (max-width: 1280px), (max-aspect-ratio: 4/3) {
  :root { --fs: clamp(12px, 1.3vw, 18px); }
  body { overflow: auto; }
  #desk { height: auto; min-height: 100vh; display: flex; flex-wrap: wrap; align-content: flex-start; }
  #desk > .panel { width: calc(50% - var(--gap) / 2); min-height: 24em; }
  #desk > #top-bar, #desk > #news-panel, #desk > #disaster-panel, #desk > #ticker { width: 100%; }
  #top-bar, #ticker { min-height: 0 !important; }
  #news-panel { order: 1; min-height: 32em !important; }
  #weather-panel { order: 2; } #air-panel { order: 3; } #fortune-panel { order: 4; } #lotto-panel { order: 5; }
  #ott-panel { order: 6; min-height: 30em !important; } #events-panel { order: 7; min-height: 30em !important; }
  #disaster-panel { order: 8; min-height: 36em !important; } #market-panel { order: 9; min-height: 26em !important; } #ticker { order: 10; }
}
@media (max-width: 760px) {
  :root { --fs: 14px; }
  #desk > .panel { width: 100% !important; }
  #news-body { grid-template-columns: 1fr; }
  #top-bar { flex-wrap: wrap; }
  #status-chips { justify-content: flex-start; max-height: none; }
}

/* 당첨자 수 */
.win-sec { flex: 1; min-height: 0; }
.win-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7em; margin-top: .45em; }
.win-col { min-width: 0; }
.win-h { font-size: .74em; color: var(--sub); margin-bottom: .25em; font-weight: 600; }
.win-row { display: grid; grid-template-columns: 2.9em auto 1fr; align-items: baseline; gap: .35em; font-size: .8em; padding: .22em 0; border-bottom: 1px dashed var(--line); }
.win-row:last-child { border-bottom: 0; }
.win-rk { color: var(--sub); font-size: .92em; }
.win-row.r1 .win-rk { color: #f59e0b; font-weight: 700; }
.win-row.r2 .win-rk { color: #60a5fa; font-weight: 700; }
.win-n b { font-size: 1.15em; }
.win-amt { text-align: right; color: var(--sub); font-size: .88em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 시세 목록 편집 */
.mk-search { position: relative; }
.mk-search input { width: 100%; }
.mk-results { display: flex; flex-direction: column; max-height: 13em; overflow-y: auto; margin-top: .3em; border-radius: .5em; }
.mk-results:empty { display: none; }
.mk-res { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: .5em; text-align: left; padding: .4em .55em; border-bottom: 1px solid var(--line); font-size: .85em; color: var(--text); }
.mk-res:hover:not([disabled]) { background: var(--hover); }
.mk-res[disabled] { opacity: .5; cursor: default; }
.mk-res .tiny { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-add { font-size: .85em; color: var(--accent, #60a5fa); white-space: nowrap; }
.mk-my { list-style: none; margin: .5em 0 0; padding: 0; display: flex; flex-direction: column; gap: .25em; }
.mk-my li { display: flex; align-items: center; gap: .45em; font-size: .85em; padding: .3em .5em; border: 1px solid var(--line); border-radius: .45em; }
.mk-my-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.mk-my li button { width: 1.8em; height: 1.8em; border-radius: .35em; border: 1px solid var(--line); color: var(--sub); }
.mk-my li button:hover:not([disabled]) { background: var(--hover); color: var(--text); }
.mk-my li button[disabled] { opacity: .3; }
.mk-kind { font-size: .72em; padding: .1em .45em; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.mk-kind.k-kr { background: rgba(59,130,246,.18); color: #60a5fa; }
.mk-kind.k-ws { background: rgba(168,85,247,.18); color: #c084fc; }
.mk-kind.k-coin { background: rgba(245,158,11,.18); color: #f59e0b; }
#btn-mk-edit { margin-left: .3em; padding: .1em .5em; }
/* 종목이 많을 때 행 압축 */
.mk-list.dense .mk-row { min-height: 1.9em; font-size: .9em; }
.mk-list.dense .mk-pr { display: none; }

/* 패널 드래그 앤 드롭 */
#desk > .panel > .panel-head { cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
#desk > .panel > .panel-head h2::after { content: '⠿'; margin-left: .45em; font-size: .85em; color: var(--mute); opacity: 0; transition: opacity .15s; }
#desk > .panel > .panel-head:hover h2::after { opacity: 1; }
html.layout-locked #desk > .panel > .panel-head { cursor: default; touch-action: auto; }
html.layout-locked #desk > .panel > .panel-head h2::after { display: none; }
html.panel-dragging, html.panel-dragging * { cursor: grabbing !important; user-select: none !important; }
.panel.drag-src { opacity: .35; }
.panel.drop-target { outline: 2px dashed var(--accent); outline-offset: -3px; }
#drag-ghost { position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none; display: flex; align-items: center; gap: .4em;
  padding: .55em .95em; border-radius: .6em; background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(0,0,0,.35); font-weight: 700; white-space: nowrap; }
#drag-ghost i { color: var(--sub); }

/* 대시보드 글자 선택(파란 블록) 막기 — 입력칸·설정 창은 그대로 선택 가능 */
body, body *, #drag-ghost { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#desk img, #desk a { -webkit-user-drag: none; user-drag: none; }
body > :not(dialog) ::selection { background: transparent; }
dialog, dialog *, input, textarea, select, [contenteditable] { user-select: text; -webkit-user-select: text; }
