/* CHART MAKR — the room around the page.
   PHASE's noir palette, because the two are the same family, and because a
   dark room is what makes cream paper look like paper. */

:root {
  --ground:   #04060b;
  --shell:    #070a12;
  --panel:    #0b101b;
  --raised:   #121a2a;
  --stroke:   rgba(125, 165, 220, 0.22);
  --strong:   rgba(120, 195, 255, 0.42);

  --cyan:     #39d8ff;
  --blue:     #3478ff;
  --violet:   #8b5cff;
  --violet-b: #a584ff;
  --gold:     #ffd166;
  --mint:     #35e0b3;
  --amber:    #ff9d47;
  --red:      #ff5d75;

  --text:     #f2f6ff;
  --text-2:   #9eabc2;
  --text-3:   #66738a;

  --paper:    #f8f5ed;

  --label: 'DIN Condensed', 'Avenir Next Condensed', 'Oswald', 'Helvetica Neue', sans-serif;
  --body:  'Avenir Next', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }

/* ------------------------------------------------------------------ shell */

#app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100%;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--shell);
  border-bottom: 1px solid var(--stroke);
}

.wordmark {
  font-family: var(--label);
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: 22px;
  white-space: nowrap;
}
.wordmark b { color: var(--gold); font-weight: 700; }
.wordmark span { color: var(--text-3); font-size: 12px; letter-spacing: 0.2em; margin-left: 8px; }
/* PHASE is the house CHART MAKR comes from, so it is set as a quiet tag
   beside the name rather than competing with it. */
.wordmark .by { color: var(--violet-b); }

.topbar .spacer { flex: 1; }

.btn {
  background: var(--raised);
  border: 1px solid var(--stroke);
  border-radius: 7px;
  padding: 11px 18px;
  font-family: var(--label);
  font-size: 15.5px;
  letter-spacing: 0.09em;
  color: var(--text);
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--strong); background: #182337; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #2b6bff, #1d4fd8); border-color: transparent; }
.btn.go { background: linear-gradient(180deg, #2ad3a4, #16a882); border-color: transparent; color: #04120d; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.rec { border-color: var(--red); color: var(--red); }
.btn.rec.armed { background: var(--red); color: #14060a; font-weight: 700; }
.btn.small { padding: 8px 13px; font-size: 13.5px; }

/* An <a> styled as a button needs the bits a <button> gets for free. */
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* ------------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--stroke);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 20px 12px;
  font-family: var(--label);
  font-size: 16px;
  letter-spacing: 0.11em;
  color: var(--text-3);
  white-space: nowrap;
}
.tab:hover { color: var(--text-2); }
.tab[aria-selected='true'] { color: var(--gold); border-bottom-color: var(--gold); }
.tab .dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--red); margin-left: 6px; vertical-align: middle; }

/* ------------------------------------------------------------------- body */

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

.side {
  background: var(--panel);
  border-right: 1px solid var(--stroke);
  overflow-y: auto;
  padding: 18px;
}

.stage {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 16px 30px;
  background:
    radial-gradient(900px 500px at 50% -8%, rgba(139, 92, 255, 0.10), transparent 62%),
    var(--ground);
}

#paper {
  background: var(--paper);
  border-radius: 3px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.62), 0 0 0 1px rgba(0, 0, 0, 0.5);
  max-width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}

/* ------------------------------------------------------------- side panel */

.group { margin-bottom: 20px; }

.group > h3 {
  margin: 0 0 9px;
  font-family: var(--label);
  font-size: 13px;
  letter-spacing: 0.19em;
  color: var(--text-3);
  font-weight: 700;
}

.field { margin-bottom: 8px; }
.field label {
  display: block;
  font-family: var(--label);
  font-size: 12px;
  letter-spacing: 0.17em;
  color: var(--text-3);
  margin-bottom: 4px;
}
.field input, .field select {
  width: 100%;
  background: var(--ground);
  border: 1px solid var(--stroke);
  border-radius: 5px;
  padding: 10px 12px;
  font-size: 16px;   /* 16px stops iOS zooming the page on focus */
}
.field input:focus, .field select:focus { outline: none; border-color: var(--strong); }

.blurb {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text-2);
  margin: 0 0 12px;
}

.hint { font-size: 13.5px; line-height: 1.5; color: var(--text-3); margin: 8px 0 0; }
.hint b { color: var(--text-2); font-weight: 600; }

/* ---------------------------------------------------------------- symbols */

.palette { display: flex; flex-wrap: wrap; gap: 4px; }

