/* Gofuso Runway - shell, controls and screens */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--acc2); }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------------- top bar ---------------- */

.top {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px; height: 56px; flex: 0 0 auto;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  position: relative; z-index: 60;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; background: var(--grad);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 10px rgba(18, 161, 221, .35); flex: 0 0 auto;
}
.brand-name { font-size: 15px; }
.brand-name small { color: var(--text2); font-weight: 500; }

.top-sep { width: 1px; height: 24px; background: var(--border); }
.spacer { flex: 1 1 auto; }

/* segmented control */
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--text2);
  padding: 5px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--panel3); color: var(--text); }

.btn {
  border: 1px solid var(--border2); background: var(--panel);
  padding: 7px 13px; border-radius: 10px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--panel2); }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); background: var(--grad); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--panel); color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 11px; min-width: 0;
}
.field:focus { outline: 2px solid var(--acc); outline-offset: -1px; }
select.field { padding-right: 26px; }

.search { position: relative; }
.search input { width: 210px; padding-left: 30px; }
.search::before {
  content: ''; position: absolute; left: 10px; top: 50%; width: 13px; height: 13px;
  transform: translateY(-50%); opacity: .5;
  background: currentColor;
  -webkit-mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
}

/* ---------------- source bar ---------------- */

.sources {
  display: flex; align-items: center; gap: 8px; flex: 0 0 auto;
  padding: 8px 14px; background: var(--bg2);
  border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin;
}
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  border: 1px solid var(--border2); background: var(--panel);
  padding: 5px 11px 5px 8px; border-radius: 999px; font-size: 12.5px;
  transition: background .15s, opacity .15s;
}
.chip:hover { background: var(--panel2); }
.chip[aria-pressed="false"] { opacity: .42; }
.chip-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.chip-n { color: var(--text2); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.chip-x { opacity: .5; margin-left: 2px; }
.chip-x:hover { opacity: 1; }

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

.main { flex: 1 1 auto; min-height: 0; position: relative; display: flex; }
.tl-wrap { flex: 1 1 auto; min-width: 0; position: relative; }

.tl { position: absolute; inset: 0; overflow: auto; scrollbar-width: thin; }
.tl-inner { position: relative; width: max-content; min-width: 100%; }

/* header row: axis sticks to top, corner sticks to top-left */
.tl-headrow { display: flex; position: sticky; top: 0; z-index: 30; }
.tl-corner {
  position: sticky; left: 0; z-index: 32; flex: 0 0 var(--lane-w); width: var(--lane-w);
  height: var(--axis-h); background: var(--bg2);
  border-right: 1px solid var(--border2); border-bottom: 1px solid var(--border2);
  display: flex; align-items: flex-end; padding: 0 12px 7px;
}
.tl-corner-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; }

.tl-axis {
  height: var(--axis-h); background: var(--bg2);
  border-bottom: 1px solid var(--border2); position: relative; flex: 0 0 auto;
}
.tl-axis-major, .tl-axis-minor { position: absolute; left: 0; right: 0; }
.tl-axis-major { top: 0; height: 26px; }
.tl-axis-minor { top: 26px; height: 27px; }
.tl-maj {
  position: absolute; top: 0; height: 26px; display: flex; align-items: center;
  padding-left: 9px; font-size: 11.5px; font-weight: 600; color: var(--text2);
  border-left: 1px solid var(--border2); white-space: nowrap; overflow: hidden;
}
.tl-min {
  position: absolute; top: 0; height: 27px; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; color: var(--text3); border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums; overflow: hidden;
}
.tl-min.is-weekend { color: var(--text3); background: rgba(255,255,255,.05); }
.tl-min span, .tl-maj span { pointer-events: none; }

/* background grid + today line */
.tl-bg {
  position: absolute; left: var(--lane-w); top: var(--axis-h); bottom: 0;
  z-index: 0; pointer-events: none;
}
.tl-grid { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); opacity: .55; }
.tl-grid.is-weekend { background: rgba(255,255,255,.055); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--today); opacity: .85; z-index: 3; }
.tl-today span {
  position: absolute; top: 2px; left: 4px; font-size: 10px; font-weight: 700;
  color: var(--today); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
}

/* rows */
.tl-rows { position: relative; z-index: 1; padding-bottom: 60px; }
.tl-row { display: flex; align-items: stretch; min-height: var(--row-h); }
.tl-lane {
  position: sticky; left: 0; z-index: 20; flex: 0 0 var(--lane-w); width: var(--lane-w);
  background: var(--bg); border-right: 1px solid var(--border2);
  display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: var(--row-h);
}
.tl-lane-head { background: var(--bg2); }
.tl-grouprow { min-height: 30px; }
.tl-grouprow .tl-lane { border-top: 1px solid var(--border); }
.tl-track-head { border-top: 1px solid var(--border); background: var(--panel); }
.tl-lane-label {
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto;
}
.tl-count {
  font-size: 10.5px; color: var(--text3); background: var(--panel2);
  padding: 1px 6px; border-radius: 999px; font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
.tl-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.tl-track { position: relative; flex: 0 0 auto; min-height: var(--row-h); }

/* bars */
.tl-bar {
  position: absolute; top: 4px; height: calc(var(--row-h) - 12px);
  background: var(--c); border-radius: var(--bar-radius);
  display: flex; align-items: center; overflow: hidden;
  cursor: pointer; box-shadow: var(--shadow-sm);
  transition: filter .12s, transform .12s;
}
.tl-bar:hover { filter: brightness(1.14); transform: translateY(-1px); }
.tl-prog { position: absolute; inset: 0 auto 0 0; background: rgba(0, 0, 0, .28); }
[data-theme="light"] .tl-prog { background: rgba(255, 255, 255, .38); }
.tl-bar-label {
  position: relative; z-index: 1; padding: 0 8px; font-size: 11.5px; font-weight: 600;
  color: #06121c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .18);
}
[data-theme="light"] .tl-bar-label { color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); }

