/* BioStudio AI — window chrome (Windows 11) */

.window {
  position: absolute;
  min-width: var(--window-min-w);
  min-height: var(--window-min-h);
  display: flex;
  flex-direction: column;
  background: var(--win-bg);
  border: 1px solid var(--win-border);
  border-radius: 8px;
  box-shadow: var(--win-shadow);
  overflow: hidden;
  transform-origin: center;
  animation: window-pop 0.16s ease;
  color: var(--ink);
}

@keyframes window-pop {
  from { transform: scale(0.97); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.window.dragging { transition: none; user-select: none; will-change: left, top; }
.window.focused { box-shadow: var(--win-shadow-focus); border-color: var(--win-border-focus); }
.window:not(.focused) .window-titlebar { opacity: 0.72; }
.window.minimized { display: none; }
/* Windows that live on another virtual desktop stay mounted but hidden. */
.window.on-other-desktop { display: none !important; }
.window.maximized { border-radius: 0; border-color: transparent; }
.window.snapped { border-radius: 8px; }
.window.drop-target { outline: 2px dashed var(--accent, #2f6bff); outline-offset: -2px; }
.window.drop-target::after {
  content: "Drop to import";
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--accent, #2f6bff); color: #fff; padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; pointer-events: none; z-index: 5; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}

.window.closing { animation: window-close 0.12s ease forwards; }
@keyframes window-close { to { transform: scale(0.97); opacity: 0; } }

.window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--window-titlebar-h);
  padding: 0 0 0 clamp(10px, calc(14px * var(--shell-scale)), 16px);
  background: var(--titlebar-bg);
  border-bottom: 1px solid var(--win-border);
  cursor: default;
  flex: 0 0 auto;
  transition: opacity 0.15s ease;
}

.window-title-text {
  display: flex;
  align-items: center;
  gap: clamp(7px, calc(10px * var(--shell-scale)), 11px);
  font-size: clamp(11.5px, calc(12.5px * var(--shell-scale)), 13px);
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
}
.window-title-icon .icon, .window-title-icon { width: 16px; height: 16px; flex: 0 0 16px; }
.window-title-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.window-controls { display: flex; align-items: stretch; height: 100%; flex-shrink: 0; position: relative; z-index: 6; }

.win-theme-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 100%;
  padding: 0 8px 0 4px;
  flex: none;
}

.win-theme-dot {
  appearance: none;
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  cursor: pointer;
  flex: none;
  user-select: none;
}

.win-theme-dot:hover {
  transform: scale(1.12);
}

.win-theme-dot:focus-visible {
  outline: 2px solid var(--accent, #2f6bff);
  outline-offset: 2px;
}

.win-theme-dot.is-on {
  box-shadow:
    0 0 0 2px var(--titlebar-bg, #fff),
    0 0 0 3.5px var(--ink, #132238);
}

.dark .win-theme-dot,
#os.dark .win-theme-dot {
  border-color: rgba(255, 255, 255, 0.42);
}

.dark .win-theme-dot.is-on,
#os.dark .win-theme-dot.is-on {
  box-shadow:
    0 0 0 2px var(--titlebar-bg, #1b1f27),
    0 0 0 3.5px #f3f4f6;
}

.win-btn {
  width: var(--window-control-w);
  height: var(--window-titlebar-h);
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: background 0.1s ease, color 0.1s ease;
}
.win-btn svg { width: clamp(14px, calc(16px * var(--shell-scale)), 17px); height: clamp(14px, calc(16px * var(--shell-scale)), 17px); }
.win-btn:hover { background: rgba(127, 127, 127, 0.18); }
.win-btn.close:hover { background: #e81123; color: #fff; }

.window-body {
  flex: 1 1 auto;
  overflow: auto;
  background: var(--win-body-bg);
  position: relative;
}

.window-body.has-project-context-bar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.project-context-bar {
  flex: 0 0 auto;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--win-border);
  background: var(--titlebar-bg);
  background: color-mix(in srgb, var(--titlebar-bg) 88%, var(--win-body-bg));
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  /* Stay above app chrome (incl. Graph Studio Simple mode overlay) so project /
     subproject / name controls remain usable in every mode. */
  position: relative;
  z-index: 50;
}

.project-context-sep {
  flex: 0 0 auto;
  width: 1px;
  height: 16px;
  background: var(--win-border);
  margin: 0 2px;
}

.work-status-controls {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.work-status-select {
  height: 23px;
  flex: 0 0 auto;
  border: 1px solid var(--win-border);
  border-radius: 5px;
  padding: 2px 6px;
  background: var(--win-body-bg);
  color: var(--ink);
  font-size: 12px;
  min-width: 108px;
}
.work-status-select:disabled { color: var(--ink-soft); opacity: .72; }
/* A colored left edge encodes the current status at a glance. */
.work-status-select[data-status="in_progress"] { box-shadow: inset 3px 0 0 #2a78d6; }
.work-status-select[data-status="blocked"] { box-shadow: inset 3px 0 0 #d03b3b; }
.work-status-select[data-status="review"] { box-shadow: inset 3px 0 0 #4a3aa7; }
.work-status-select[data-status="done"] { box-shadow: inset 3px 0 0 #0ca30c; }
.work-status-select[data-status="not_started"] { box-shadow: inset 3px 0 0 #98968f; }

.work-status-reopen-reason {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  box-sizing: border-box;
}
.work-status-reopen-confirm {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 12px;
  cursor: pointer;
}
.work-status-reopen-confirm input { margin-top: 2px; }
.work-status-reopen-actor { margin-top: 12px; }
.work-status-reopen-error {
  margin: 10px 0 0;
  color: #b42318;
  font-size: 12px;
  font-weight: 600;
}

.work-status-date {
  height: 23px;
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--win-border);
  border-radius: 5px;
  padding: 2px 6px;
  background: var(--win-body-bg);
  color: var(--ink);
  font-size: 12px;
}
.work-status-date:disabled { color: var(--ink-soft); opacity: .72; }

.work-status-date-wrap {
  position: relative;
  flex: 0 0 auto;
}

.work-status-date-toggle {
  height: 23px;
  flex: 0 0 auto;
  border: 1px solid var(--win-border);
  border-radius: 5px;
  padding: 2px 8px;
  background: var(--win-body-bg);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.work-status-date-toggle:hover {
  background: var(--win-hover-bg, rgba(0, 0, 0, 0.04));
}

.work-status-date-toggle.is-open,
.work-status-date-toggle.is-warn {
  border-color: #d97706;
  background: color-mix(in srgb, #d97706 10%, var(--win-body-bg));
}

.work-status-date-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 12000;
  min-width: 268px;
  padding: 10px 12px;
  border: 1px solid var(--win-border);
  border-radius: 8px;
  background: var(--win-body-bg);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
}

.work-status-timeline {
  margin: 4px 0 10px;
}

.work-status-timeline-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-soft) 18%, var(--win-body-bg));
  overflow: hidden;
}

.work-status-timeline-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2a78d6, #4f9cf5);
}

.work-status-timeline-today {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid var(--win-body-bg);
  transform: translateY(-50%);
  box-shadow: 0 0 0 1px color-mix(in srgb, #f59e0b 55%, transparent);
}

.work-status-timeline-today[hidden] {
  display: none !important;
}

.work-status-timeline-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 10px;
  color: var(--ink-soft);
}

.work-status-timeline-start,
.work-status-timeline-end {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48%;
}

.work-status-date-panel[hidden] {
  display: none !important;
}

.work-status-date-panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.work-status-date-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.work-status-date-row label {
  font-size: 11px;
  color: var(--ink-soft);
}

.work-status-start-date {
  height: 23px;
  width: 100%;
  border: 1px solid var(--win-border);
  border-radius: 5px;
  padding: 2px 6px;
  background: color-mix(in srgb, var(--win-body-bg) 88%, var(--ink-soft));
  color: var(--ink-soft);
  font-size: 12px;
  cursor: not-allowed;
}

.work-status-deadline-hint {
  margin: 0;
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.work-status-deadline-hint.is-warn {
  color: #b45309;
  font-weight: 600;
}

.work-status-deadline-hint.is-urgent {
  color: #c2410c;
}

.work-status-deadline-warn {
  margin: 6px 0 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, #f59e0b 16%, var(--win-body-bg));
  border: 1px solid color-mix(in srgb, #f59e0b 42%, transparent);
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}

.work-status-deadline-warn[hidden] {
  display: none !important;
}

.project-context-label {
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.project-context-select {
  min-width: 140px;
  max-width: 200px;
  height: 23px;
  flex: 0 0 140px;
  border: 1px solid var(--win-border);
  border-radius: 5px;
  padding: 2px 7px;
  background: var(--win-body-bg);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.project-context-select:disabled {
  color: var(--ink-soft);
  opacity: .72;
}

.window-body.has-project-context-bar > .app,
.window-body.has-project-context-bar > .studio,
.window-body.has-project-context-bar > .graph-studio-app {
  /* .studio is `position:absolute; inset:0` by default, which paints over the
     project-context bar and hides it. When the bar is present, flow the app in
     the flex column beneath it instead. */
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.window-body.has-project-context-bar.is-context-gated > .app,
.window-body.has-project-context-bar.is-context-gated > .studio,
.window-body.has-project-context-bar.is-context-gated > .graph-studio-app {
  pointer-events: none;
  user-select: none;
}

.project-context-gate {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 30px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(251, 251, 253, 0.78);
  background: color-mix(in srgb, var(--win-body-bg) 78%, transparent);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.project-context-gate[hidden] {
  display: none !important;
}

.project-context-gate-inner {
  max-width: 360px;
  text-align: center;
  padding: 16px 20px;
  border: 1px solid var(--win-border);
  border-radius: 10px;
  background: var(--win-body-bg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.project-context-gate-inner strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.project-context-gate-msg {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.project-context-load {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 30px;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  background: rgba(251, 251, 253, 0.86);
  background: color-mix(in srgb, var(--win-body-bg) 86%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.project-context-load[hidden] {
  display: none !important;
}

.project-context-load-inner {
  width: min(320px, 100%);
  text-align: center;
  padding: 18px 20px;
  border: 1px solid var(--win-border);
  border-radius: 10px;
  background: var(--win-body-bg);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
}

.project-context-load-inner strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.project-context-load-msg {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.project-context-load-track {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-soft) 18%, transparent);
  overflow: hidden;
}

.project-context-load-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2a78d6, #18b5c5);
  transition: width 0.28s ease;
}

.resize-handle {
  position: absolute;
  z-index: 8;
  touch-action: none;
}
.resize-n, .resize-s { left: 14px; right: 14px; height: 8px; }
.resize-e, .resize-w { top: 14px; bottom: 14px; width: 8px; }
.resize-n { top: -3px; cursor: ns-resize; }
.resize-s { bottom: -3px; cursor: ns-resize; }
.resize-e { right: -3px; cursor: ew-resize; }
.resize-w { left: -3px; cursor: ew-resize; }
.resize-ne, .resize-se, .resize-sw, .resize-nw { width: 16px; height: 16px; }
.resize-ne { top: -3px; right: -3px; cursor: nesw-resize; }
.resize-se { right: -3px; bottom: -3px; cursor: nwse-resize; }
.resize-sw { left: -3px; bottom: -3px; cursor: nesw-resize; }
.resize-nw { top: -3px; left: -3px; cursor: nwse-resize; }
.window.resizing { user-select: none; }
.window.maximized .resize-handle { display: none; }

.app-crash { padding: 18px; color: #d11; font-size: 13px; }
.app-crash pre { margin-top: 8px; white-space: pre-wrap; font-size: 11px; color: var(--ink-soft); }

:root {
  --win-bg: rgba(249, 249, 251, 0.92);
  --win-body-bg: #fbfbfd;
  --win-border: rgba(0, 0, 0, 0.1);
  --win-border-focus: rgba(0, 0, 0, 0.16);
  --titlebar-bg: rgba(245, 246, 249, 0.9);
  --win-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
  --win-shadow-focus: 0 18px 50px rgba(0, 0, 0, 0.32);
}
.dark {
  --win-bg: rgba(32, 32, 38, 0.94);
  --win-body-bg: #1f1f25;
  --win-border: rgba(255, 255, 255, 0.09);
  --win-border-focus: rgba(255, 255, 255, 0.16);
  --titlebar-bg: rgba(40, 40, 47, 0.92);
  --win-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  --win-shadow-focus: 0 18px 50px rgba(0, 0, 0, 0.6);
}
