@font-face {
  font-family: Manrope;
  src: url('/fonts/manrope-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #080808;
  --surface: #121212;
  --ink: #f0f0f0;
  --muted: #adadad;
  --border: #2b2b2b;
  --accent: #08df9c;
  --accent-strong: #6af3c6;
  --accent-soft: #17241e;
  --success: #75d8b5;
  --pending: #ffc078;
  --error: #ff9ea9;
  font: 14px/1.55 Manrope, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; color: inherit; border: 0; background: transparent; }
button:disabled { cursor: default; opacity: .52; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
::selection { background: #c5fae6; color: var(--ink); }
h1, h2, p { margin: 0; }
h1 { font-weight: 770; letter-spacing: -.035em; line-height: 1.12; overflow-wrap: anywhere; }
h2 { font-size: 15px; font-weight: 760; letter-spacing: -.015em; }
label { display: block; margin: 18px 0 7px; font-size: 13px; font-weight: 700; }
input:not([type=checkbox]), select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #373737;
  border-radius: 8px;
  padding: 10px 12px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea { min-height: 104px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 8px;
  color: #080808;
  background: var(--accent);
  font-weight: 750;
  white-space: nowrap;
  transition: background 160ms, transform 160ms;
}
.primary:hover:not(:disabled) { background: var(--accent-strong); }
.primary:active:not(:disabled) { transform: scale(.97); }
.quiet { color: var(--muted); font-size: 13px; padding: 7px; border-radius: 6px; }
.quiet:hover { color: var(--ink); background: var(--bg); }
.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 19px;
  background: var(--surface);
  color: var(--muted);
}
.icon-button:hover { background: var(--accent-soft); color: var(--accent-strong); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 800; line-height: 1.2; }
.brand svg { width: 31px; height: 31px; stroke: var(--accent); fill: none; stroke-width: 1.7; flex-shrink: 0; }
.brand br { display: none; }
.boot { padding: 32px; color: var(--muted); }

.login {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 420px;
  align-items: center;
  gap: clamp(48px, 10vw, 150px);
  max-width: 1220px;
  margin: auto;
  padding: 64px;
}
.login-copy h1 { font-size: clamp(42px, 6vw, 78px); margin: 60px 0 20px; }
.login-copy p { color: var(--muted); font-size: 17px; max-width: 36ch; }
.login-form, dialog { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px; }
.login-form h2 { font-size: 25px; }
.login-form > p:not(.error), dialog p:not(.error) { color: var(--muted); margin-top: 8px; }
.login-form .primary, dialog .primary { width: 100%; margin-top: 15px; }
.error { color: var(--error); margin-top: 10px; font-size: 13px; }

.workspace { display: grid; grid-template-columns: 214px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 25px 17px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.sidebar .brand { padding: 0 6px; }
.nav-heading { display: flex; align-items: center; justify-content: space-between; margin: 39px 0 12px; }
.nav-heading h2 { padding-left: 8px; }
#project-nav { display: flex; flex-direction: column; gap: 5px; overflow: auto; }
.project-item {
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  color: var(--muted);
  border-radius: 8px;
  transition: background 150ms, color 150ms;
}
.project-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item::before { content: ''; width: 7px; height: 7px; border-radius: 50%; border: 1px solid currentColor; flex-shrink: 0; }
.project-item.active, .project-item:hover { background: var(--accent-soft); color: var(--accent-strong); }
.project-item.active { font-weight: 750; }
.project-item.active::before { background: currentColor; }
.nav-empty { color: var(--muted); padding: 8px; }
.sidebar-bottom { margin-top: auto; padding-top: 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.storage { display: inline-flex; align-items: center; gap: 8px; color: var(--success); font-size: 12px; }
.storage i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 30px; height: 62px; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.owner-mark { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 800; }

.editor { max-width: 1640px; margin: auto; padding: 30px; }
.project-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 24px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.project-heading h1 { margin-top: 10px; font-size: clamp(32px, 4vw, 46px); }
.save-controls { display: flex; align-items: center; gap: 12px; }
.save-controls > span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-controls > span.dirty { color: var(--pending); }
.editor-grid { display: grid; grid-template-columns: minmax(215px, .95fr) minmax(250px, 1.15fr) minmax(230px, .88fr); gap: 14px; align-items: start; }
.sequence-panel, .detail-panel, .preview-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 17px;
  min-width: 0;
}
.section-heading, .preview-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.section-heading h2 > span { color: var(--muted); font-size: 12px; margin-left: 3px; }
.measurement { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.slide-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 5px; }
.slide-row { display: flex; align-items: center; border: 1px solid transparent; border-radius: 9px; transition: background 160ms, border-color 160ms; }
.slide-row:hover { background: var(--bg); }
.slide-row.selected { background: var(--accent-soft); border-color: #32775e; }
.slide-select { display: flex; align-items: center; gap: 8px; padding: 9px 7px; text-align: left; flex: 1; min-width: 0; }
.slide-index { display: grid; place-items: center; flex-shrink: 0; width: 23px; height: 23px; color: var(--muted); font-size: 11px; border-radius: 6px; background: var(--bg); }
.selected .slide-index { background: var(--accent); color: #080808; font-weight: 750; }
.slide-copy { min-width: 0; }
.slide-copy strong, .slide-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slide-copy strong { font-size: 13px; font-weight: 740; }
.slide-copy small { font-size: 11px; margin-top: 3px; color: var(--muted); }
.slide-row.off .slide-copy { opacity: .66; }
.reorder { display: flex; gap: 1px; padding-right: 3px; }
.reorder button { width: 24px; height: 33px; border-radius: 6px; color: var(--muted); padding: 0; }
.reorder button:hover:not(:disabled) { color: var(--accent-strong); background: #194a39; }
.add-slide { width: 100%; padding: 10px; border: 1px dashed #515151; color: var(--accent-strong); border-radius: 8px; text-align: left; font-weight: 700; margin-top: 10px; }
.add-slide:hover { background: var(--accent-soft); }
.danger-link, .danger { color: var(--error); }
.danger-link { padding: 0; margin-top: 13px; font-size: 12px; }
.danger-link:hover { text-decoration: underline; }
.no-slide { color: var(--muted); padding: 14px 0; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.field-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
.timing-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.timing-row > div { min-width: 115px; flex: 1; }
.number-unit { display: flex; align-items: center; border: 1px solid #373737; border-radius: 8px; padding-right: 10px; }
.number-unit input { border: 0; width: 64px; }
.number-unit > span { font-size: 12px; color: var(--muted); }
.switch-label { display: flex; align-items: center; gap: 5px; margin: 0 0 7px; font-size: 12px; }

.device { background: #080808; border-radius: 10px; padding: 12px 12px 9px; }
.device-screen { padding: 8px; background: #050505; border: 1px solid #303030; border-radius: 4px; aspect-ratio: 2 / 1; display: grid; place-items: center; }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.device-label { display: flex; justify-content: space-between; font: 10px ui-monospace, monospace; color: #adadad; margin-top: 8px; }
.preview-controls { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 10px; }
.preview-controls .icon-button { width: 29px; height: 32px; }
.preview-controls .quiet { font-size: 12px; }
.preview-explainer { color: var(--muted); font-size: 12px; margin-top: 12px; }
.sequence-summary { display: flex; justify-content: space-between; gap: 8px; border-block: 1px solid var(--border); margin-top: 14px; padding: 12px 0; font-size: 12px; color: var(--muted); }
.sequence-summary strong { display: block; color: var(--ink); font-size: 21px; font-weight: 760; }
.save-footnote { margin-top: 13px; }
.empty { display: grid; place-items: center; align-content: center; gap: 16px; min-height: 66dvh; padding: 30px; text-align: center; }
.empty h1 { font-size: 32px; }
.empty p { color: var(--muted); max-width: 42ch; }
.empty-display { width: 180px; height: 90px; padding: 12px; border-radius: 9px; display: grid; place-items: center; background: #080808; color: #bded83; font: 13px ui-monospace, monospace; }
.workspace-error { color: var(--error); background: #392330; padding: 12px 30px; }
dialog { width: min(430px, calc(100vw - 32px)); color: var(--ink); }
dialog::backdrop { background: #010704a6; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.dialog-heading h2 { font-size: 22px; }
.checkbox-row { display: flex; align-items: center; gap: 7px; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 22px; transform: translateX(-50%); color: var(--ink); background: #222222; border-radius: 9px; padding: 11px 18px; max-width: calc(100% - 28px); }
.editor:not([hidden]), .login:not([hidden]), dialog[open] { animation: enter 270ms cubic-bezier(.2,.75,.25,1) both; }
.toast:not([hidden]) { animation: toast-in 220ms ease-out both; }
@keyframes enter { from { opacity: .65; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 7px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: minmax(210px, 1fr) minmax(240px, 1fr); }
  .sequence-panel { grid-row: 1 / 3; }
  .preview-panel { grid-column: 2; }
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: 170px minmax(0, 1fr); }
  .editor, .topbar { padding-inline: 18px; }
  .editor-grid { grid-template-columns: 1fr; }
  .sequence-panel, .preview-panel { grid-area: auto; }
  .connection-note { display: none; }
  .login { padding: 34px; gap: 32px; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .workspace { display: block; }
  .sidebar { position: static; height: auto; display: grid; grid-template-columns: 1fr auto; gap: 9px; padding: 13px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav-heading { margin: 0; }
  .nav-heading h2 { display: none; }
  #project-nav { grid-column: 1 / -1; flex-direction: row; }
  .project-item { width: auto; max-width: 210px; flex-shrink: 0; }
  .sidebar-bottom { grid-column: 1 / -1; padding: 0; flex-direction: row; justify-content: space-between; align-items: center; }
  .topbar { height: 47px; }
  .editor { padding: 18px 14px 30px; }
  .project-heading { display: block; }
  .save-controls { justify-content: space-between; margin-top: 14px; }
  .reorder button { width: 36px; height: 42px; }
  .login { display: block; padding: 26px 18px; }
  .login-copy h1 { margin-top: 30px; }
  .login-form { margin-top: 27px; padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


/* Project header and ordered slides use the reference's dark green surfaces. */
.topbar { background: #0c0c0c; }
.project-heading {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 166px;
  padding: 26px 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: radial-gradient(ellipse at 91% 100%, #222222 0%, transparent 69%), #101010;
}
.project-heading::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0 0 0 43%;
  background-image: radial-gradient(circle, #aaaaaa35 1px, transparent 1.5px);
  background-size: 18px 18px;
  mask-image: linear-gradient(90deg, transparent, #000);
  animation: grid-in 550ms ease-out both;
}
.project-heading h1 { font-size: clamp(34px, 4.5vw, 55px); }
.project-heading .save-controls { align-self: flex-end; }
.project-heading .save-controls > span { color: var(--ink); }
.project-heading .save-controls > span.dirty { color: var(--pending); }
.sequence-panel, .detail-panel, .preview-panel { border-radius: 10px; }
.slide-list { position: relative; }
.slide-list::before {
  content: '';
  position: absolute;
  left: 19px;
  inset-block: 22px;
  border-left: 1px solid var(--border);
  pointer-events: none;
}
.slide-row { position: relative; }
.slide-index { position: relative; border: 1px solid var(--border); border-radius: 50%; }
.selected .slide-index { border-color: var(--accent); }
.slide-row.selected { background: #17241e; }
.primary { color: #010704; }
.device { border: 1px solid #373737; }
.login-copy {
  padding: clamp(22px, 4vw, 52px);
  border-radius: 12px;
  background: radial-gradient(ellipse at bottom right, #232323, transparent 72%), #101010;
  border: 1px solid var(--border);
}
.login-copy h1 { font-size: clamp(38px, 5vw, 70px); }
@keyframes grid-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (max-width: 620px) {
  .project-heading { min-height: 0; padding: 20px 16px; }
  .project-heading .save-controls { margin-top: 22px; }
  .login-copy { padding: 20px; }
}

#device-dialog { width: min(100% - 2rem, 38rem); max-height: 90dvh; overflow: auto; }
#device-dialog input { width: 100%; min-width: 0; }
#device-dialog .primary { margin-top: .8rem; }
#network-list { display: grid; gap: .8rem; margin-block: 1rem; }
.network-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: .65rem; align-items: end; }
.network-row label { min-width: 0; }
.device-pairing { border-top: 1px solid #2b2b2b; margin-top: 1.25rem; padding-top: 1.25rem; }
#pair-keys { margin-top: 1rem; }
#device-feedback { min-height: 1.4em; }
@media (max-width: 520px) {
  .network-row { grid-template-columns: 1fr; padding-bottom: .8rem; border-bottom: 1px solid #2b2b2b; }
  .network-row button { justify-self: start; }
}

.settings-trigger { position: absolute; inset: 16px 16px auto auto; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); }
.settings-trigger:hover { border-color: var(--accent); }
.project-heading > div:first-of-type { min-width: 0; padding-top: 38px; overflow-wrap: anywhere; }
.device-pairing h3 { font-size: 15px; }
