/* DTATools Web: the desktop application's layout - a dark top bar with the module tabs, a ribbon, the model tree,
   the 3D view, the properties and the output - as a page. */
:root {
  --top: #16202e; --top-ink: #e8edf4; --top-muted: #9fb0c6; --accent: #2f6fd0; --accent-ink: #ffffff;
  --bg: #f3f5f8; --panel: #ffffff; --ink: #1b2430; --muted: #66707d; --line: #dfe3e9; --hover: #eef3fb; --select: #d6e4fa;
  --view-a: #c9d7e8; --view-b: #f2f5f9; --ok: #2e9b57; --bad: #b3261e; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
/* (one look, the desktop application's light one, whatever the system's theme) */
:root { color-scheme: light; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { height: 100vh; height: 100dvh; display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  grid-template-rows: 44px auto minmax(0, 1fr) 210px 26px;
  grid-template-areas: "top top top" "ribbon ribbon ribbon" "tree view props" "out out out" "status status status"; }

/* The top bar */
.topbar { grid-area: top; background: var(--top); color: var(--top-ink); display: flex; align-items: stretch; gap: 8px; padding: 0 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--top-ink); text-decoration: none; font-weight: 700; font-size: 16px; padding-right: 14px; }
.brand svg { color: #6aa5ff; }
.tabs { display: flex; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--top-muted); padding: 0 20px; font-size: 15px; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--top-ink); }
.tab.on { color: var(--top-ink); background: #24344b; border-bottom-color: #5b9bff; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.docname { color: var(--top-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.badge { font-size: 12px; color: #9be0b4; white-space: nowrap; }
.badge.live { color: #ffd479; }
.langs { display: flex; border: 1px solid #3a4a61; border-radius: 6px; overflow: hidden; }
.langs button { background: none; border: 0; color: var(--top-muted); padding: 4px 10px; cursor: pointer; }
.langs button.on { background: #2f6fd0; color: #fff; }
.icon { background: none; border: 0; color: var(--top-muted); cursor: pointer; display: flex; padding: 6px; border-radius: 6px; }
.icon:hover { color: var(--top-ink); background: #24344b; }

/* The ribbon */
.ribbon { grid-area: ribbon; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; gap: 0; padding: 6px 8px 2px; overflow-x: auto; }
.group { display: flex; flex-direction: column; padding: 0 12px; border-right: 1px solid var(--line); flex: none; }
.group:last-child { border-right: 0; }
.group__items { display: flex; gap: 6px; align-items: center; flex: 1; }
.group__items.col { flex-direction: column; align-items: stretch; justify-content: center; gap: 4px; display: inline-flex; }
.group:has(.col) { flex-direction: row; flex-wrap: wrap; column-gap: 14px; }
.group:has(.col) .group__label { flex-basis: 100%; }
.group__label { text-align: center; color: var(--muted); font-size: 12px; padding: 3px 0 2px; }
.ribbon button { background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; color: var(--ink); }
.ribbon button:hover:not(:disabled) { background: var(--hover); }
.ribbon button:disabled { color: var(--muted); cursor: default; opacity: .6; }
.ribbon .big { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 14px; min-width: 66px; }
.ribbon .big .glyph { font-size: 20px; line-height: 1; }
.ribbon .big.primary { background: var(--accent); color: var(--accent-ink); }
.ribbon .big.primary:hover { background: var(--accent); filter: brightness(1.08); }
.ribbon .small { padding: 5px 9px; border-color: var(--line); }
.ribbon .small.on { background: var(--select); }
.ribbon label { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink); }
.ribbon select, .ribbon input[type=number] { background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; width: 150px; }
.ribbon input[type=number] { width: 92px; }
.ribbon label.check { cursor: pointer; }

/* The panels */
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel h2 { margin: 0; padding: 9px 14px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--bg); }
.tree { grid-area: tree; border-right: 1px solid var(--line); }
.props { grid-area: props; border-left: 1px solid var(--line); }
.tree__body, .props__body { overflow: auto; flex: 1; }
.node { padding: 4px 0; }
.node__head { display: flex; justify-content: space-between; gap: 8px; padding: 5px 14px 5px 12px; font-weight: 600; cursor: pointer; user-select: none; }
.node__head::before { content: "▾"; color: var(--muted); margin-right: 6px; }
.node.closed .node__head::before { content: "▸"; }
.node.closed .leaf { display: none; }
.node__head span:first-of-type { flex: 1; }
.node__head .count { color: var(--muted); font-weight: 400; }
.leaf { display: flex; justify-content: space-between; gap: 10px; padding: 5px 14px 5px 38px; cursor: pointer; position: relative; }
.leaf::before { content: ""; position: absolute; left: 24px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--ok); }
.leaf.off::before { background: var(--line); }
.leaf:hover { background: var(--hover); }
.leaf.on { background: var(--select); }
.leaf .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaf .what { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 55%; }
.props__body { padding: 12px 14px; }
.props__body h3 { margin: 0; font-size: 17px; }
.props__body .sub { color: var(--muted); margin: 2px 0 12px; }
.props__body h4 { margin: 14px 0 6px; font-size: 13px; }
.kv { display: grid; grid-template-columns: minmax(80px, 40%) 1fr; gap: 6px 10px; align-items: center; }
.kv .k { color: var(--muted); overflow-wrap: anywhere; }
.kv .v { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; min-height: 26px; }
table.values { width: 100%; border-collapse: collapse; font-size: 13px; }
table.values td, table.values th { border-top: 1px solid var(--line); padding: 5px 4px; text-align: left; }
table.values td.num, table.values th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }

/* The 3D view */
.viewport { grid-area: view; position: relative; min-height: 0; min-width: 0; background: linear-gradient(var(--view-a), var(--view-b)); overflow: hidden; }
#canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.legend { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); color: var(--ink); font-size: 13px; }
.legend__title { font-weight: 600; margin-bottom: 8px; text-align: right; }
.legend__bar { display: flex; gap: 8px; justify-content: flex-end; }
.legend__ticks { display: flex; flex-direction: column; justify-content: space-between; height: 200px; font-family: var(--mono); font-size: 12px; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.empty p { max-width: 420px; margin: 0; color: var(--ink); font-size: 15px; }
.tip { position: absolute; pointer-events: none; background: var(--top); color: #fff; padding: 3px 7px; border-radius: 4px; font: 12px var(--mono); transform: translate(12px, 12px); white-space: nowrap; }
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 8px 18px; cursor: pointer; }
button.primary:disabled { opacity: .5; cursor: default; }

/* The output */
.output { grid-area: out; min-width: 0; background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.output__tabs { display: flex; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.otab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 7px 16px; cursor: pointer; color: var(--muted); }
.otab.on { color: var(--accent); border-bottom-color: var(--accent); background: var(--panel); }
.output__body { flex: 1; min-height: 0; overflow: auto; margin: 0; }
.log { padding: 8px 12px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; }
#out-assistant { display: flex; flex-direction: column; }
.chat { flex: 1; overflow: auto; padding: 8px 12px; min-height: 0; }
.msg { margin: 0 0 8px; max-width: 900px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { background: var(--select); border-radius: 8px; padding: 6px 10px; width: fit-content; }
.msg.note { color: var(--muted); font-size: 12.5px; }
.msg.bad { color: var(--bad); }
.ask { display: flex; gap: 8px; padding: 6px 12px 8px; border-top: 1px solid var(--line); flex: none; }
.ask textarea { flex: 1; resize: none; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; min-width: 0; }
.ask textarea:disabled { background: var(--bg); }

.status { grid-area: status; display: flex; justify-content: space-between; gap: 12px; padding: 4px 12px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: var(--bg); white-space: nowrap; overflow: hidden; }
.status span { overflow: hidden; text-overflow: ellipsis; }

/* The dialogs */
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); padding: 18px 20px; width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
dialog::backdrop { background: rgba(10, 16, 26, .45); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog .note { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
dialog label { display: grid; gap: 4px; margin-bottom: 10px; }
dialog input { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
dialog form { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
dialog form button:not(.primary) { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; cursor: pointer; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.card:hover { border-color: var(--accent); }
.card b { font-size: 14px; }
.card small { color: var(--muted); }
.card span { font-size: 12.5px; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Narrow screens: the view first, the panels below it, the page scrolls */
@media (max-width: 900px) {
  #app { height: auto; min-height: 100dvh; grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 44px auto 56vh auto auto auto 26px;
    grid-template-areas: "top" "ribbon" "view" "out" "tree" "props" "status"; }
  .tree, .props { border: 0; border-top: 1px solid var(--line); max-height: 320px; }
  .output { height: 260px; }
  .docname, .badge { display: none; }
  #app { max-width: 100vw; overflow-x: clip; }
  .tab { padding: 0 12px; }
  .legend { right: 8px; }
}

/* Editing the model's values (a server that solves models sent to it is connected) */
.kv input.edit { width: 100%; min-width: 0; box-sizing: border-box; background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; font-family: var(--mono); font-size: 12.5px; min-height: 26px; color: inherit; }
.kv input.edit:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.kv input.edit.bad { border-color: #c0392b; background: #fdf1ef; }
.kv .many { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.kv .many input.edit { flex: 1 1 84px; width: auto; }
.groups { display: grid; gap: 3px; }
.hint.changed { color: var(--accent); }
