:root {
  --primary: #14532d;
  --on-primary: #ffffff;
  --outline: #CBD5E1;
  --surface: #FFFFFF;
  --surface-1: #F6F7F9;
  --surface-2: #EEF2F6;
  --surface-3: #E7ECF2;
  --text: #0F172A;
  --text-muted: #475569;
  --radius: 16px;
  --r-sm: 12px;
  --gap: 14px;
  --pad: 18px;
  --pad-lg: 22px;
  --dock: 52px;
  --fs-root: 17px;
  --tile-h: 120px;
  --elev-1: 0 2px 4px rgba(0, 0, 0, .06), 0 6px 12px rgba(0, 0, 0, .08);
  --elev-2: 0 4px 8px rgba(0, 0, 0, .07), 0 14px 24px rgba(0, 0, 0, .12);
  --elev-3: 0 8px 18px rgba(0, 0, 0, .12), 0 22px 32px rgba(0, 0, 0, .18);
  --state-hover: rgba(20, 83, 45, .08);
  --state-press: rgba(20, 83, 45, .14);
  --ctrl-bg: #ffffff;
  --ctrl-border: #CBD5E1;
  --ctrl-color: #0F172A;
  --bg: #F6F7F9;
  --ambient: transparent;
}

html.dark {
  --primary: #90D7B0;
  --on-primary: #062414;
  --outline: #30405a;
  --surface: #0f1522;
  --surface-1: #0B1220;
  --surface-2: #141c2b;
  --surface-3: #172235;
  --text: #F1F5F9;
  --text-muted: #B6C2D6;
  --state-hover: rgba(144, 215, 176, .14);
  --state-press: rgba(144, 215, 176, .22);
  --bg: #0B1220;
  --ctrl-bg: #1b2436;
  --ctrl-border: #334766;
  --ctrl-color: #F1F5F9;
}

html {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: var(--fs-root);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 76px 16px;
}

.grid {
  display: grid;
  gap: var(--gap);
}

.grid-12 {
  grid-template-columns: repeat(12, 1fr);
}

.col-4 {
  grid-column: span 4;
}

.col-8 {
  grid-column: span 8;
}

@media (max-width: 900px) {
  .grid-12 {
    grid-template-columns: 1fr;
  }
  .col-4,
  .col-8 {
    grid-column: auto;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--elev-1);
  padding: var(--pad-lg);
}

.card.small {
  padding: var(--pad);
}

.card:hover {
  box-shadow: var(--elev-2);
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.h-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-block;
}

.icon.big {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.ctrl svg {
  width: 20px;
  height: 20px;
}

.short .icon {
  width: 22px;
  height: 22px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  height: var(--tile-h);
  background: var(--surface-2);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--elev-1);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}

.tile:hover {
  background: var(--state-hover);
  border-color: var(--primary);
  box-shadow: var(--elev-2);
}

.tile:active {
  background: var(--state-press);
}

.tile .t-title {
  font-weight: 700;
}

.tile .t-sub {
  color: var(--text-muted);
  font-size: .95rem;
}

.profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile .avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--outline);
}

.profile .title {
  font-weight: 800;
  font-size: 1.6rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag {
  padding: 6px 10px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: .9rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.btn:hover {
  background: var(--state-hover);
  border-color: var(--primary);
  box-shadow: var(--elev-2);
}

.btn:active {
  background: var(--state-press);
}

.dock {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: calc(var(--gap)*2);
}

.short {
  width: var(--dock);
  height: var(--dock);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--elev-1);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.short:hover {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  box-shadow: var(--elev-2);
}

.short:active {
  filter: saturate(1.1);
}

.projects {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  margin-top: calc(var(--gap)*2);
}

@media (max-width: 900px) {
  .projects {
    grid-template-columns: 1fr 1fr;
  }
}

.pcard {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--elev-1);
  padding: var(--pad);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}

.pcard:hover {
  border-color: var(--primary);
  box-shadow: var(--elev-2);
}

.pname {
  font-weight: 700;
}

.pdesc {
  color: var(--text-muted);
  font-size: .95rem;
}

.controls {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 40;
}

.ctrl {
  padding: 8px 10px;
  border: 1px solid var(--ctrl-border);
  background: var(--ctrl-bg);
  color: var(--ctrl-color);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--elev-1);
}

.ctrl[aria-pressed="true"] {
  outline: 2px solid var(--primary);
}

.ctrl:hover {
  background: var(--state-hover);
  border-color: var(--primary);
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal .box {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--elev-3);
  padding: var(--pad-lg);
  max-width: 760px;
  width: 100%;
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.feed {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 420px;
  max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--outline);
  box-shadow: var(--elev-3);
  transform: translateX(100%);
  transition: transform .18s ease;
  z-index: 45;
  display: flex;
  flex-direction: column;
}

