:root {
  --bg: #fff9f3;
  --panel: #fffdfb;
  --ink: #30251f;
  --muted: #916f5b;
  --line: #efd8c7;
  --line-strong: #e8bd9b;
  --orange: #e96f26;
  --orange-dark: #b84b14;
  --peach: #f3b086;
  --cream: #f4e4d4;
  --cream-2: #faeee3;
  --shadow: 0 18px 44px rgba(111, 62, 26, .08);
  --radius: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(233,111,38,.22); outline-offset: 2px; }
.topbar { height: 66px; display: grid; grid-template-columns: 230px minmax(300px, 480px) 1fr; gap: 42px; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--line); background: rgba(255,250,245,.94); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.brand { border: 0; background: transparent; display: flex; gap: 10px; align-items: center; padding: 0; font-size: 18px; font-weight: 900; cursor: pointer; }
.foxmark { font-size: 27px; transform: translateY(1px); }
.searchbox { height: 46px; background: #fff; border: 1px solid var(--line); border-radius: 14px; display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.searchbox:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(233,111,38,.09); }
.searchbox input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); }
kbd { color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; padding: 0 6px; border-radius: 6px; font-size: 12px; }
.topbar nav { justify-self: end; display: flex; gap: 10px; }
.navbtn, .iconbtn { border: 0; background: transparent; color: var(--orange-dark); font-weight: 800; cursor: pointer; padding: 10px; }
.page { display: grid; grid-template-columns: 208px minmax(0, 1fr) 340px; gap: 20px; padding: 28px 24px 44px; max-width: 1480px; margin: 0 auto; }
.workspace { min-width: 0; }
.hero { display: flex; gap: 16px; align-items: center; padding: 4px 4px 24px; }
.herofox { width: 48px; height: 48px; display: grid; place-items: center; background: var(--cream-2); border: 1px solid var(--line); border-radius: 16px; font-size: 28px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 19px; margin-bottom: 3px; }
.hero p, .muted { color: var(--muted); margin-bottom: 0; }
.sectionbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.sectionbar h2 { font-size: 15px; margin-bottom: 2px; }
.sectionbar p { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.seg { display: flex; gap: 5px; background: var(--cream-2); padding: 4px; border-radius: 13px; }
.seg button, .kindpick button { border: 0; background: transparent; color: #8d6045; font-weight: 800; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.seg button.active, .kindpick button.active { background: var(--orange); color: white; }
.seg.tiny button { padding: 8px 11px; font-size: 13px; }
.vault { min-height: 470px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.62); padding: 20px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-content: start; gap: 14px; }
.vault.list { display: flex; flex-direction: column; }
.empty { grid-column: 1 / -1; min-height: 400px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; gap: 5px; }
.emptyfox { font-size: 34px; filter: saturate(.75); }
.card { min-height: 178px; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); cursor: pointer; transition: .14s ease; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.cardtop { min-height: 105px; background: var(--cream); display: flex; flex-direction: column; justify-content: space-between; padding: 15px; }
.cardicon { font-size: 30px; }
.kindlabel { align-self: flex-start; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: var(--orange-dark); }
.cardbody { padding: 12px 14px; min-width: 0; }
.cardbody strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cardbody p { color: var(--muted); margin: 3px 0 8px; font-size: 13px; min-height: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tagrow { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { background: var(--cream-2); color: #8b5a3c; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; padding: 2px 7px; }
.vault.list .card { min-height: 0; flex-direction: row; }
.vault.list .cardtop { min-height: 92px; width: 120px; flex: 0 0 120px; }
.vault.list .cardbody { flex: 1; }
.creator { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; align-self: start; position: sticky; top: 86px; }
.creator-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.creator-head strong { font-size: 12px; color: var(--muted); text-align: right; }
.eyebrow { color: var(--orange-dark); font-size: 11px; font-weight: 900; letter-spacing: .09em; }
.kindpick { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 14px; }
.kindpick button { background: var(--cream-2); padding: 9px 6px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: flex; justify-content: space-between; font-size: 12px; font-weight: 850; margin: 0 0 5px 2px; }
.field small { color: var(--muted); font-weight: 500; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: white; padding: 10px 11px; color: var(--ink); resize: vertical; }
.field input:focus, .field textarea:focus { outline: 0; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(233,111,38,.08); }
.dropzone { min-height: 150px; border: 2px dashed #efa875; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px; margin: 5px 0 10px; transition: .12s; }
.dropzone.drag { background: #fff2e8; border-color: var(--orange); transform: scale(1.01); }
.dropzone span { color: var(--muted); font-size: 13px; }
.dropzone .limit { font-size: 11px; margin-top: 4px; }
.uploadicon { color: var(--orange); font-size: 34px; line-height: 1; margin-bottom: 8px; }
.pickrow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.soft, .primary, .danger { border: 0; border-radius: 11px; padding: 11px 12px; font-weight: 850; cursor: pointer; }
.soft { background: var(--cream); color: #965324; }
.primary { width: 100%; margin-top: 10px; background: var(--peach); color: white; font-size: 15px; }
.primary:hover { background: var(--orange); }
.danger { background: #fff0ea; color: #b13d1e; padding: 7px 10px; font-size: 12px; }
.filequeue { max-height: 126px; overflow: auto; margin-top: 10px; }
.queueitem { display: flex; justify-content: space-between; gap: 8px; padding: 6px 3px; border-bottom: 1px solid #f5e6da; font-size: 12px; }
.queueitem span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queueitem span:last-child { color: var(--muted); flex: 0 0 auto; }
.status { min-height: 18px; font-size: 12px; color: var(--muted); margin: 7px 0 0; }
.dialog { width: min(1100px, calc(100vw - 34px)); border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: var(--bg); color: var(--ink); box-shadow: 0 32px 100px rgba(61,32,12,.22); }
.dialog::backdrop { background: rgba(55,33,20,.28); backdrop-filter: blur(4px); }
.dialog.small { width: min(560px, calc(100vw - 34px)); }
.dialogbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialogbar h2 { margin-bottom: 5px; }
.iconbtn { font-size: 24px; line-height: 1; }
.detailgrid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 12px; margin-top: 16px; min-height: 480px; }
.tree, .codepane { border: 1px solid var(--line); background: white; border-radius: 14px; overflow: auto; }
.tree { padding: 8px; }
.tree button { display: block; width: 100%; border: 0; background: transparent; text-align: left; padding: 7px 8px; border-radius: 8px; cursor: pointer; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree button:hover { background: var(--cream-2); }
.tree .dir { color: var(--orange-dark); font-weight: 800; }
.codepane { display: flex; flex-direction: column; min-width: 0; }
.codebar { min-height: 44px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px; color: var(--muted); font: 12px ui-monospace, monospace; }
pre { margin: 0; }
#codeView { flex: 1; overflow: auto; background: #2d2927; color: #ffe8d5; padding: 16px; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; tab-size: 2; }
.apidoc { background: #2d2927; color: #ffe8d5; border-radius: 14px; padding: 16px; overflow: auto; margin-bottom: 14px; }
.linkbtn { display: inline-block; text-decoration: none; }
@media (max-width: 980px) { .topbar { grid-template-columns: auto 1fr; gap: 14px; } .topbar nav { display: none; } .page { grid-template-columns: 1fr; } .creator { position: static; grid-row: 1; } .spaces { position: static; } }
@media (max-width: 650px) { .topbar { padding: 0 12px; } .brand span:last-child { display: none; } .page { padding: 16px 12px 30px; } .sectionbar { align-items: stretch; flex-direction: column; } .controls { justify-content: flex-start; } .seg { overflow-x: auto; } .detailgrid { grid-template-columns: 1fr; } .tree { max-height: 220px; } }
.brand { color: var(--ink); text-decoration: none; }
.topbar nav .navbtn { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
@media (max-width: 980px) { .topbar { height: auto; min-height: 66px; padding-top: 8px; padding-bottom: 8px; } .topbar nav { display: flex; grid-column: 1 / -1; justify-self: stretch; overflow-x: auto; } }

.spaces { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; align-self: start; position: sticky; top: 86px; }
.spaces h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.spaces h3 button { padding: 2px 8px; border-radius: 8px; font-size: 12px; }
.spaces .space-row { display: flex; align-items: center; gap: 4px; }
.spaces .space-row button.name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; padding: 8px 9px; border-radius: 9px; background: transparent; color: var(--text); font-weight: 600; }
.spaces .space-row.active button.name { background: #ffe9d6; }
.spaces .space-row button.mini { padding: 4px 6px; font-size: 11px; }
.spaces .count { color: var(--muted); font-size: 11px; }
.spaces .hint { color: var(--muted); font-size: 11px; margin-top: 10px; }

.spaces .space-row.drop-target { background: #ffe0c2; outline: 1px dashed var(--fox); border-radius: 9px; }
.card[draggable="true"] { cursor: grab; }

.editor-dialog { width: min(96vw, 1500px); max-width: none; }
.editorbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 10px; }
.editor-host { height: 68vh; min-height: 320px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.editor-host .ace_gutter { background: #faf3ec; }
.editor-dialog .status { min-height: 1.4em; color: var(--muted); }