.sym {
  background: var(--raised);
  border: 1px solid var(--stroke);
  border-radius: 5px;
  min-width: 38px;
  padding: 9px 10px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.sym:hover:not(:disabled) { border-color: var(--violet-b); color: var(--violet-b); }
.sym.on { background: var(--violet); border-color: var(--violet); color: #fff; }
.sym:disabled { opacity: 0.3; cursor: not-allowed; }
.sym.wide { min-width: 60px; }
.sym.mark { color: var(--amber); }

.selected-bar {
  font-family: var(--label);
  font-size: 13.5px;
  letter-spacing: 0.15em;
  color: var(--gold);
  margin-bottom: 10px;
  min-height: 14px;
}

/* ----------------------------------------------------------------- footer */

.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--shell);
  border-top: 1px solid var(--stroke);
  font-family: var(--label);
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--text-3);
}
.statusbar .spacer { flex: 1; }
.statusbar b { color: var(--text-2); font-weight: 600; }
.statusbar .ok { color: var(--mint); }
.statusbar .warn { color: var(--amber); }

.pager { display: flex; align-items: center; gap: 7px; }

/* ------------------------------------------------------------------ modal */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 8, 0.86);
  display: grid;
  place-items: center;
  padding: 22px;
  z-index: 60;
  backdrop-filter: blur(6px);
}

.sheet {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 26px;
  max-width: 600px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}
.sheet h2 {
  margin: 0 0 6px;
  font-family: var(--label);
  font-size: 26px;
  letter-spacing: 0.13em;
}
.sheet p { color: var(--text-2); font-size: 16px; line-height: 1.6; }
.sheet .row { display: flex; gap: 9px; margin-top: 16px; flex-wrap: wrap; }
.sheet .err { color: var(--red); font-size: 12.5px; min-height: 17px; margin: 6px 0 0; }
.sheet ol { color: var(--text-2); font-size: 15.5px; line-height: 1.7; padding-left: 22px; }
.sheet kbd {
  background: var(--raised); border: 1px solid var(--stroke); border-radius: 4px;
  padding: 2px 7px; font-size: 13.5px; font-family: var(--label); letter-spacing: .08em;
}

/* --------------------------------------------------------------- dropzone */

.dropzone {
  border: 2px dashed var(--stroke);
  border-radius: 12px;
  padding: 34px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  transition: border-color .15s, color .15s, background .15s;
}
.dropzone.hot { border-color: var(--cyan); color: var(--cyan); background: rgba(57, 216, 255, 0.06); }

/* ----------------------------------------------------------------- mobile */

@media (max-width: 860px) {
  /* On a phone the page IS the product, so it comes first and the controls sit
     under it. Leading with a column of text fields buries the chart. */
  /* One scrolling column. The sidebar must NOT be its own scroll container
     here: a scrolling box contributes zero height to an auto grid row, so it
     collapsed to a 57pt strip under the chart and every control lived in it. */
  .workspace { display: flex; flex-direction: column; overflow-y: auto; }   /* flex keeps `order`: chart first */
  .stage { order: 1; flex: none; overflow: visible; padding: 12px 8px 8px; }   /* flex:none - a shrinkable stage collapses to a strip */
  .side {
    order: 2;
    flex: none;
    overflow: visible;
    border-right: none;
    border-top: 1px solid var(--stroke);
    max-height: none;
    padding-bottom: 40px;
  }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  #app { grid-template-rows: auto auto 1fr auto; }
  .tab { padding: 14px 16px 12px; font-size: 15px; }
  .btn { padding: 11px 14px; font-size: 14.5px; }
}

@media print {
  .topbar, .tabs, .side, .statusbar, .scrim { display: none !important; }
  #app { display: block; }
  .stage { padding: 0; background: #fff; }
  #paper { box-shadow: none; border-radius: 0; width: 100%; }
}

/* ----------------------------------------------------------- the iOS app */
/* The web view runs edge to edge, so the top bar has to clear the notch and
   the status bar itself. In a browser this class is never set. */
body.native .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
body.native .statusbar { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
body.native .side { padding-bottom: 40px; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%) translateY(20px);
  background: var(--raised); color: var(--text); border: 1px solid var(--strong);
  border-radius: 10px; padding: 12px 18px; font-size: 15px; max-width: min(92vw, 560px);
  box-shadow: 0 14px 40px rgba(0,0,0,.6); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 80; text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------- PLAY IN sheet */
.sheet.playin .field { margin-bottom: 14px; }
.sheet.playin .palette .sym { flex: 1 1 auto; padding: 12px 10px; font-size: 15px; }
.sheet.playin input { font-size: 20px; padding: 12px 14px; }
