/* Swype One V2 — the desktop shell. */

/* --- Ambient ground -------------------------------------------------------- */
.wallpaper {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(255,75,36,.06), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(57,194,215,.05), transparent 60%),
    radial-gradient(rgba(236,232,225,.045) 1px, transparent 1.4px);
  background-size: auto, auto, 26px 26px;
  background-position: 0 0, 0 0, center;
}

/* --- Menubar ----------------------------------------------------------------- */
.menubar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; gap: var(--sp-3);
  height: 46px; padding: 0 var(--sp-4);
  background: rgba(19,18,16,.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.menubar-co { font-size: 0.72rem; color: var(--ink-2); letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.menubar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.menubar-clock { font-size: 0.72rem; color: var(--ink-3); }
#thread-state { cursor: pointer; }
.menubar-power {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: 0.9rem; padding: 4px 6px; border-radius: 8px;
  transition: color var(--dur-1), background var(--dur-1);
}
.menubar-power:hover { color: var(--hot); background: var(--hot-soft); }

/* --- Desktop layout -------------------------------------------------------------- */
#desktop {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr 300px; gap: var(--sp-5);
  max-width: 1280px; margin: 0 auto;
  padding: calc(46px + var(--sp-5)) var(--sp-5) 120px;
  min-height: 100vh;
  align-content: start;
  transition: padding var(--dur-3) var(--ease-soft, ease-out);
}
/* When the Thread lives on the right, the desktop makes room for it —
   a dockable companion, not an overlay hiding the widgets. */
@media (min-width: 1100px) {
  body.thread-open #desktop { padding-right: 440px; }
}

/* App icons — the iOS-grade grid */
.desk-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: var(--sp-5) var(--sp-4);
  align-content: start;
}
.desk-icon {
  display: grid; justify-items: center; gap: 8px;
  background: none; border: 0; cursor: pointer; padding: 4px 2px;
  border-radius: 14px;
  transition: transform var(--dur-2) var(--ease-spring);
}
.desk-icon:hover { transform: translateY(-3px); }
.desk-icon:active { transform: scale(.94); }
.desk-icon .tile {
  position: relative;
  width: 60px; height: 60px;
  border-radius: var(--icon-r);
  display: grid; place-items: center;
  font-size: 1.5rem; color: rgba(255,255,255,.95);
  box-shadow: var(--shadow-icon);
  transition: box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-spring);
}
.desk-icon:hover .tile { transform: scale(1.06); }
.desk-icon .label {
  font-size: 0.72rem; font-weight: 500; color: var(--ink-2);
  text-align: center; line-height: 1.2;
  max-width: 88px;
}
.desk-icon .badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 500;
  color: #1a1206;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.desk-icon .badge.needs-you { background: var(--amber); }
