:root {
  color-scheme: dark;
  --panel: rgba(12, 17, 24, .84);
  --panel-strong: rgba(17, 24, 34, .96);
  --border: rgba(255,255,255,.11);
  --text: #f4f7fb;
  --muted: #9ba9b8;
  --accent: #74b7ff;
  --radius: 18px;
  --shadow: 0 18px 45px rgba(0,0,0,.28);
  --shade: .35;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: #081018;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: auto;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

#backgroundLayer, #backgroundVideo, .background-shade { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#backgroundLayer {
  z-index: -3;
  background: radial-gradient(circle at 20% 15%, #1c4366 0, transparent 34%), linear-gradient(140deg, #0a111a, #111827 55%, #07101a);
  background-size: cover; background-position: center;
}
#backgroundVideo { z-index: -4; object-fit: cover; display: none; }
.background-shade { z-index: -2; background: rgba(0,0,0,var(--shade)); }

.topbar {
  min-height: 132px;
  display: grid;
  grid-template-columns: 150px minmax(680px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(5,9,14,.68);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { font-size: 20px; font-weight: 720; letter-spacing: -.02em; }
.location { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.header-weather { display: grid; grid-template-columns: 155px 250px minmax(360px, 1fr); align-items: stretch; gap: 9px; min-width: 0; }
.header-clock, .weather-current, .forecast-head-card {
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.045);
  border-radius: 13px;
}
.header-clock { padding: 11px 13px; display: flex; flex-direction: column; justify-content: center; }
.header-clock strong { font-size: 27px; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.header-clock span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.weather-current { padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.weather-current-main strong, .weather-current-main span { display: block; }
.weather-current-main strong { font-size: 30px; line-height: 1; letter-spacing: -.05em; }
.weather-current-main span { color: var(--muted); font-size: 11px; margin-top: 5px; max-width: 105px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-metrics { display: grid; gap: 3px; font-size: 10px; color: var(--muted); }
.header-metrics b { color: var(--text); font-weight: 650; min-width: 52px; display: inline-block; }
.header-forecast { display: grid; grid-template-columns: repeat(3, minmax(118px, 1fr)); gap: 7px; min-width: 0; }
.forecast-head-card { padding: 8px 9px; min-width: 0; }
.forecast-head-card .forecast-title { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; font-weight: 650; }
.forecast-head-card .forecast-desc { color: var(--muted); font-size: 10px; margin: 3px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.forecast-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 7px; font-size: 9.5px; color: var(--muted); }
.forecast-metrics b { color: var(--text); font-weight: 600; }

.button, .icon-button, .text-button, .tab-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(116,183,255,.16);
  cursor: pointer;
}
.button { border-radius: 10px; padding: 9px 12px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.button.secondary { background: rgba(255,255,255,.06); }
.button:hover, .icon-button:hover, .text-button:hover, .tab-button:hover { border-color: rgba(116,183,255,.55); }
.icon-button { width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; }
.text-button { padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.045); font-size: 11px; }
.full { width: 100%; }

.dashboard { position: relative; min-width: 1200px; min-height: calc(100vh - 132px); height: 1110px; }
.widget {
  position: absolute;
  left: var(--x); top: var(--y); width: var(--w); height: var(--h);
  min-width: 250px; min-height: 160px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(20px); overflow: hidden;
  display: flex; flex-direction: column;
}
.widget.is-moving { opacity: .9; border-color: rgba(116,183,255,.55); }
.widget-head {
  height: 48px; flex: 0 0 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; border-bottom: 1px solid var(--border); user-select: none; font-size: 14px; font-weight: 650;
}
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.widget-meta { color: var(--muted); font-weight: 500; font-size: 12px; }
.widget-body { min-height: 0; flex: 1; padding: 16px; overflow: auto; }
.resize-handle { position: absolute; right: 3px; bottom: 3px; width: 18px; height: 18px; cursor: nwse-resize; }
.resize-handle::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 8px; height: 8px; border-right: 2px solid rgba(255,255,255,.36); border-bottom: 2px solid rgba(255,255,255,.36); }

.module-status { min-height: 17px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.module-status.error { color: #ffb4b4; }

.widget-tabs { display: flex; gap: 4px; }
.tab-button { padding: 4px 8px; font-size: 11px; border-radius: 8px; background: rgba(255,255,255,.04); }
.tab-button.is-active { background: rgba(116,183,255,.2); border-color: rgba(116,183,255,.4); }
.youtube-widget { display: flex; flex-direction: column; gap: 12px; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.search-row input, .chat-compose textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; background: rgba(7,12,18,.72); color: var(--text); outline: 0; padding: 10px 11px;
}
.search-row input:focus, .chat-compose textarea:focus { border-color: rgba(116,183,255,.5); }
.youtube-content { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(250px, .95fr) minmax(220px, 1.05fr); gap: 12px; }
.youtube-player-column, .youtube-results-column { min-height: 0; }
.youtube-results-column { display: flex; flex-direction: column; gap: 8px; }
.youtube-player-shell { position: relative; aspect-ratio: 16 / 9; width: 100%; border-radius: 12px; overflow: hidden; background: #05080c; border: 1px solid rgba(255,255,255,.08); }
#youtubePlayer, #youtubePlayer iframe { width: 100% !important; height: 100% !important; }
.player-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; padding: 20px; }
.player-controls { display: flex; align-items: center; gap: 7px; margin-top: 9px; }
.volume-control { min-width: 0; flex: 1; display: grid; grid-template-columns: auto 1fr auto; gap: 5px; align-items: center; color: var(--muted); font-size: 9px; }
.volume-control input { min-width: 50px; width: 100%; }
.player-open { padding: 6px 9px; font-size: 11px; }
.now-playing { color: var(--muted); font-size: 11px; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.youtube-results { min-height: 0; overflow: auto; display: grid; gap: 7px; align-content: start; padding-right: 2px; }
.youtube-result { display: grid; grid-template-columns: 88px 1fr; gap: 8px; width: 100%; text-align: left; padding: 6px; border: 1px solid rgba(255,255,255,.07); border-radius: 10px; background: rgba(255,255,255,.035); color: var(--text); cursor: pointer; }
.youtube-result:hover { border-color: rgba(116,183,255,.32); background: rgba(116,183,255,.08); }
.youtube-result img { width: 88px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 7px; background: #05080c; }
.youtube-result strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; line-height: 1.3; }
.youtube-result span { display: block; margin-top: 4px; color: var(--muted); font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-widget { display: flex; flex-direction: column; padding-bottom: 10px; }
.chat-messages { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 9px; padding: 2px 2px 10px; }
.chat-empty { margin: auto; color: var(--muted); font-size: 12px; text-align: center; max-width: 270px; line-height: 1.45; }
.chat-message { max-width: 88%; padding: 9px 11px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; font-size: 12px; }
.chat-message.user { align-self: flex-end; background: rgba(116,183,255,.18); border: 1px solid rgba(116,183,255,.22); }
.chat-message.assistant { align-self: flex-start; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.07); }
.chat-compose { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.chat-compose textarea { resize: none; max-height: 110px; line-height: 1.35; }
.chat-compose button { height: 43px; }
.chat-widget .module-status { margin-top: 5px; }

.gw2-widget { padding-top: 12px; }
.gw2-summary { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.07); }
.gw2-summary strong, .gw2-summary span { font-size: 12px; }
.gw2-summary span { color: var(--muted); }
.gw2-gold { font-variant-numeric: tabular-nums; }
.gw2-section { margin-top: 13px; }
.gw2-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 7px; }
.gw2-characters { display: flex; flex-wrap: wrap; gap: 6px; }
.gw2-character { padding: 6px 8px; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.06); border-radius: 8px; font-size: 10px; }
.gw2-character b { display: block; font-size: 11px; margin-bottom: 2px; }
.gw2-daily { display: grid; gap: 6px; }
.gw2-objective { display: grid; grid-template-columns: 18px 1fr auto; gap: 7px; align-items: start; padding: 7px 8px; background: rgba(255,255,255,.035); border-radius: 8px; font-size: 10px; }
.gw2-objective .check { color: var(--accent); }
.gw2-objective small { display: block; color: var(--muted); margin-top: 2px; }
.gw2-permissions { margin-top: 10px; color: var(--muted); font-size: 9.5px; line-height: 1.35; }

.notes-widget { padding: 0; }
.notes-widget textarea { width: 100%; height: 100%; resize: none; border: 0; outline: 0; padding: 16px; background: transparent; color: var(--text); line-height: 1.55; }
.notes-widget textarea::placeholder { color: #718093; }

.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 9px; }
.quick-link { display: flex; flex-direction: column; justify-content: space-between; min-height: 86px; padding: 11px; text-decoration: none; color: var(--text); background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); border-radius: 12px; }
.quick-link:hover { background: rgba(116,183,255,.12); border-color: rgba(116,183,255,.3); }
.quick-link span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal { border: 0; padding: 0; background: transparent; color: var(--text); }
.modal::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(5px); }
.modal-card { width: min(520px, calc(100vw - 32px)); background: var(--panel-strong); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-card label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; margin: 13px 0; }
.modal-card input, .modal-card select { width: 100%; background: #0c131d; border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 10px; outline: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.links-editor { display: grid; gap: 9px; max-height: 380px; overflow: auto; margin-bottom: 10px; }
.link-row { display: grid; grid-template-columns: .8fr 1.7fr 34px; gap: 7px; }
.link-row button { width: 34px; }

@media (max-width: 1080px) {
  .topbar { position: relative; grid-template-columns: 1fr auto; }
  .header-weather { grid-column: 1 / -1; grid-row: 2; grid-template-columns: 155px 250px minmax(360px, 1fr); overflow-x: auto; padding-bottom: 2px; }
  .dashboard { min-height: 0; }
}

@media (max-width: 899px) {
  body { overflow-x: hidden; }
  .topbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; padding: 12px; }
  .header-brand { flex: 1; }
  .topbar-actions { flex-direction: row; }
  .topbar-actions .button { padding: 7px 9px; font-size: 11px; }
  .header-weather { order: 3; width: 100%; display: flex; overflow-x: auto; gap: 7px; }
  .header-clock { flex: 0 0 145px; }
  .weather-current { flex: 0 0 235px; }
  .header-forecast { display: flex; flex: 0 0 auto; }
  .forecast-head-card { width: 125px; }
  .dashboard { min-width: 0; height: auto !important; padding: 14px; display: grid; gap: 14px; }
  .widget { position: relative; left: auto !important; top: auto !important; width: auto !important; height: auto !important; min-height: 360px; }
  .widget[data-widget="youtube"] { min-height: 620px; }
  .widget[data-widget="chat"] { min-height: 520px; }
  .widget[data-widget="gw2"] { min-height: 470px; }
  .widget[data-widget="notes"] { min-height: 380px; }
  .drag-handle { cursor: default; }
  .resize-handle { display: none; }
  .youtube-content { grid-template-columns: 1fr; }
  .youtube-results-column { min-height: 260px; }
}