.feed.open {
  transform: translateX(0);
}

.feed header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--outline);
}

.segments {
  display: flex;
  gap: 8px;
  padding: 10px var(--pad) 0;
}

.seg {
  padding: 8px 10px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}

.seg[aria-pressed="true"] {
  background: var(--state-hover);
  border-color: var(--primary);
}

.feed-list {
  padding: 8px var(--pad) 16px;
  overflow: auto;
}

.feed-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--outline);
}

.feed-item:last-child {
  border-bottom: 0;
}

.feed-item a {
  color: inherit;
  text-decoration: none;
}

.feed-item a:hover {
  text-decoration: underline;
}

.feed-meta {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: 4px;
}

.focus-btn {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 42;
}

.focus-overlay {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 60;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px) saturate(.9);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .focus-overlay {
    background: rgba(0, 0, 0, .72);
  }
}

.focus-overlay.open {
  display: block;
}

.focus-card {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(980px, 94vw);
  height: min(640px, 88vh);
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--elev-3);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 320px;
}

@media (max-width: 880px) {
  .focus-card {
    grid-template-columns: 1fr;
  }
}

.scene {
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 10px;
}

.scene img {
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--outline);
}

.note {
  max-width: 660px;
  margin: 0 auto;
  text-align: center;
  color: var(--text);
}

.note h3 {
  margin: 0 0 8px 0;
  font-size: 1.6rem;
}

.note p {
  margin: 0 0 10px 0;
  color: var(--text-muted);
}

.note .grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.badge {
  padding: 10px 12px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--surface-2);
}

.mixer {
  background: var(--surface);
  padding: var(--pad);
  border-left: 1px solid var(--outline);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mixer h4 {
  margin: 0 0 6px 0;
}

.track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: var(--surface-2);
}

.track input[type=range] {
  width: 140px;
}

.scene-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scene-btn {
  padding: 6px 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
}

.scene-btn:hover {
  background: var(--state-hover);
}

.scene-title {
  position: absolute;
  left: 10px;
  top: 10px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--outline);
  padding: 6px 10px;
  border-radius: 999px;
}

/* Mini-player */
.mini-player {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 43;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--outline);
  border-radius: 12px;
  box-shadow: var(--elev-2);
  width: min(380px, 94vw);
  transition: all .15s ease;
}

.mp-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-player .title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.mini-player .mp-btn {
  padding: 6px 8px;
  border: 1px solid var(--outline);
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
}

.mini-player .mp-btn:hover {
  background: var(--state-hover);
  border-color: var(--primary);
}

.mini-player .mp-btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

.mp-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

#mpSeek {
  width: 100%;
}

.mp-times {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: .9rem;
  min-width: 88px;
  text-align: right;
}

.mini-player.collapsed {
  padding: 6px 10px;
}

.mini-player.collapsed .mp-bar {
  display: none;
}

.mini-player.collapsed .mp-btn.prev,
.mini-player.collapsed .mp-btn.toggle,
.mini-player.collapsed .mp-btn.next,
.mini-player.collapsed .mp-btn.stop {
  display: none;
}

.listen-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
}

.listen-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.play-btn {
  padding: 8px 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
}

.play-btn:hover {
  background: var(--state-hover);
  border-color: var(--primary);
}

.listen-item[aria-current="true"] {
  outline: 2px solid var(--primary);
}

.muted {
  color: var(--text-muted);
}

h2 {
  margin: 0 0 8px 0;
}

small {
  color: var(--text-muted);
}

/* Elevate main UI above backdrop */
.container {
  position: relative;
  z-index: 1;
}

.controls,
.feed,
.mini-player,
.focus-btn {
  z-index: 2;
}

.h-left h2 {
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
  display: inline-block;
}

/* Focus tools */
.focus-tools {
  position: absolute;
  left: 10px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tool {
  padding: 6px 10px;
  border: 1px solid var(--outline);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
}

.tool:hover {
  background: var(--state-hover);
}

.focus-task {
  position: absolute;
  left: 10px;
  bottom: 56px;
  display: flex;
  gap: 8px;
}

.focus-task input {
  padding: 8px 10px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  min-width: 220px;
}

.timer {
  position: absolute;
  right: 10px;
  bottom: 12px;
  border: 1px solid var(--outline);
  background: var(--surface);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.timer .t {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.preset {
  padding: 6px 10px;
  border: 1px dashed var(--outline);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.preset:hover {
  background: var(--state-hover);
}

.preset-row {
  position: absolute;
  left: 10px;
  top: 46px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}