.desk-icon .badge.working { background: var(--signal); color: #fff5f2; animation: badge-pulse 1.8s ease-in-out infinite; }
@keyframes badge-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* Ghost icon — create/browse affordances */
.desk-icon.ghost .tile {
  background: transparent;
  border: 1.5px dashed var(--line-3);
  color: var(--ink-3); box-shadow: none;
}
.desk-icon.ghost:hover .tile { border-color: var(--signal); color: var(--signal-deep); }

/* --- Widgets ----------------------------------------------------------------------- */
.desk-widgets { display: grid; gap: var(--sp-4); align-content: start; }
.widget {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 10px 30px rgba(0,0,0,.32);
  padding: var(--sp-4);
  cursor: pointer; text-align: left;
  transition: border-color var(--dur-2), transform var(--dur-2) var(--ease-out);
  width: 100%;
  color: var(--ink);
  font-family: inherit; font-size: inherit;
}
.widget:hover { border-color: var(--line-2); transform: translateY(-2px); }
.widget .w-label {
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-3);
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.w-pulse .w-objective {
  font-size: 0.92rem; font-weight: 600; line-height: 1.3;
  display: block; margin-bottom: var(--sp-3);
}
.w-stats { display: flex; gap: var(--sp-4); }
.w-stat b { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1; }
.w-stat span { font-size: 0.62rem; color: var(--ink-3); font-family: var(--font-mono); letter-spacing: 0.06em; }
.w-stat.attn b { color: var(--amber); }
.w-pulse svg { margin-top: var(--sp-3); }

.w-approval strong { font-size: 0.88rem; display: block; margin-bottom: 4px; }
.w-approval .w-ev { font-family: var(--font-mono); font-size: 0.62rem; color: var(--ink-3); display: block; margin-bottom: var(--sp-3); }
.w-approval .w-actions { display: flex; gap: var(--sp-2); }

.w-today ul { list-style: none; padding: 0; display: grid; gap: 8px; }
.w-today li { display: flex; gap: 10px; align-items: baseline; font-size: 0.8rem; }
.w-today .t { font-family: var(--font-mono); font-size: 0.66rem; color: var(--signal-deep); min-width: 44px; }

/* --- Windows ------------------------------------------------------------------------- */
#windows { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
#windows > * { pointer-events: auto; }
.window {
  position: absolute;
  display: grid; grid-template-rows: auto 1fr;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r-win);
  box-shadow: var(--shadow-win);
  overflow: hidden;
  min-width: 340px; min-height: 260px;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.window.focused { border-color: var(--line-3);
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset,
              0 34px 90px rgba(0,0,0,.7), 0 6px 22px rgba(0,0,0,.5); }
.window:not(.focused) { box-shadow: 0 1px 0 rgba(255,255,255,.04) inset,
              0 14px 40px rgba(0,0,0,.42), 0 3px 12px rgba(0,0,0,.32); }
.window:not(.focused) .win-bar { opacity: .82; }
.window.dragging { transition: none; box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 40px 110px rgba(0,0,0,.7); }
.window.minimized { opacity: 0; transform: translateY(30px) scale(.92); pointer-events: none; }
.window.closing { opacity: 0; transform: scale(.96); }
.appear-win { animation: win-in var(--dur-3) var(--ease-spring) both; }
@keyframes win-in {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.win-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 9px 12px;
  background: var(--deck-2);
  border-bottom: 1px solid var(--line);
  cursor: grab; user-select: none; touch-action: none;
}
.win-bar:active { cursor: grabbing; }
.window.maximized .win-bar { cursor: default; }
.win-icon { display: inline-flex; }
.win-icon .tile { width: 20px; height: 20px; border-radius: 6px; font-size: 0.62rem; }
.win-title { font-weight: 600; font-size: 0.85rem; }
.win-source { font-size: 0.62rem; color: var(--ink-3); letter-spacing: 0.06em; }
.win-controls { margin-left: auto; display: flex; gap: 6px; }
.win-btn {
  width: 26px; height: 26px; border-radius: 8px;
  border: 1px solid transparent; background: transparent;
  color: var(--ink-2); font-size: 0.85rem; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1);
}
.win-btn:hover { background: var(--panel-3); color: var(--ink); border-color: var(--line-2); }
.win-btn.close:hover { background: var(--hot-soft); color: var(--hot); }

.win-body { overflow-y: auto; padding: var(--sp-4); }
.win-resize {
  position: absolute; right: 0; bottom: 0;
  width: 22px; height: 22px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--line-3) 50%, var(--line-3) 55%, transparent 55%, transparent 65%, var(--line-3) 65%, var(--line-3) 70%, transparent 70%);
  border-bottom-right-radius: var(--r-win);
  touch-action: none;
}
.window.maximized .win-resize { display: none; }

/* --- App window content (the common frame) -------------------------------------------- */
.app-search { margin-bottom: var(--sp-4); }
.app-section-label {
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-3); margin: var(--sp-4) 0 var(--sp-2);
}
.queue { display: grid; gap: 6px; }
.queue-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-2);
  background: var(--deck-2);
  font-size: var(--fs-small);
  transition: border-color var(--dur-1), background var(--dur-1);
}
.queue-item:hover { border-color: var(--line-2); background: var(--panel-2); }
.queue-item .meta { color: var(--ink-3); font-size: 0.66rem; font-family: var(--font-mono); }

.t-card {
  border: 1px solid var(--line-2); border-radius: var(--r-2);
  background: var(--deck-2); padding: var(--sp-3);
  display: grid; gap: var(--sp-2); font-size: var(--fs-small);
}
.t-card .stages { list-style: none; padding: 0; display: grid; gap: 4px; }
.t-card .stages li { display: flex; gap: var(--sp-2); align-items: center; font-size: var(--fs-micro); color: var(--ink-3); }
.t-card .stages li.done { color: var(--go-deep); }
.t-card .stages li.now { color: var(--signal-deep); font-weight: 600; }
.t-card .stages li::before { content: "○"; }
.t-card .stages li.done::before { content: "●"; color: var(--go); }
.t-card .stages li.now::before { content: "◐"; color: var(--signal); }

.approval-card { border-color: rgba(255,176,32,.4); }
.approval-facts { display: grid; grid-template-columns: 92px 1fr; gap: 6px var(--sp-3); margin: var(--sp-2) 0; }
.approval-facts dt { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); padding-top: 2px; }
.approval-facts dd { font-size: var(--fs-small); }

