:root {
  --bg: #07090d;
  --panel: #0e1218;
  --panel-2: #141a22;
  --line: #222b36;
  --text: #dfe6ef;
  --muted: #8592a3;
  --accent: #8fb8ff;
  --accent-2: #ffd88a;
  --ok: #7fe0a8;
  --err: #ff8a8a;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.45 Inter, system-ui, -apple-system, sans-serif; overflow: hidden; }
button, .button { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 11px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover:not(:disabled), .button:hover { border-color: #3a4757; background: #1a212b; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: #23395c; border-color: #35548a; color: #eaf2ff; padding: 8px 18px; font-weight: 500; }
button.primary:hover { background: #2b4772; }
button.icon { padding: 5px 9px; }
input { font: inherit; color: var(--text); background: #0a0d12; border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
input:focus { outline: 1px solid var(--accent); border-color: transparent; }

header { height: 46px; display: flex; align-items: center; gap: 14px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .02em; color: var(--accent); white-space: nowrap; }
.title { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; gap: 6px; }

main { position: absolute; top: 46px; left: 0; right: 0; bottom: 0; display: flex; }
#viewer { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #000; cursor: grab; }
#viewer.dragging { cursor: grabbing; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, #101826 0%, #05070a 70%); }
.drop-card { text-align: center; max-width: 440px; padding: 36px 28px; border: 1.5px dashed #2c3a4d; border-radius: 16px; color: var(--muted); }
.drop-card svg { color: var(--accent); margin-bottom: 6px; }
.drop-card h1 { font-size: 20px; font-weight: 600; color: var(--text); margin: 6px 0 8px; }
.drop-card p { margin: 0 0 16px; }
.drop-card .hint { margin: 14px 0 0; font-size: 12px; opacity: .8; }

.dropzone { position: fixed; inset: 0; z-index: 50; background: rgba(10, 20, 40, .7); display: grid; place-items: center; pointer-events: none; }
.dropzone div { border: 2px dashed var(--accent); border-radius: 20px; padding: 60px 90px; font-size: 22px; color: #eaf2ff; background: rgba(20, 35, 60, .6); }

.progress { position: absolute; left: 16px; bottom: 16px; max-width: min(560px, calc(100% - 32px)); display: flex; gap: 12px;
  align-items: flex-start; background: rgba(8, 11, 16, .88); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; backdrop-filter: blur(6px); }
.progress ol { list-style: none; margin: 0; padding: 0; font: 12px/1.6 var(--mono); color: var(--muted); max-height: 40vh; overflow: auto; }
.progress li:last-child { color: var(--text); }
.progress li.err { color: var(--err); }
.progress li.ok { color: var(--ok); }
.progress li .t { color: #566273; margin-right: 8px; }
.spinner { flex: none; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 2px solid #2a3647; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.progress.done .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.legend { position: absolute; left: 12px; top: 12px; z-index: 2; font-size: 12px; color: #dfe6ef; background: rgba(5, 8, 12, .75);
  border-radius: 6px; padding: 4px 9px; pointer-events: none; display: flex; align-items: center; gap: 7px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; background: rgba(255, 110, 70, .6); flex: none; }
.readout { position: absolute; left: 12px; bottom: 12px; font: 12px var(--mono); color: #c9d4e2; background: rgba(5, 8, 12, .75);
  padding: 4px 9px; border-radius: 6px; pointer-events: none; white-space: nowrap; }
.tooltip { position: absolute; pointer-events: none; background: rgba(12, 16, 22, .95); border: 1px solid #2c3746; border-radius: 6px;
  padding: 6px 9px; font-size: 12px; max-width: 280px; z-index: 5; }
.tooltip b { color: #fff; font-weight: 600; }
.tooltip .sub { color: var(--muted); }

aside { width: 300px; flex: none; border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; }
aside.hidden { display: none; }
aside section { padding: 12px 14px 14px; border-bottom: 1px solid var(--line); }
aside h2 { margin: 0 0 9px; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.small { font-size: 12px; margin: -2px 0 10px; }

.info { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-family: var(--mono); font-size: 12px; text-align: right; }
.info dd.good { color: var(--ok); }
.info dd.warn { color: var(--accent-2); }

.layers { display: grid; gap: 2px; }
.layer { display: flex; align-items: center; gap: 9px; padding: 4px 6px; border-radius: 5px; cursor: pointer; user-select: none; }
.layer:hover { background: var(--panel-2); }
.layer input { margin: 0; accent-color: var(--accent); }
.layer .sw { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.layer .name { flex: 1; }
.layer .note { display: block; font-size: 11px; color: #e8b25c; line-height: 1.3; }
.layer .note:empty { display: none; }
.layer kbd { font: 10px var(--mono); color: #6b7788; border: 1px solid #2a3442; border-radius: 3px; padding: 0 4px; }
.layer.na { opacity: .35; }

.slider { display: grid; grid-template-columns: 1fr 120px; align-items: center; gap: 8px; margin: 4px 0; color: var(--muted); }
.slider input { width: 100%; accent-color: var(--accent); padding: 0; }

.obs { display: grid; grid-template-columns: 0.9fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.obs label { display: grid; gap: 3px; color: var(--muted); font-size: 12px; }
.obs label:first-child { grid-column: 1 / -1; }
.obs input { width: 100%; }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.history li { display: flex; gap: 8px; align-items: baseline; padding: 4px 6px; border-radius: 5px; cursor: pointer; }
.history li:hover { background: var(--panel-2); }
.history li.active { background: #172234; }
.history .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .st { font: 11px var(--mono); color: var(--muted); }
.history .st.error { color: var(--err); }
.history .st.running, .history .st.queued { color: var(--accent-2); }

@media (max-width: 760px) {
  aside { position: absolute; right: 0; top: 0; bottom: 0; width: min(300px, 88vw); z-index: 10; box-shadow: -10px 0 30px rgba(0,0,0,.5); }
  .brand span, .title { display: none; }
  #btn-wcs { display: none; }
}

dialog#publish { width: min(520px, calc(100vw - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
dialog#publish::backdrop { background: rgba(0, 0, 0, .55); }
dialog#publish h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
#publish-form { display: grid; gap: 10px; }
#publish-form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
#publish-form input, #publish-form textarea { width: 100%; font: inherit; color: var(--text); background: #0a0d12; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
#publish-form textarea { resize: vertical; }
#publish-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#publish-form .slug { display: flex; align-items: center; gap: 2px; }
#publish-form .slug .muted { white-space: nowrap; font-size: 13px; }
#publish-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
#publish-form label.check input { width: auto; }
#publish-form label.check.na { opacity: .4; }
#publish-form .status { font-size: 12px; color: var(--muted); min-height: 1em; }
#publish-form .status a { color: var(--accent); }
#publish-form .status code { display: block; margin-top: 6px; padding: 6px 8px; background: #0a0d12; border: 1px solid var(--line); border-radius: 6px; font: 11.5px var(--mono); color: var(--text); user-select: all; }
#publish-form .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.history .st.pub { color: var(--ok); }

/* client-only app */
.drop-card .hint { line-height: 1.6; }
.progress li.ok { color: var(--ok); }
.urlform { display: flex; gap: 6px; margin: 14px auto 0; max-width: 360px; }
.urlform input { flex: 1; min-width: 0; padding: 7px 9px; }
.title a { color: var(--muted); text-decoration: none; }
.title a:hover { color: var(--text); text-decoration: underline; }
dialog#share { width: min(520px, calc(100vw - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
dialog#share::backdrop { background: rgba(0, 0, 0, .55); }
dialog#share h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
#share-form { display: grid; gap: 10px; }
#share-form label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
#share-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
#share-form label.check input { width: auto; }
#share-form label.check.na { opacity: .4; }
#share-form input[type=url], #share-form textarea { width: 100%; font: inherit; color: var(--text); background: #0a0d12; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
#share-form textarea { font: 12px var(--mono); resize: none; }
#share-form .row { display: flex; gap: 8px; }
#share-form .row input { flex: 1; }
#share-form .status { font-size: 12px; color: var(--muted); min-height: 1em; }
#share-form .status.bad { color: var(--err); }
#share-form .status.good { color: var(--ok); }
#share-form .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
@media (max-width: 760px) { header .title { display: none; } .actions button { padding: 5px 9px; } }

/* toolbar: icon buttons (labels hidden on phones); the layers button never scrolls off */
header { position: relative; }
button.tb { display: inline-flex; align-items: center; gap: 6px; }
button.tb svg { flex: none; }
#btn-panel { flex: none; }
#btn-panel[aria-expanded="true"] { border-color: #35548a; background: #1b2a42; }
.actions { min-width: 0; margin-left: auto; } /* phones hide the title that otherwise pushes these right */
@media (max-width: 760px) {
  header { gap: 8px; padding: 0 8px; }
  .actions { gap: 4px; }
  button.tb { padding: 6px 8px; }
  button.tb .lbl { display: none; }
}
@media (max-width: 760px) { .brand .name { display: inline; } }
@media (max-width: 520px) { .brand .name { display: none; } }
.callout { position: absolute; top: calc(100% + 8px); right: 8px; z-index: 20; max-width: 220px;
  background: #23395c; color: #eaf2ff; border: 1px solid #35548a; border-radius: 8px; padding: 7px 11px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.45); cursor: pointer; animation: callout-in .25s ease-out; }
.callout::before { content: ""; position: absolute; top: -6px; right: 14px; width: 10px; height: 10px;
  background: inherit; border-left: 1px solid #35548a; border-top: 1px solid #35548a; transform: rotate(45deg); }
@keyframes callout-in { from { opacity: 0; transform: translateY(-4px); } }

.credit { position: absolute; right: 10px; bottom: 10px; z-index: 3; display: inline-flex; align-items: center; gap: 6px;
  font: 400 11px Inter, system-ui, sans-serif; letter-spacing: .01em; color: rgba(255,255,255,.22); text-decoration: none;
  padding: 3px 6px; border-radius: 999px; transition: color .2s, background .2s; }
.credit:hover { color: rgba(255,255,255,.85); background: rgba(5,8,12,.6); }
