:root, [data-theme="dark"] {
  --bg: #141414; --fg: #EDEDED; --muted: #8C8C8C; --subtle: #6F6F6F; --icon: #BDBDBD;
  --line: #1F1F1F; --line2: #2A2A2A; --chip: #262626; --panel: #181818; --input: #111111;
  --thumb: #262626; --toastbg: #FFFFFF; --toastfg: #111111;
  --navbg: #3A0E16; --navfg: #FF4D6A; --area: rgba(255,255,255,0.06);
  --red: #FF0033; --overlay: rgba(0,0,0,0.6);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #FFFFFF; --fg: #0F0F0F; --muted: #606060; --subtle: #767676; --icon: #3F3F3F;
  --line: #E5E5E5; --line2: #DADADA; --chip: #F2F2F2; --panel: #FFFFFF; --input: #F8F8F8;
  --thumb: #E8E8E8; --toastbg: #0F0F0F; --toastfg: #FFFFFF;
  --navbg: #FFE6EB; --navfg: #E6002E; --area: rgba(0,0,0,0.05);
  --overlay: rgba(0,0,0,0.6);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: 'Geist', system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--fg); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.rail { flex: 0 0 68px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 0; background: var(--bg); z-index: 5; }
.rail .logo { width: 36px; height: 36px; border-radius: 10px; margin-bottom: 14px; display: block; }
.rail .spacer { flex: 1; }
.navbtn { position: relative; width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.navbtn:hover { color: var(--fg); background: var(--chip); }
.navbtn.on { background: var(--navbg); color: var(--navfg); }
.navbtn .dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 99px; background: var(--red); }
.navbtn img { width: 28px; height: 28px; border-radius: 99px; }
main { flex: 1; min-width: 0; padding: 36px 48px 96px; }
.wrap { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 32px; }

