:root {
  color-scheme: dark;
  --bg: #08090b;
  --panel: rgba(20,22,27,.9);
  --panel-2: rgba(27,29,35,.86);
  --line: rgba(255,255,255,.12);
  --line-strong: rgba(255,255,255,.22);
  --text: #f2f4f6;
  --muted: #9da4ad;
  --red: #e3414b;
  --red-soft: rgba(227,65,75,.14);
  --green: #5fd3a0;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(150,24,33,.25), transparent 32rem),
    radial-gradient(circle at 92% 18%, rgba(64,72,92,.18), transparent 28rem),
    linear-gradient(150deg, #111318 0%, #08090b 44%, #0b0c0f 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.studio-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 74px;
  padding: 10px clamp(16px, 4vw, 52px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(8,9,11,.88);
  backdrop-filter: blur(18px) saturate(140%);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: .8px; }
.brand img { width: 50px; height: 50px; object-fit: contain; }
.brand span { display: grid; gap: 3px; }
.brand small { color: #e2767d; font: 10px/1.1 var(--mono); letter-spacing: 1.8px; }
.studio-header nav { display: flex; gap: 8px; }
.studio-header nav a {
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #c8cdd3;
  font: 700 10px/1 var(--mono);
  letter-spacing: 1.2px;
  text-decoration: none;
  text-transform: uppercase;
}
.studio-header nav a:hover { border-color: var(--line-strong); color: #fff; }

main { width: min(1500px, 100%); margin: 0 auto; padding: clamp(22px, 4vw, 54px); }
.access-card {
  width: min(680px, 100%);
  margin: 10vh auto;
  padding: clamp(28px, 6vw, 58px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 34px 90px rgba(0,0,0,.42);
  text-align: center;
}
.gate-mark { width: 62px; height: 62px; margin: 0 auto 22px; display: grid; place-items: center; border: 1px solid rgba(227,65,75,.4); border-radius: 50%; background: var(--red-soft); color: #ff8f96; font-size: 34px; }
.access-card h1 { margin: 8px 0 12px; font-size: clamp(26px, 5vw, 44px); line-height: 1.05; }
.access-card > p:not(.eyebrow) { margin: 0; color: var(--muted); line-height: 1.6; }
.gate-actions { margin-top: 28px; display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.eyebrow { margin: 0; color: #dc7178; font: 700 10px/1.2 var(--mono); letter-spacing: 1.8px; text-transform: uppercase; }
.studio-intro { margin-bottom: 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.studio-intro h1 { max-width: 820px; margin: 8px 0 10px; font-size: clamp(31px, 5vw, 58px); line-height: .98; letter-spacing: -1.8px; }
.studio-intro > div > p:last-child { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.55; }
.signed-in { flex: none; min-height: 42px; padding: 0 14px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.04); color: #cdd2d7; font: 700 10px/1 var(--mono); letter-spacing: 1px; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px rgba(95,211,160,.8); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { min-height: 48px; padding: 0 20px; border: 1px solid var(--line); border-radius: 8px 8px 0 0; background: rgba(255,255,255,.025); color: var(--muted); cursor: pointer; font: 800 11px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; }
.tab.active { border-color: rgba(227,65,75,.42); background: var(--red-soft); color: #fff; }

.workspace { display: grid; grid-template-columns: minmax(280px, 370px) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 0 16px 16px 16px; background: rgba(11,12,15,.72); box-shadow: 0 28px 80px rgba(0,0,0,.34); overflow: hidden; }
.library { min-width: 0; padding: 20px; border-right: 1px solid var(--line); background: rgba(255,255,255,.018); }
.library-head, .editor-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.library h2, .editor h2 { margin: 5px 0 0; font-size: 22px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(227,65,75,.45); border-radius: 50%; background: var(--red-soft); color: #ff9ca2; cursor: pointer; font-size: 25px; }

.search { height: 44px; margin-top: 18px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.25); color: var(--muted); }
.search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: #fff; }
.library-filters { margin: 12px 0 14px; display: flex; gap: 6px; }
.filter { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer; font: 700 9px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; }
.filter.active { border-color: rgba(227,65,75,.42); background: var(--red-soft); color: #fff; }

.item-list { max-height: 710px; display: grid; gap: 8px; overflow: auto; padding-right: 3px; scrollbar-color: #54565c transparent; }
.library-item { width: 100%; padding: 14px; display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.025); color: inherit; cursor: pointer; text-align: left; }
.library-item:hover, .library-item.active { border-color: rgba(227,65,75,.5); background: rgba(227,65,75,.09); }
.library-item strong { overflow-wrap: anywhere; font-size: 14px; line-height: 1.28; }
.item-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font: 9px/1.2 var(--mono); letter-spacing: .8px; text-transform: uppercase; }
.status-chip { padding: 4px 7px; border: 1px solid rgba(255,255,255,.13); border-radius: 999px; }
.status-chip.live { border-color: rgba(95,211,160,.3); background: rgba(95,211,160,.1); color: #90e9bf; }
.empty-list { padding: 30px 12px; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); font: 11px/1.6 var(--mono); text-align: center; }

.editor { min-width: 0; padding: clamp(20px, 4vw, 40px); background: var(--panel); }
.unsaved { color: #ffbb73; font: 700 9px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; }
.editor-form { margin-top: 28px; display: grid; gap: 20px; }
.field-grid { display: grid; gap: 16px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.field { min-width: 0; display: grid; gap: 8px; color: #d9dde1; font-size: 13px; font-weight: 700; }
.field > span { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.field b { color: #ef767d; font: 700 9px/1 var(--mono); letter-spacing: .8px; text-transform: uppercase; }
.field em { color: var(--muted); font: 500 10px/1 var(--mono); }
.field input:not([type=file]), .field textarea, .field select {
  width: 100%;
  min-height: 46px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: rgba(0,0,0,.28);
  color: #fff;
  resize: vertical;
}
.field textarea { line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(227,65,75,.7); box-shadow: 0 0 0 3px rgba(227,65,75,.1); }
.field small { color: var(--muted); font: 10px/1.4 var(--mono); text-align: right; }

.toggle-card { min-height: 76px; padding: 13px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0,0,0,.2); cursor: pointer; }
.toggle-card input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { width: 42px; height: 24px; flex: none; position: relative; border-radius: 999px; background: #34373d; transition: .2s; }
.toggle::after { content: ''; width: 18px; height: 18px; position: absolute; top: 3px; left: 3px; border-radius: 50%; background: #d6d8dc; transition: .2s; }
.toggle-card input:checked + .toggle { background: var(--red); }
.toggle-card input:checked + .toggle::after { transform: translateX(18px); background: #fff; }
.toggle-card > span:last-child { display: grid; gap: 4px; }
.toggle-card strong { font-size: 13px; }
.toggle-card small { color: var(--muted); font-size: 11px; line-height: 1.35; }

.drop-zone { min-height: 144px; padding: 22px; display: grid; place-items: center; align-content: center; gap: 6px; border: 1px dashed rgba(255,255,255,.28); border-radius: 10px; background: rgba(255,255,255,.025); color: #e6e8eb; cursor: pointer; text-align: center; }
.drop-zone:hover, .drop-zone.dragging { border-color: rgba(227,65,75,.75); background: var(--red-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { color: #ff858c; font-size: 28px; }
.drop-zone small { color: var(--muted); font: 10px/1.4 var(--mono); }
.file-preview { position: relative; min-height: 110px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(0,0,0,.28); }
.file-preview img, .file-preview video { width: min(100%, 520px); max-height: 260px; display: block; margin: 0 auto; border-radius: 6px; object-fit: contain; }
.file-preview p { margin: 9px 0 0; color: var(--muted); font: 10px/1.4 var(--mono); text-align: center; overflow-wrap: anywhere; }
.segmented { display: grid; grid-template-columns: repeat(2,1fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: rgba(0,0,0,.25); }
.segmented input { position: absolute; opacity: 0; }
.segmented span { min-height: 42px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); cursor: pointer; font: 800 10px/1 var(--mono); letter-spacing: 1px; text-transform: uppercase; }
.segmented input:checked + span { background: var(--red-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(227,65,75,.4); }

.editor-actions { margin-top: 28px; padding-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); }
.save-actions { display: flex; justify-content: flex-end; gap: 9px; }
.button { min-height: 44px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(255,255,255,.04); color: #fff; cursor: pointer; font: 800 10px/1 var(--mono); letter-spacing: 1px; text-decoration: none; text-transform: uppercase; }
.button:hover { background: rgba(255,255,255,.08); }
.button.primary { border-color: #df404a; background: #c6323c; }
.button.primary:hover { background: #df404a; }
.button.danger { border-color: rgba(227,65,75,.34); color: #ff8d94; }
.button:disabled { opacity: .46; cursor: wait; }
.status { min-height: 20px; margin-top: 14px; color: var(--muted); font: 10px/1.5 var(--mono); letter-spacing: .5px; }
.status.error { color: #ff8d94; }
.status.ok { color: #87e4b9; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); padding: 14px 17px; border: 1px solid rgba(95,211,160,.35); border-radius: 9px; background: rgba(12,25,20,.96); box-shadow: 0 20px 50px rgba(0,0,0,.45); color: #b9f3d7; font: 700 11px/1.5 var(--mono); }

[hidden] { display: none !important; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; border-radius: 0 12px 12px 12px; }
  .library { border-right: 0; border-bottom: 1px solid var(--line); }
  .item-list { max-height: 310px; }
}

@media (max-width: 620px) {
  .studio-header { min-height: 64px; padding: 8px 12px; }
  .brand img { width: 44px; height: 44px; }
  .brand span { font-size: 11px; }
  .studio-header nav a { display: none; }
  .studio-header nav a:last-child { display: inline-flex; min-height: 42px; }
  main { padding: 18px 12px 36px; }
  .studio-intro { align-items: flex-start; flex-direction: column; }
  .studio-intro h1 { letter-spacing: -1px; }
  .tabs { width: 100%; }
  .tab { min-width: 0; flex: 1; padding: 0 8px; font-size: 9px; }
  .library, .editor { padding: 16px 13px; }
  .field-grid.two { grid-template-columns: 1fr; }
  .editor-actions { align-items: stretch; flex-direction: column-reverse; }
  .save-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .danger-zone .button { width: 100%; }
  .toast { right: 16px; bottom: 16px; }
}
