:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #66716c;
  --paper: #f3f1e9;
  --panel: #fffdf7;
  --line: #d7d5cc;
  --accent: #d94c27;
  --accent-dark: #a93518;
  --blueprint: #244b5a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
}

button, input { font: inherit; }

.site-header {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.94);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.03em;
}

.brand span, .brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: white;
  background: var(--accent);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.session { display: flex; gap: 18px; align-items: center; color: var(--muted); font-size: 14px; }
.header-button {
  padding: 7px 11px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  font-weight: 700;
  text-decoration: none;
}
.header-button:hover { border-color: var(--accent); color: var(--accent-dark); }
.text-button { border: 0; background: none; color: var(--ink); cursor: pointer; text-decoration: underline; }

.workspace {
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(380px, 520px) 1fr;
}

.control-panel {
  min-height: 0;
  padding: 34px 38px 48px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.panel-heading { margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font: 700 11px/1.2 ui-monospace, SFMono-Regular, monospace; text-transform: uppercase; letter-spacing: 0.14em; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 38px); line-height: 1.08; letter-spacing: -0.045em; }

fieldset {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 24px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

legend { padding: 0 12px 0 0; color: var(--blueprint); font: 700 12px/1 ui-monospace, monospace; text-transform: uppercase; letter-spacing: 0.1em; }
label { margin-top: 6px; font-size: 13px; font-weight: 700; }
label small { color: var(--muted); font-weight: 500; }
input {
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #c7c8c0;
  border-radius: 2px;
  color: var(--ink);
  background: white;
}
input:focus { outline: 2px solid color-mix(in srgb, var(--blueprint) 40%, transparent); border-color: var(--blueprint); }
.wide { grid-column: 1 / -1; }
.subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 10px; }
.toggle { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.toggle input { width: 17px; height: 17px; }

.actions { display: flex; flex-wrap: wrap; gap: 9px; }
button {
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 11px 16px;
  color: white;
  background: var(--accent);
  font-weight: 750;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { cursor: wait; opacity: 0.6; }
button.secondary { color: var(--ink); background: transparent; border-color: #aeb1aa; }
button.secondary:hover { background: #eeece4; }
.error { min-height: 20px; color: #a12816; font-size: 13px; }

.viewer-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background-color: #e9ece8;
  background-image: linear-gradient(#d8dedb 1px, transparent 1px), linear-gradient(90deg, #d8dedb 1px, transparent 1px);
  background-size: 28px 28px;
}
#plot { width: 100%; height: 100%; min-height: 0; background: rgba(255,255,255,0.74); }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 30px; }
.empty-state h2 { margin: 18px 0 6px; letter-spacing: -0.03em; }
.empty-state p { max-width: 370px; color: var(--muted); }
.axis-glyph { display: grid; place-items: center; width: 78px; height: 78px; border: 2px solid var(--blueprint); color: var(--blueprint); font: 700 14px ui-monospace, monospace; transform: rotate(45deg); }
.axis-glyph::first-line { transform: rotate(-45deg); }
.busy { position: absolute; right: 20px; bottom: 20px; padding: 9px 12px; color: white; background: var(--blueprint); font: 12px ui-monospace, monospace; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--blueprint); background-image: linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px); background-size: 32px 32px; }
.login-shell { width: min(440px, calc(100% - 32px)); }
.login-card { padding: 40px; background: var(--panel); box-shadow: 14px 14px 0 rgba(10, 26, 32, 0.28); }
.login-card .brand-mark { margin-bottom: 35px; }
.login-card .lede { margin: 13px 0 28px; color: var(--muted); line-height: 1.5; }
.login-card form { display: grid; gap: 10px; }
.login-card button { margin-top: 7px; }
.login-host { margin: 24px 0 0; color: #bdcbc7; text-align: center; font: 12px ui-monospace, monospace; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .workspace { height: auto; min-height: calc(100vh - 64px); grid-template-columns: 1fr; }
  .control-panel { min-height: auto; overflow-y: visible; border-right: 0; }
  .viewer-panel, #plot { min-height: 520px; height: 65vh; }
}

@media (max-width: 520px) {
  .site-header { padding: 0 16px; }
  .control-panel { padding: 28px 20px 40px; }
  fieldset, .subgrid { grid-template-columns: 1fr; }
  fieldset > span { display: none; }
  .wide { grid-column: 1; }
  .session > span { display: none; }
  .login-card { padding: 30px 24px; }
}