.tl-ms { position: absolute; top: 4px; height: calc(var(--row-h) - 12px); display: flex; align-items: center; cursor: pointer; }
.tl-ms i {
  width: 13px; height: 13px; background: var(--c); transform: rotate(45deg);
  border-radius: 2px; flex: 0 0 auto; margin-left: -6px; box-shadow: var(--shadow-sm);
}
.tl-ms:hover i { filter: brightness(1.2); }
.tl-ms-label {
  margin-left: 8px; font-size: 11.5px; color: var(--text2); white-space: nowrap;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}

.tl-empty { padding: 40px; color: var(--text3); text-align: center; }

/* tooltip */
.tl-tip {
  position: fixed; z-index: 200; display: none; pointer-events: none;
  background: var(--bg2); border: 1px solid var(--border2); border-radius: 10px;
  padding: 8px 11px; box-shadow: var(--shadow); max-width: 380px;
}
.tl-tip strong { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 3px; }
.tl-tip em { display: block; font-size: 11.5px; color: var(--text2); font-style: normal; }

/* ---------------- detail drawer ---------------- */

.drawer {
  flex: 0 0 340px; width: 340px; background: var(--bg2);
  border-left: 1px solid var(--border); overflow-y: auto; padding: 18px;
}
.drawer h3 { margin: 0 0 4px; font-size: 15.5px; line-height: 1.3; }
.drawer .ref { font-family: var(--mono); font-size: 11px; color: var(--text3); }
.drawer dl { margin: 16px 0 0; display: grid; grid-template-columns: 96px 1fr; gap: 9px 12px; }
.drawer dt { color: var(--text3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.drawer dd { margin: 0; font-size: 13px; }
.drawer-close { position: absolute; top: 10px; right: 12px; }

/* ---------------- screens ---------------- */

.screen {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 80; padding: 24px; overflow-y: auto;
}
.card {
  width: 100%; max-width: 460px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
}
.card.wide { max-width: 760px; }
.card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card p.sub { margin: 0 0 20px; color: var(--text2); font-size: 13.5px; }
.card label { display: block; font-size: 12px; color: var(--text2); margin: 12px 0 5px; }
.card .field { width: 100%; }
.card .actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }

.notice { padding: 10px 13px; border-radius: 10px; font-size: 12.5px; margin-top: 14px; }
.notice-err { background: rgba(248, 113, 113, .12); color: var(--red); border: 1px solid rgba(248, 113, 113, .3); }
.notice-ok { background: rgba(52, 211, 153, .1); color: var(--green); border: 1px solid rgba(52, 211, 153, .28); }
.notice-info { background: var(--acc-soft); color: var(--acc2); border: 1px solid rgba(18, 161, 221, .3); }

/* wizard */
.pick-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; }
.pick {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 13px; background: transparent; border: 0; border-bottom: 1px solid var(--border);
}
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--panel); }
.pick-main { flex: 1 1 auto; min-width: 0; }
.pick-title { font-size: 13.5px; font-weight: 550; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub { font-size: 11.5px; color: var(--text3); }
.pick-badge { font-size: 11px; color: var(--text3); background: var(--panel2); padding: 2px 7px; border-radius: 999px; }

.steps { display: flex; gap: 6px; margin-bottom: 18px; font-size: 11.5px; color: var(--text3); align-items: center; }
.steps b { color: var(--text); font-weight: 600; }

.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 6px; }
@media (max-width: 620px) { .map-grid { grid-template-columns: 1fr; } }

.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--border2); border-top-color: var(--acc2);
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text2); }

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

@media (max-width: 760px) {
  :root { --lane-w: 148px; }
  .top { gap: 8px; padding: 0 10px; }
  .brand-name small, .top-sep, .search input { display: none; }
  .search { display: none; }
  .drawer { position: absolute; inset: 0 0 0 auto; width: min(340px, 92vw); z-index: 90; box-shadow: var(--shadow); }
  .sources { padding: 6px 10px; }
}

/* ---- record rows: name in the fixed left column, bar carries dates ---- */

.tl-lane-item { justify-content: space-between; gap: 6px; }
.tl-item-title {
  font-size: 12.5px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0;
}
.tl-item-pct {
  font-size: 10.5px; color: var(--text3); font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
.tl-item-multi { font-size: 11.5px; color: var(--text3); font-style: italic; }
.tl-row:hover .tl-lane-item { background: var(--panel); }
.tl-row:hover .tl-item-title { color: var(--acc2); }

/* label hung off the end of a bar too narrow to contain it */
.tl-bar.is-narrow { overflow: visible; }
.tl-bar-out {
  position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  margin-left: 7px; font-size: 11.5px; color: var(--text2);
  white-space: nowrap; pointer-events: none; max-width: 320px;
  overflow: hidden; text-overflow: ellipsis;
}

/* today marker: readable chip that does not collide with the first lane */
.tl-today span {
  background: var(--today); color: #fff; padding: 1px 5px 2px;
  border-radius: 0 4px 4px 0; top: 0; left: 2px; letter-spacing: .06em;
}

[data-theme="light"] .tl-grid.is-weekend { background: rgba(15,20,40,.05); }
[data-theme="light"] .tl-min.is-weekend { background: rgba(15,20,40,.045); }
