:root {
  --bg: #0E1116; --card: #161B22; --line: #262D38; --line2: #2F3846;
  --text: #E6EAF0; --muted: #9AA4B2; --soft: #C3CBD6;
  --up: #3DD68C; --down: #FF7B72; --amber: #F2C86B; --accent: #7AA2F7;
  --up-bg: rgba(61, 214, 140, .12); --down-bg: rgba(255, 123, 114, .11);
  --mono: ui-monospace, "SF Mono", "IBM Plex Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 10px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.err { color: var(--down); min-height: 18px; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.status { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; flex: 1 1 auto; }
.status .chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand { flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--soft); background: #1B222C; white-space: nowrap; }
.chip.warn { color: var(--amber); border-color: #5A4A1E; background: #2A2412; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #1B222C; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.vix { padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; flex-wrap: wrap; }
.vix .left { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.vix .val { font-size: 18px; font-weight: 500; }
.vix svg { display: block; }

.presets { display: flex; gap: 8px; overflow-x: auto; margin: -4px -16px; padding: 4px 16px; scrollbar-width: none; }
.presets::-webkit-scrollbar { display: none; }
.pbtn { flex: none; min-height: 56px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--card); display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; text-align: left; }
.pbtn.up { background: var(--up-bg); border-color: rgba(61, 214, 140, .3); }
.pbtn.down { background: var(--down-bg); border-color: rgba(255, 123, 114, .3); }
.pbtn[aria-pressed="true"] { border: 2px solid var(--accent); padding: 5px 13px; box-shadow: 0 0 0 3px rgba(122, 162, 247, .22); }
.pn { font-size: 14px; font-weight: 600; white-space: nowrap; }
.pn .tag { font-size: 11px; opacity: .8; font-weight: 500; margin-left: 6px; }
.pm { display: flex; align-items: center; gap: 8px; }
.ps { font-size: 12px; color: var(--muted); }
.pbtn.up .ps { color: var(--up); }
.pbtn.down .ps { color: var(--down); }
.dots { display: flex; gap: 3px; align-items: center; }
.dots i { width: 5px; height: 12px; border-radius: 2px; background: #3A4350; display: block; }
.dots i.up { background: var(--up); }
.dots i.down { background: var(--down); }
.dots i.flat { background: var(--muted); }
.dots i.na { background: transparent; border: 1px solid #3A4350; }
.pbtn.add { border-style: dashed; background: transparent; color: #8DB4FF; font-size: 14px; font-weight: 600; align-items: center; padding: 0 16px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; } }
.tile { border-radius: 12px; padding: 10px 12px; min-width: 0; border: 1px solid var(--line); background: var(--card); }
.tile.up { background: var(--up-bg); border-color: rgba(61, 214, 140, .25); }
.tile.down { background: var(--down-bg); border-color: rgba(255, 123, 114, .25); }
.tile .row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.tile .sym { font-size: 14px; font-weight: 600; }
.tile .nm { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .px { font-size: 20px; font-weight: 500; margin-top: 6px; }
.tile .chg { font-size: 13px; }
.up .chg, .chg.up { color: var(--up); }
.down .chg, .chg.down { color: var(--down); }
.flat .chg { color: var(--muted); }
.range { margin-top: 8px; }
.bar { position: relative; height: 4px; border-radius: 2px; background: #2A323E; }
.bar i { position: absolute; top: -3px; width: 3px; height: 10px; border-radius: 2px; background: var(--text); transform: translateX(-1px); }
.rl { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 4px; }
.empty { grid-column: 1 / -1; padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line2); border-radius: 12px; }

.foot { border-top: 1px solid var(--line); padding-top: 4px; display: flex; flex-direction: column; gap: 6px; }
.links { display: flex; gap: 16px; flex-wrap: wrap; }
.link { background: none; border: 0; padding: 0; min-height: 44px; color: #8DB4FF; font-size: 13px; text-decoration: underline; }

dialog { width: min(440px, calc(100vw - 24px)); border: 1px solid var(--line2); border-radius: 16px; background: var(--card); color: var(--text); padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.dlg h2 { margin: 0 0 4px; font-size: 18px; }
.dlg label { font-size: 13px; font-weight: 500; color: var(--soft); margin-top: 6px; }
.dlg input[type="text"], .addrow input { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg); color: var(--text); font-size: 15px; }
.addrow { display: flex; gap: 8px; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; min-height: 8px; }
.chips li { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line2); border-radius: 999px; background: #1B222C; padding: 0 4px 0 12px; font-family: var(--mono); font-size: 13px; }
.chips button { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 50%; color: var(--muted); font-size: 16px; }
.chips button:hover { color: var(--text); background: #2A323E; }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.spacer { flex: 1; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line2); background: transparent; font-size: 14px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0B1220; font-weight: 700; }
.btn.danger { color: var(--down); border-color: rgba(255, 123, 114, .4); }

.vix .src { display: none; }
@media (min-width: 640px) { .vix .src { display: block; } }

/* ---------- step 2: weekly change, feed, sectors ---------- */
.tile .wk { font-size: 12px; color: var(--muted); margin-top: 2px; }
.c-up { color: var(--up); }
.c-down { color: var(--down); }
.c-flat { color: var(--muted); }
.tile .wk .c-up { color: var(--up); }
.tile .wk .c-down { color: var(--down); }
.tile .wk .c-flat { color: var(--muted); }

.feed .head { padding: 12px 14px 10px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.feed h2, .section-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.fbtn { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: transparent; color: var(--soft); font-size: 13px; font-weight: 600; }
.fbtn[aria-pressed="true"] { border-color: var(--accent); background: #1B2A44; color: var(--text); }
.flist { list-style: none; margin: 0; padding: 0; }
.flist li { padding: 12px 14px; border-top: 1px solid #20262F; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.fmeta .chip { padding: 1px 8px; font-size: 11px; }
.ftext { color: var(--text); font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
a.ftext { text-decoration: none; }
a.ftext:hover { text-decoration: underline; color: #B8D0FF; }
.fsrc { font-size: 12px; color: var(--muted); }
.fempty { padding: 16px 14px 18px; border-top: 1px solid #20262F; margin: 0; }
.feed .more { margin: 0 14px 12px; }

.sectors-wrap { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.sectors { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@media (min-width: 640px) { .sectors { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@media (min-width: 980px) { .sectors { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sector { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); min-width: 0; }
.sector.up { background: var(--up-bg); border-color: rgba(61, 214, 140, .25); }
.sector.down { background: var(--down-bg); border-color: rgba(255, 123, 114, .25); }
.sector .shead { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sector .sname { font-size: 15px; font-weight: 600; min-width: 0; }
.sector .metrics { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.sector .ms { display: flex; gap: 12px; }
.sector .k { font-size: 11px; color: var(--muted); }
.sector .v { font-size: 14px; white-space: nowrap; }
.sector .ms { flex: none; }
.sector .metrics svg { flex: 1 1 auto; width: auto; min-width: 40px; max-width: 96px; height: 24px; }
@media (min-width: 400px) { .sector .ms { gap: 16px; } }
#note:empty { display: none; }
.sector .sfoot { font-size: 12px; color: var(--soft); line-height: 1.5; }
.sector .members { font-size: 11px; color: var(--muted); }