/* top bar */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.pills { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.pill { border: 0; border-radius: 99px; padding: 9px 16px; min-height: 40px; font-size: 15px; background: transparent; color: var(--muted); white-space: nowrap; }
.pill:hover { color: var(--fg); }
.pill.on { background: var(--chip); color: var(--fg); }
.tools { display: flex; align-items: center; gap: 4px; }
.iconbtn { width: 42px; height: 42px; border-radius: 99px; border: 0; background: transparent; color: var(--icon); display: inline-flex; align-items: center; justify-content: center; }
.iconbtn:hover { background: var(--chip); color: var(--fg); }
.iconbtn.sm { width: 34px; height: 34px; }
.ghost { height: 42px; border-radius: 99px; border: 1px solid var(--line2); background: transparent; color: var(--fg); padding: 0 16px; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.ghost:hover { background: var(--chip); }
.primary { height: 42px; border-radius: 99px; border: 0; background: var(--red); color: #FFFFFF; padding: 0 20px; font-size: 15px; font-weight: 500; white-space: nowrap; }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .6; cursor: default; }
.danger { height: 40px; border-radius: 99px; border: 1px solid var(--red); background: transparent; color: var(--red); padding: 0 16px; font-size: 14px; }
.seg { display: flex; gap: 2px; margin-right: 6px; }
.seg button { width: 34px; height: 34px; border-radius: 99px; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--chip); color: var(--fg); }

/* menus */
.menuwrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 6px; min-width: 220px; z-index: 20; box-shadow: 0 12px 32px rgba(0,0,0,.25); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 9px; font-size: 14px; }
.menu button:hover { background: var(--chip); }

/* overview */
.overview { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 28px; }
.ov-left { display: flex; flex-direction: column; gap: 6px; }
.scope { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
.chipbtn { display: inline-flex; align-items: center; gap: 6px; background: var(--chip); border: 0; border-radius: 99px; color: var(--fg); padding: 5px 12px; font-size: 14px; }
.big { font-size: 56px; font-weight: 600; letter-spacing: -0.035em; line-height: 1.1; color: var(--red); }
.sub { font-size: 15px; color: var(--muted); }
.sub b { color: var(--fg); font-weight: 500; }
.chart { margin: 0; flex: 1 1 380px; max-width: 620px; display: flex; flex-direction: column; gap: 8px; }
.chart svg { width: 100%; height: 120px; display: block; }
.chart figcaption { display: flex; justify-content: space-between; font-size: 12px; color: var(--subtle); }
.chart .empty { height: 120px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line2); border-radius: 14px; font-size: 13px; color: var(--muted); text-align: center; padding: 0 20px; }

/* tooltips */
.tip { position: relative; display: inline-flex; }
.tipbox { position: absolute; top: calc(100% + 8px); left: 0; width: 260px; background: var(--chip); color: var(--fg); font-size: 13px; line-height: 1.45; padding: 10px 12px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 15; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.tip:hover .tipbox, .tip:focus-within .tipbox { opacity: 1; }
.divider { width: 1px; height: 20px; background: var(--line2); margin: 0 12px; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 230px), 1fr)); gap: 32px 18px; }
.card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; background: var(--thumb); overflow: hidden; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; top: 8px; left: 8px; padding: 4px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.savebtn { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 99px; border: 0; background: var(--overlay); color: #FFFFFF; display: flex; align-items: center; justify-content: center; }
.dur { position: absolute; right: 8px; bottom: 8px; background: var(--overlay); color: #FFFFFF; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.acts { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.card:hover .acts, .card:focus-within .acts { opacity: 1; }
.acts button, .acts select { height: 30px; border-radius: 99px; border: 0; background: rgba(0,0,0,0.72); color: #FFFFFF; padding: 0 12px; font-size: 12px; }
.meta { display: flex; flex-direction: column; gap: 4px; padding: 0 2px; min-width: 0; }
.title { font-size: 15px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line b { color: var(--fg); font-weight: 500; }
@media (hover: none) { .acts { opacity: 1; } }

.note { font-size: 15px; color: var(--muted); padding: 48px 0; text-align: center; line-height: 1.6; }
.note .primary { margin-top: 16px; }
.skeleton .thumb { animation: pulse 1.2s ease-in-out infinite; }
.skeleton .line, .skeleton .title { height: 14px; background: var(--chip); border-radius: 6px; color: transparent; }
@keyframes pulse { 50% { opacity: .55; } }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--panel); border-left: 1px solid var(--line2); padding: 28px 24px; display: flex; flex-direction: column; gap: 22px; overflow-y: auto; z-index: 31; }
.drawer h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 99px; background: var(--chip); object-fit: cover; display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--icon); }
.grow { flex: 1; min-width: 0; }
.name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.small { font-size: 13px; color: var(--muted); margin-top: 2px; }
.field { flex: 1; min-width: 0; height: 44px; background: var(--input); border: 1px solid var(--line2); border-radius: 99px; color: var(--fg); padding: 0 16px; font-size: 14px; outline: none; }
.field:focus { border-color: var(--muted); }
select.field { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; }
.outline-sm { height: 34px; border-radius: 99px; border: 1px solid var(--line2); background: transparent; color: var(--icon); padding: 0 14px; font-size: 13px; }

/* search */
.searchbox { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; }
.searchbox .inner { max-width: 1240px; margin: 0 auto; padding: 28px 48px 80px; display: flex; flex-direction: column; gap: 28px; }
.searchbar { display: flex; gap: 10px; align-items: center; }
.searchbar input { flex: 1; height: 52px; font-size: 17px; }
h3 { margin: 0; font-size: 15px; font-weight: 500; color: var(--muted); }