.app-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--deck-2); color: var(--ink-2);
  font-size: var(--fs-small); font-weight: 500; cursor: pointer;
  transition: border-color var(--dur-1), color var(--dur-1), background var(--dur-1);
}
.chip:hover { border-color: var(--signal); color: var(--ink); background: var(--panel-2); }

.activity { list-style: none; padding: 0; display: grid; gap: 6px; font-size: var(--fs-small); color: var(--ink-2); }
.activity li { padding-left: 1em; position: relative; }
.activity li::before { content: "·"; position: absolute; left: 0.25em; color: var(--signal); font-weight: 800; }

/* --- The Thread window ------------------------------------------------------------------ */
.thread-log { display: grid; gap: var(--sp-3); align-content: start; padding-bottom: var(--sp-2); }
.thread-compose {
  display: flex; gap: var(--sp-2);
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.thread-compose input {
  flex: 1; min-width: 0;
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--deck-2); padding: 0.55rem 0.9rem; font-size: var(--fs-small);
}
.thread-compose input:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }

/* --- Pulse trace window content ------------------------------------------------------------ */
.trace-group { margin-bottom: var(--sp-4); }
.trace-group > h3 {
  font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px;
}
.trace-item {
  display: flex; gap: var(--sp-3); align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--line);
  font-size: var(--fs-small);
}
.trace-item .pill { flex-shrink: 0; }
.trace-item .micro { white-space: nowrap; }
.trace-objective { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--sp-4); line-height: 1.35; }

/* --- Dock -------------------------------------------------------------------------------------- */
.dock {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 150;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(30,28,25,.82);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.05) inset;
}
.dock-item {
  position: relative;
  width: 46px; height: 46px;
  border: 0; background: transparent; cursor: pointer;
  border-radius: 13px;
  display: grid; place-items: center;
  transition: transform var(--dur-2) var(--ease-spring), background var(--dur-2);
}
.dock-item:hover { transform: translateY(-5px) scale(1.08); background: var(--panel-2); }
.dock-item .tile {
  width: 38px; height: 38px; border-radius: var(--icon-r);
  display: grid; place-items: center;
  font-size: 1.05rem; color: rgba(255,255,255,.95);
  box-shadow: var(--shadow-icon);
}
.dock-item .run-dot {
  position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--go);
}
.dock-item .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--panel-3); border: 1px solid var(--line-2);
  padding: 3px 9px; border-radius: 7px;
  font-size: 0.66rem; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-1), transform var(--dur-1);
}
.dock-item:hover .tip { opacity: 1; transform: translateX(-50%) translateY(0); }
.dock-sep { width: 1px; height: 34px; background: var(--line-2); margin: 0 4px; }
.dock-state {
  position: absolute; top: 2px; right: 2px;
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid #1e1c19;
}
.dock-state.ready { background: var(--go); }
.dock-state.working { background: var(--signal); animation: badge-pulse 1.6s infinite; }
.dock-state.needs-you { background: var(--amber); animation: badge-pulse 2.2s infinite; }
.dock-state.paused { background: var(--ink-3); }
.dock-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 0.58rem; font-weight: 500;
  color: #1a1206;
  border: 2px solid #1e1c19;
}
.dock-badge.needs-you { background: var(--amber); }
.dock-badge.working { background: var(--signal); color: #fff5f2; }

/* --- Command palette ---------------------------------------------------------------------------- */
.palette { display: grid; gap: var(--sp-3); }
.palette-list { display: grid; gap: 4px; max-height: 320px; overflow-y: auto; }
.palette-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; cursor: pointer; text-align: left;
  color: var(--ink); font-size: var(--fs-small);
}
.palette-item:hover, .palette-item.sel { background: var(--panel-2); border-color: var(--line-2); }
.palette-item .tile { width: 26px; height: 26px; border-radius: 8px; font-size: 0.72rem;
  display: grid; place-items: center; color: #fff; }
.palette-item .mono { margin-left: auto; font-size: 0.6rem; color: var(--ink-3); }

/* --- Responsive ----------------------------------------------------------------------------------- */
@media (max-width: 900px) {
  #desktop { grid-template-columns: 1fr; }
  .desk-widgets { grid-row: 1; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); display: grid; }
}
@media (max-width: 760px) {
  .window { inset: 46px 0 0 0 !important; width: 100vw !important; height: auto !important;
    min-width: 0; border-radius: 16px 16px 0 0; }
  .win-resize { display: none; }
  .menubar-clock { display: none; }
  .menubar-co { display: none; }
  .menubar .wordmark { display: none; }
  .desk-icons { grid-template-columns: repeat(4, 1fr); gap: var(--sp-4) var(--sp-2); }
  .dock { max-width: calc(100vw - 20px); overflow-x: auto; }
}
