:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #080909;
  color: #eef3ed;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  background: #080909;
}

#blackhole {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
}

.control-panel {
  position: fixed;
  top: 24px;
  left: 24px;
  width: min(440px, calc(100vw - 48px));
  padding: 20px;
  border: 1px solid rgba(218, 232, 219, 0.18);
  border-radius: 8px;
  background: rgba(13, 15, 14, 0.76);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(16px);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.panel-toggle,
.github-link {
  display: inline-flex;
  min-height: 44px;
  min-width: 44px;
  width: 44px;
  padding: 0;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(238, 243, 237, 0.2);
  border-radius: 8px;
  border-color: rgba(238, 243, 237, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #eef3ed;
  text-decoration: none;
}

.panel-toggle:hover,
.github-link:hover {
  background: rgba(255, 255, 255, 0.14);
}

.panel-toggle svg,
.github-link svg {
  width: 21px;
  height: 21px;
  color: currentColor;
}

.panel-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.github-link svg {
  fill: currentColor;
}

.github-link {
  min-height: 24px;
  min-width: 24px;
  width: 24px;
  border-color: rgba(238, 243, 237, 0.16);
  border-radius: 6px;
  background: #f7fbf4;
  color: #121413;
  box-shadow: none;
}

.github-link:hover {
  background: #f7fbf4;
}

.github-link svg {
  width: 18px;
  height: 18px;
}

.panel-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.panel-toggle .icon-expand {
  display: none;
}

body[data-panel="collapsed"] .panel-toggle .icon-expand {
  display: block;
}

body[data-panel="collapsed"] .panel-toggle .icon-collapse {
  display: none;
}

body[data-panel="collapsed"] .control-panel {
  top: 24px;
  left: 24px;
  width: min(382px, calc(100vw - 48px));
  max-height: none;
  overflow: visible;
  display: grid;
  grid-template-columns: minmax(78px, 0.9fr) auto 40px;
  grid-template-areas:
    "time controls toggle"
    "meter meter meter";
  align-items: center;
  gap: 6px 9px;
  padding: 8px 10px 7px;
  border-color: rgba(218, 232, 219, 0.12);
  background: rgba(8, 9, 9, 0.56);
  box-shadow: 0 12px 38px rgba(0, 0, 0, 0.28);
}

body[data-panel="collapsed"] .panel-header {
  grid-area: toggle;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}

body[data-panel="collapsed"] .panel-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

body[data-panel="collapsed"] .kicker,
body[data-panel="collapsed"] .summary,
body[data-panel="collapsed"] h1,
body[data-panel="collapsed"] .settings,
body[data-panel="collapsed"] .panel-footer {
  display: none;
}

body[data-panel="collapsed"] .status-row {
  grid-area: time;
  display: block;
  min-width: 0;
  margin-top: 0;
}

body[data-panel="collapsed"] .status-row > div {
  display: none;
}

body[data-panel="collapsed"] .status-row > div:first-child {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

body[data-panel="collapsed"] .label {
  font-size: 0.56rem;
  line-height: 1;
}

body[data-panel="collapsed"] .status-row strong {
  margin-top: 1px;
  font-size: 1rem;
  line-height: 1;
}

body[data-panel="collapsed"] .controls {
  grid-area: controls;
  gap: 6px;
  margin-top: 0;
}

body[data-panel="collapsed"] .controls button {
  min-height: 34px;
  min-width: 62px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  line-height: 1;
}

body[data-panel="collapsed"] .panel-toggle {
  min-height: 34px;
  min-width: 34px;
  width: 34px;
  align-self: center;
  border-color: rgba(238, 243, 237, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #eef3ed;
}

body[data-panel="collapsed"] .panel-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
}

body[data-panel="collapsed"] .panel-toggle svg {
  width: 19px;
  height: 19px;
}

body[data-panel="collapsed"] .meter {
  grid-area: meter;
  height: 3px;
  margin-top: 0;
  background: rgba(255, 255, 255, 0.1);
}

body[data-scene="reference"] .control-panel {
  top: auto;
  bottom: 20px;
  left: 20px;
  width: 320px;
  padding: 14px;
  background: rgba(8, 9, 9, 0.58);
}

body[data-scene="reference"] h1 {
  font-size: 1.34rem;
}

body[data-scene="reference"] .summary {
  display: none;
}

body[data-scene="reference"] .status-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

body[data-scene="reference"] .status-row > div {
  padding: 8px;
}

body[data-scene="reference"] .status-row strong {
  font-size: 0.86rem;
}

body[data-scene="reference"] .label,
body[data-scene="reference"] .kicker {
  font-size: 0.64rem;
}

body[data-scene="reference"] .controls {
  margin-top: 12px;
}

body[data-scene="reference"] button {
  min-height: 36px;
  min-width: 72px;
  font-size: 0.88rem;
}

body[data-scene="reference"] .panel-toggle {
  min-width: 40px;
  width: 40px;
}

body[data-scene="reference"] .settings {
  gap: 8px;
  margin-top: 12px;
}

body[data-scene="reference"] .field-control {
  grid-template-columns: 1fr;
  gap: 5px;
  font-size: 0.76rem;
}

body[data-scene="reference"] select {
  min-height: 36px;
}

body[data-scene="reference"] .field-help {
  grid-column: auto;
  font-size: 0.68rem;
  line-height: 1.35;
}

.title-block {
  display: grid;
  gap: 8px;
}

.kicker,
.label {
  margin: 0;
  color: #9cc7b5;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #f7fbf4;
  font-size: clamp(1.45rem, 4vw, 2rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.summary {
  max-width: 38rem;
  margin: 0;
  color: #cbd5cc;
  font-size: 0.96rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.status-row > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(218, 232, 219, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.status-row strong {
  display: block;
  margin-top: 4px;
  color: #fff8e1;
  font-variant-numeric: tabular-nums;
  font-size: 1.06rem;
  line-height: 1.2;
}

.meter {
  height: 10px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #62d69f, #ffcf70, #ff7b54);
  transition: width 180ms ease-out;
}

.controls {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

button {
  min-height: 44px;
  min-width: 96px;
  border: 1px solid rgba(255, 207, 112, 0.75);
  border-radius: 8px;
  background: #ffd06f;
  color: #17120a;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: #ffe09d;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #72d8ff;
  outline-offset: 2px;
}

button.secondary {
  border-color: rgba(238, 243, 237, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #eef3ed;
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.settings {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.field-control {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 1.3fr auto;
  align-items: center;
  gap: 10px;
  color: #dce5dc;
  font-size: 0.92rem;
}

.field-help {
  grid-column: 2 / -1;
  color: #a9b5ab;
  font-size: 0.76rem;
  line-height: 1.4;
}

input[type="range"] {
  width: 100%;
  accent-color: #ffd06f;
}

select {
  min-height: 44px;
  width: 100%;
  border: 1px solid rgba(238, 243, 237, 0.24);
  border-radius: 8px;
  background: #151817;
  color: #eef3ed;
  padding: 0 12px;
}

@media (max-width: 720px) {
  body {
    overflow: auto;
    background: #080909;
  }

  .control-panel {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: auto;
    width: min(360px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    overflow: auto;
    padding: 16px;
  }

  .panel-toggle {
    min-height: 40px;
    min-width: 40px;
    width: 40px;
  }

  .github-link {
    min-height: 40px;
    min-width: 40px;
    width: 40px;
  }

  body[data-panel="collapsed"] .control-panel {
    top: auto;
    right: auto;
    bottom: 8px;
    left: 8px;
    width: min(374px, calc(100vw - 16px));
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: minmax(68px, 0.9fr) auto 34px;
    grid-template-areas:
      "time controls toggle"
      "meter meter meter";
    align-items: center;
    justify-items: stretch;
    gap: 5px 8px;
    padding: 7px 8px 6px;
    border-color: rgba(218, 232, 219, 0.12);
    background: rgba(8, 9, 9, 0.54);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.26);
  }

  body[data-panel="collapsed"] .label {
    font-size: 0.54rem;
    line-height: 1;
  }

  body[data-panel="collapsed"] .status-row strong {
    margin-top: 1px;
    font-size: 0.98rem;
    line-height: 1;
  }

  body[data-panel="collapsed"] .controls button {
    min-height: 32px;
    min-width: 58px;
    padding: 0 10px;
    border-radius: 7px;
    font-size: 0.78rem;
    line-height: 1;
  }

  body[data-panel="collapsed"] .panel-toggle svg {
    width: 19px;
    height: 19px;
  }

  .status-row {
    grid-template-columns: 1fr;
  }

  .field-control {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .field-help {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .meter span {
    transition: none;
  }
}
