:root {
  --canvas: #040914;
  --panel: rgba(10, 21, 39, .72);
  --panel-strong: rgba(9, 18, 34, .88);
  --panel-soft: rgba(15, 31, 56, .56);
  --line: rgba(171, 204, 244, .15);
  --line-strong: rgba(169, 207, 255, .32);
  --text: #edf5ff;
  --muted: #91a6c4;
  --quiet: #6f86a6;
  --blue: #3d83ff;
  --blue-soft: rgba(61, 131, 255, .18);
  --green: #4cdda0;
  --danger: #ff6177;
  --shadow: 0 28px 70px rgba(0, 0, 0, .32);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; color: var(--text); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .46; }
.hidden { display: none !important; }
.muted { color: var(--muted); line-height: 1.65; }
.small { font-size: .82rem; }
.eyebrow { margin: 0 0 .42rem; color: #82b0ec; font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #050b17 url('/assets/aurora-night-v2.png') center / cover fixed;
}
.login-card {
  width: min(420px, 100%);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 26px;
  text-align: center;
  background: rgba(7, 16, 30, .84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.brand-mark {
  display: inline-grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid rgba(156, 203, 255, .54);
  border-radius: 18px;
  color: #fff;
  background: rgba(49, 112, 230, .82);
  box-shadow: 0 14px 34px rgba(22, 83, 190, .32);
}
.brand-mark svg { width: 28px; }
.login-card h1 { margin: 14px 0 8px; font-size: 2rem; letter-spacing: .04em; }
.form-stack { display: grid; gap: 14px; margin-top: 28px; text-align: left; }
.form-stack label, .settings-panel label { display: grid; gap: 7px; color: #dce9fa; font-size: .87rem; font-weight: 700; }
.form-stack input, .settings-panel input:not([type=range]), .settings-panel select, .device-picker select, .dialog-fields input, .dialog-fields select, .dialog-fields textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: rgba(2, 10, 21, .62);
}
.dialog-fields textarea { min-height: 84px; padding-top: 10px; resize: vertical; }
.form-stack input:focus, .settings-panel input:focus, .settings-panel select:focus, .dialog-fields input:focus, .dialog-fields select:focus, .dialog-fields textarea:focus { border-color: #75aaff; box-shadow: 0 0 0 3px rgba(82, 144, 255, .14); }
.login-tip { margin: 23px 0 0; color: #7791b6; font-size: .78rem; }

/* Shared controls */
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button svg, .nav-item svg, .quick-action svg, .summary-card > svg, .settings-panel h4 svg, .subnav-item svg { width: 18px; height: 18px; }
.primary { color: #fff; border-color: rgba(112, 170, 255, .75); background: #2369df; box-shadow: 0 10px 24px rgba(17, 81, 196, .28); }
.secondary { color: #cfe0f7; border-color: var(--line-strong); background: rgba(10, 25, 47, .58); }
.quiet { color: #adcaef; border-color: var(--line); background: rgba(6, 16, 31, .42); }
.danger { color: #fff; border-color: rgba(255, 134, 149, .58); background: #b83e55; }
.text-button, .mini-link { padding: 0; border: 0; color: #8ebaff; background: none; font-weight: 800; }
.icon-button { display: grid; width: 41px; height: 41px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: #c3d8f4; background: rgba(6, 17, 33, .6); }
.icon-button svg { width: 19px; }

/* App frame */
.app-shell { position: relative; display: flex; min-height: 100vh; overflow: hidden; background: var(--canvas); }
.aurora-backdrop { position: fixed; z-index: 0; inset: 0; pointer-events: none; background: #050b17 url('/assets/aurora-night-v2.png') center / cover; opacity: .72; }
.aurora-backdrop::after { position: absolute; inset: 0; content: ''; background: rgba(3, 9, 18, .48); }
.sidebar {
  position: fixed;
  z-index: 3;
  display: flex;
  width: 88px;
  height: 100vh;
  flex-direction: column;
  align-items: center;
  padding: 22px 12px;
  border-right: 1px solid var(--line);
  background: rgba(3, 10, 20, .62);
  backdrop-filter: blur(18px);
}
.brand { display: grid; place-items: center; padding: 0; }
.brand > span:not(.brand-mark), .brand b { display: none; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 14px; }
.brand-mark.small svg { width: 22px; }
.nav-list { display: grid; width: 100%; gap: 12px; margin-top: 58px; }
.nav-item { display: grid; width: 100%; min-height: 56px; place-items: center; gap: 5px; padding: 9px 4px; border: 1px solid transparent; border-radius: 13px; color: #8fa6c7; background: transparent; font-size: .68rem; font-weight: 800; }
.nav-item:hover { color: #eaf3ff; border-color: rgba(147, 194, 255, .16); background: rgba(26, 61, 105, .28); }
.nav-item.active { color: #fff; border-color: rgba(117, 177, 255, .5); background: rgba(39, 103, 221, .72); box-shadow: 0 10px 25px rgba(0, 0, 0, .22); }
.nav-item svg { width: 20px; height: 20px; }
.sidebar-footer { display: grid; width: 100%; margin-top: auto; justify-items: center; color: #95add0; font-size: .72rem; }
.sidebar-footer p { display: grid; margin: 0; justify-items: center; gap: 6px; text-align: center; }
.sidebar-footer .text-button { display: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6e829f; }
.dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(76, 221, 160, .11); }

.content-shell { position: relative; z-index: 1; width: calc(100% - 88px); margin-left: 88px; padding: 26px clamp(28px, 4vw, 70px) 68px; }
.topbar { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.top-title h2 { margin: 0; font-size: 1.62rem; letter-spacing: .03em; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.device-picker { display: flex; min-width: 212px; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; color: #91b9f0; background: rgba(7, 18, 35, .68); backdrop-filter: blur(10px); }
.device-picker svg { width: 17px; }
.device-picker select { min-height: 39px; padding: 0; border: 0; color: #e7f1ff; background: transparent; }
.device-picker option { color: #101b2f; }
.tab-page { display: none; animation: reveal .28s ease; }
.tab-page.active { display: block; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Home: one immersive control surface */
.home-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .68fr); min-height: 510px; gap: clamp(20px, 4vw, 66px); align-items: center; }
.hero-stage { position: relative; min-height: 500px; overflow: hidden; border: 1px solid rgba(175, 217, 255, .1); border-radius: 28px; background: rgba(4, 12, 24, .28); box-shadow: var(--shadow); }
.hero-clock-photo { position: absolute; width: min(86%, 560px); height: 124%; right: 5%; bottom: -30%; object-fit: contain; opacity: .8; }
.round-preview { position: absolute; top: 48%; right: 24%; display: block; width: min(40%, 250px); aspect-ratio: 1; overflow: hidden; border: 3px solid rgba(123, 180, 255, .7); border-radius: 50%; color: #fff; background: rgba(2, 7, 15, .92); box-shadow: 0 0 0 13px rgba(3, 10, 20, .64), 0 25px 55px rgba(0, 0, 0, .42); }
.preview-noise, .preview-orb { display: none; }
.preview-content { position: relative; z-index: 1; display: flex; height: 100%; align-items: center; flex-direction: column; padding: 17% 8% 12%; text-align: center; }
.preview-content p { margin: 0; color: #9ac2ff; font-size: .68rem; font-weight: 800; }
.preview-content strong { margin-top: 12%; color: #f4f8ff; font-size: clamp(2.3rem, 4vw, 4.4rem); font-weight: 500; letter-spacing: -.08em; line-height: 1; }
.preview-content > span:not(#previewWeather) { margin-top: 10px; color: #c1d6ef; font-size: .72rem; }
.preview-content #previewWeather { display: flex; align-items: center; gap: 5px; margin-top: auto; color: #dcecff; font-size: .68rem; }
.preview-content #previewWeather svg { width: 15px; }
.preview-content em { margin-top: 8px; color: #8da5c7; font-size: .64rem; font-style: normal; }
.round-preview.theme-paper { border-color: rgba(232, 184, 121, .76); background: rgba(45, 31, 20, .92); }
.round-preview.theme-paper .preview-content, .round-preview.theme-paper .preview-content p, .round-preview.theme-paper .preview-content > span:not(#previewWeather), .round-preview.theme-paper .preview-content #previewWeather, .round-preview.theme-paper .preview-content em { color: #f7e6cf; }
.round-preview.theme-playful { border-color: rgba(87, 220, 227, .74); background: rgba(6, 56, 70, .92); }

.surface { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 10px 32px rgba(0, 0, 0, .12); backdrop-filter: blur(16px); }
.overview-card { display: grid; align-content: start; min-height: 396px; gap: 18px; padding: 23px; background: var(--panel-strong); }
.surface-header, .section-heading, .content-toolbar, .maintenance-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.surface-header h3, .section-heading h3 { margin: .1rem 0 0; font-size: 1.28rem; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: #b5c9e4; background: rgba(39, 67, 101, .32); font-size: .76rem; font-weight: 800; white-space: nowrap; }
.overview-info { display: grid; grid-template-columns: 1fr; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--line); }
.overview-info div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; background: rgba(9, 22, 41, .86); }
.overview-info span { color: var(--quiet); font-size: .74rem; }
.overview-info b { max-width: 65%; overflow: hidden; color: #d9e7f8; font-size: .82rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-action { display: grid; min-height: 78px; place-items: center; gap: 7px; padding: 10px 5px; border: 1px solid var(--line); border-radius: 12px; color: #bdcef2; background: rgba(12, 31, 58, .54); font-size: .72rem; font-weight: 800; text-align: center; }
.quick-action:hover { border-color: rgba(107, 167, 255, .58); color: #fff; background: rgba(35, 89, 168, .36); }
.quick-action svg { color: #7caef7; }

.section-block { margin-top: 22px; padding: 18px; border: 1px solid var(--line); border-radius: 21px; background: rgba(5, 14, 28, .64); backdrop-filter: blur(16px); }
.section-heading { align-items: center; margin-bottom: 15px; }
.section-heading h3 { font-size: 1.08rem; }
.dock-heading-actions { display: flex; gap: 8px; }
.scene-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.scene-card { display: grid; min-height: 86px; place-items: center; gap: 7px; padding: 10px 6px; border: 1px solid transparent; border-radius: 13px; color: #aebfd8; background: rgba(21, 44, 78, .5); text-align: center; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.scene-card:hover { transform: translateY(-1px); border-color: rgba(132, 184, 255, .4); color: #fff; }
.scene-card h4 { margin: 0; font-size: .85rem; }
.scene-card p { display: none; }
.scene-card svg { width: 22px; height: 22px; color: #92bbff; }
.scene-card.active { border-color: rgba(121, 181, 255, .86); color: #fff; background: rgba(36, 103, 215, .7); box-shadow: inset 0 0 0 1px rgba(207, 232, 255, .18); }
.scene-card[data-scene="morning"] svg { color: #ffd07a; }
.scene-card[data-scene="focus"] svg { color: #8fc7ff; }
.scene-card[data-scene="rest"] svg { color: #c9a8ff; }
.scene-card[data-scene="album"] svg { color: #78e1d6; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.summary-card { display: flex; min-width: 0; align-items: center; gap: 12px; padding: 15px; }
.summary-card > svg { flex: 0 0 auto; color: #84b6ff; }
.summary-card div { min-width: 0; flex: 1; }
.summary-card span, .summary-card small { display: block; overflow: hidden; color: var(--quiet); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.summary-card strong { display: block; margin: 3px 0; color: #f1f7ff; font-size: 1rem; }

/* Content and settings, intentionally quieter than the home screen */
.subnav { display: flex; gap: 6px; margin: 12px 0 18px; padding: 5px; border: 1px solid var(--line); border-radius: 13px; background: rgba(7, 18, 35, .58); width: fit-content; }
.subnav-item { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border: 1px solid transparent; border-radius: 9px; color: #91a7c6; background: transparent; font-size: .82rem; font-weight: 800; }
.subnav-item.active { border-color: rgba(117, 177, 255, .46); color: #fff; background: rgba(44, 101, 204, .56); }
.content-panel { display: none; }
.content-panel.active { display: block; }
.content-toolbar { padding: 20px; margin-bottom: 13px; }
.content-toolbar h4 { margin: 0 0 5px; }
.content-toolbar p { max-width: 620px; margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.toolbar-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.compact-select { display: inline-flex; align-items: center; gap: 7px; color: #a9bfdd; font-size: .77rem; font-weight: 800; }
.compact-select select, .album-config select { min-height: 38px; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; color: #e8f2ff; background: rgba(4, 15, 29, .72); }
.album-config { display: grid; gap: 16px; padding: 20px; margin-bottom: 13px; }
.album-config h4 { margin: 2px 0 0; }
.album-config-grid { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)) auto auto; align-items: end; gap: 11px; }
.album-config-grid label { display: grid; gap: 7px; color: #c6d7ef; font-size: .78rem; font-weight: 800; }
.upload-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.media-list, .schedule-list { display: grid; gap: 9px; }
.media-row, .schedule-row { display: flex; align-items: center; gap: 14px; padding: 14px 17px; }
.media-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 12px; color: #91bcff; background: rgba(42, 83, 142, .28); }
.media-icon.photo { overflow: hidden; background: #132a44; }
.media-icon.photo img { width: 100%; height: 100%; object-fit: cover; }
.media-text { min-width: 0; flex: 1; }
.media-text b, .media-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-text b { color: #e8f2ff; }
.media-text span { margin-top: 4px; color: var(--quiet); font-size: .77rem; }
.row-actions { display: flex; gap: 7px; }
.row-actions button { display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: #a8c7f3; background: rgba(7, 20, 39, .64); }
.row-actions button.danger-icon { color: #ff9baa; }
.schedule-row .schedule-time { display: grid; width: 54px; height: 54px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(116, 178, 255, .23); border-radius: 13px; color: #a8caff; background: rgba(31, 76, 143, .3); font-size: .83rem; font-weight: 900; }
.schedule-row.priority-high .schedule-time { border-color: rgba(255, 132, 151, .28); color: #ffb2bd; background: rgba(135, 37, 56, .28); }
.schedule-badges { display: flex; gap: 6px; margin-top: 5px; }
.schedule-badges span { padding: 2px 6px; border: 1px solid var(--line); border-radius: 999px; color: #a7bddb; background: rgba(43, 69, 103, .28); font-size: .67rem; }
.device-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-panel { display: grid; align-content: start; gap: 16px; padding: 21px; }
.settings-panel h4 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1rem; }
.settings-panel h4 svg { color: #89b8ff; }
.settings-panel output { float: right; color: #9fc4ff; }
.settings-panel input[type=range] { width: 100%; accent-color: #4b91ff; }
.check-row { display: flex !important; align-items: center; gap: 8px; }
.check-row input { width: 16px; height: 16px; accent-color: #4b91ff; }
.wide { grid-column: 1 / -1; }
.cache-slots { display: grid; gap: 8px; }
.cache-slot { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; color: #b7cae5; background: rgba(10, 26, 48, .55); font-size: .78rem; }
.cache-slot i { display: grid; width: 21px; height: 21px; place-items: center; border-radius: 6px; color: #c7ddff; background: rgba(54, 120, 222, .36); font-size: .68rem; font-style: normal; }
.cache-slot span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cache-slot button { margin-left: auto; padding: 4px 7px; border: 1px solid rgba(255, 126, 145, .3); border-radius: 6px; color: #ffb7c1; background: rgba(143, 36, 58, .26); font-size: .7rem; }
.maintenance-row { align-items: center; padding-top: 4px; }
.maintenance-row div { margin-right: auto; }
.maintenance-row span, .maintenance-row b { display: block; }
.maintenance-row span { color: var(--quiet); font-size: .76rem; }
.maintenance-row b { margin-top: 3px; color: #e7f1ff; }

/* Dialogs and feedback */
.form-dialog { width: min(470px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: #0b1729; box-shadow: var(--shadow); }
.form-dialog::backdrop { background: rgba(1, 6, 14, .7); backdrop-filter: blur(5px); }
.form-dialog form { padding: 23px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dialog-head h3 { margin: 0; }
.dialog-fields { display: grid; gap: 13px; margin-top: 21px; }
.dialog-fields label { display: grid; gap: 6px; color: #d7e5f7; font-size: .84rem; font-weight: 800; }
.dialog-error { min-height: 1.1em; margin: 13px 0 0; color: #ff8c9e; font-size: .82rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 14px; }
.toast { position: fixed; z-index: 10; right: 22px; bottom: 22px; max-width: min(360px, calc(100vw - 44px)); padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 11px; transform: translateY(18px); opacity: 0; color: #eff7ff; background: #102440; box-shadow: var(--shadow); pointer-events: none; transition: .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(255, 132, 151, .55); background: #74263b; }

@media (max-width: 1080px) {
  .home-layout { grid-template-columns: minmax(0, 1.25fr) minmax(260px, .72fr); gap: 24px; }
  .hero-stage { min-height: 460px; }
  .round-preview { top: 48%; right: 22%; }
}
@media (max-width: 850px) {
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 70px; flex-direction: row; padding: 8px 12px; border-top: 1px solid var(--line); border-right: 0; }
  .brand, .sidebar-footer { display: none; }
  .nav-list { display: flex; justify-content: space-around; width: 100%; gap: 4px; margin: 0; }
  .nav-item { min-height: 51px; max-width: 100px; }
  .content-shell { width: 100%; margin: 0; padding: 22px 18px 98px; }
  .home-layout { grid-template-columns: 1fr; }
  .hero-stage { min-height: 480px; max-width: 700px; width: 100%; margin: auto; }
  .overview-card { grid-template-columns: 1fr 1fr; min-height: 0; }
  .overview-card .surface-header, .overview-card .quick-actions { grid-column: 1 / -1; }
  .scene-grid { grid-template-columns: repeat(5, minmax(94px, 1fr)); overflow-x: auto; padding-bottom: 2px; }
  .scene-card { min-width: 94px; }
  .device-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
}
@media (max-width: 590px) {
  .content-shell { padding: 17px 14px 94px; }
  .topbar { align-items: flex-start; }
  .top-title .eyebrow { display: none; }
  .top-title h2 { font-size: 1.42rem; }
  .top-actions { max-width: 62%; flex-wrap: wrap; justify-content: flex-end; }
  .device-picker { min-width: 0; width: 100%; }
  .top-bind { min-height: 39px; padding: 0 10px; font-size: .75rem; }
  .hero-stage { min-height: 420px; border-radius: 22px; }
  .hero-clock-photo { width: 100%; height: 124%; right: 0; bottom: -31%; }
  .round-preview { top: 49%; right: 25%; width: 46%; border-width: 2px; box-shadow: 0 0 0 8px rgba(3, 10, 20, .64), 0 18px 35px rgba(0, 0, 0, .38); }
  .preview-content strong { font-size: clamp(2rem, 11vw, 3.4rem); }
  .preview-content > span:not(#previewWeather), .preview-content #previewWeather, .preview-content em { font-size: .58rem; }
  .overview-card { grid-template-columns: 1fr; padding: 17px; }
  .overview-info { grid-column: auto; }
  .quick-actions { grid-column: auto; }
  .section-block { padding: 15px; border-radius: 17px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .dock-heading-actions { width: 100%; }
  .dock-heading-actions .button { flex: 1; padding: 0 10px; font-size: .78rem; }
  .summary-grid { grid-template-columns: 1fr; }
  .content-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .album-config-grid { grid-template-columns: 1fr; }
  .media-row, .schedule-row { align-items: flex-start; padding: 13px; }
  .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .maintenance-row { align-items: flex-start; flex-wrap: wrap; }
  .maintenance-row div { width: 100%; }
}