/* settings */
.settings { max-width: 720px; display: flex; flex-direction: column; gap: 28px; }
.settings h1 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -0.02em; }
.section { border: 1px solid var(--line2); border-radius: 18px; padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.section h2 { margin: 0; font-size: 16px; font-weight: 600; }
.setrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.setrow .label { font-size: 15px; }
.setrow .hint { font-size: 13px; color: var(--muted); margin-top: 3px; max-width: 420px; line-height: 1.45; }
.toggle { position: relative; width: 46px; height: 28px; border-radius: 99px; border: 0; background: var(--line2); }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 99px; background: #FFFFFF; transition: left .15s; }
.toggle.on { background: var(--red); }
.toggle.on::after { left: 21px; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .box { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.login img { width: 64px; height: 64px; border-radius: 16px; }
.login h1 { margin: 0; font-size: 32px; font-weight: 600; letter-spacing: -0.02em; }
.login p { margin: 0; color: var(--muted); line-height: 1.5; }
.gbtn { height: 48px; border-radius: 99px; border: 1px solid var(--line2); background: var(--fg); color: var(--bg); padding: 0 22px; font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; gap: 10px; }

#toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px); background: var(--toastbg); color: var(--toastfg); padding: 12px 20px; border-radius: 99px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* alerts */
.alertrow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.notif { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: center; }
.notif img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: var(--thumb); }
.notif .msg { font-size: 15px; line-height: 1.45; }
.notif.unread .msg { font-weight: 500; }

@media (max-width: 720px) {
  .shell { flex-direction: column-reverse; }
  .rail { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: 64px; flex-direction: row; justify-content: space-around; padding: 0 8px; border-right: 0; border-top: 1px solid var(--line); }
  .rail .logo, .rail .spacer { display: none; }
  main { padding: 24px 16px 96px; }
  .big { font-size: 42px; }
  .searchbox .inner { padding: 20px 16px 80px; }
  .seg { display: none; }
}
.thumb > a { display: block; width: 100%; height: 100%; }
.topsearch { display: flex; align-items: center; gap: 10px; height: 42px; width: 300px; max-width: 46vw; padding: 0 16px; border-radius: 99px; background: var(--chip); color: var(--muted); cursor: text; }
.topsearch input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 14px; color: var(--fg); cursor: text; }
.topsearch input::placeholder { color: var(--muted); }
.tools .primary { margin-left: 10px !important; }
.topsearch .clearq { width: 26px; height: 26px; border: 0; border-radius: 99px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.topsearch .clearq:hover { color: var(--fg); background: var(--line2); }
.topsearch:focus-within { outline: 1px solid var(--line2); }
.searchresults { display: flex; flex-direction: column; gap: 28px; }

/* phones */
@media (max-width: 720px) {
  .rail { z-index: 25; padding: 0 4px; padding-bottom: env(safe-area-inset-bottom); height: calc(64px + env(safe-area-inset-bottom)); }
  .navbtn { width: 44px; height: 44px; }
  main { padding: 16px 14px 104px; }
  .wrap { gap: 22px; }
  .topbar { gap: 12px; }
  .tools { order: 1; width: 100%; gap: 8px; }
  .topsearch { flex: 1; width: auto; max-width: none; }
  .tools .primary { margin-left: 0 !important; padding: 0 16px; font-size: 14px; }
  .topbar > .pills { order: 2; width: 100%; }
  .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .pills::-webkit-scrollbar { display: none; }
  .pill { padding: 8px 14px; font-size: 14px; flex: 0 0 auto; }
  .tipbox { display: none; }
  .overview { gap: 16px; }
  .big { font-size: 40px; }
  .sub { font-size: 14px; line-height: 1.45; }
  .chart { flex-basis: 100%; }
  .chart svg { height: 90px; }
  .grid { grid-template-columns: 1fr; gap: 24px; }
  .title { font-size: 15px; }
  .drawer { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .settings h1 { font-size: 26px; }
  .section { padding: 16px; }
  .notif img { width: 96px; }
  #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (min-width: 721px) and (max-width: 1024px) {
  main { padding: 28px 28px 80px; }
}
