/* On Easy Desk — three panes on top of member.css tokens.
   Desktop: 26% OS · 41% shell · 33% course. Phone: course on top, chat below, OS as a tab. */
:root { --dk-head: 3.5rem; --dk-tabs: 2.6rem; }

body.desk { overflow: hidden; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
body.desk:before { display: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.dk-header { flex: none; }
.dk-header-inner {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  min-height: var(--dk-head); padding: 0.5rem clamp(0.75rem, 2vw, 1.25rem);
}
.dk-now { margin: 0; flex: 1 1 12rem; min-width: 0; color: var(--dim); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk-header-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
#hdr-key[data-state="set"] { color: #8ee0c0; border-color: #3ddc9744; background: #3ddc9714; }
#hdr-key[data-state="none"] { color: #ffb0c0; border-color: #ff4b8a44; background: #ff4b8a14; }

.btn.dk-small { min-height: 2.15rem; padding: 0.35rem 0.85rem; font-size: 0.86rem; }

.dk-tabs { display: none; gap: 0.4rem; padding: 0 0.75rem 0.5rem; }
.dk-tab { flex: 1; border-radius: var(--pill); border: 1px solid var(--rule); background: var(--glass); color: var(--dim); font: inherit; font-size: 0.86rem; font-weight: 600; min-height: 2.1rem; cursor: pointer; }
.dk-tab[aria-pressed="true"] { color: var(--ink); border-color: var(--rim-hot); }

.dk-grid {
  flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: 26fr 41fr 33fr; gap: 0;
}
.dk-pane {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  padding: 0.85rem clamp(0.75rem, 1.5vw, 1.1rem); border-left: 1px solid var(--rule); overflow: hidden;
}
.dk-pane:first-child { border-left: 0; }
.dk-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.dk-pane-head h2, .dk-pane-head h3 { margin: 0; font-size: 0.95rem; letter-spacing: -0.01em; }
.dk-pane-head.dk-sub h3 { font-size: 0.82rem; color: var(--dim); font-weight: 600; }
.dk-hint { color: var(--dim); font-size: 0.82rem; margin: 0 0 0.5rem; line-height: 1.45; }
.dk-row { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; margin: 0.35rem 0; }

/* LEFT — files + editor */
.dk-files { list-style: none; margin: 0.25rem 0; padding: 0; display: grid; gap: 0.25rem; max-height: 30%; overflow: auto; }
.dk-files li button {
  width: 100%; text-align: left; font: inherit; font-size: 0.9rem; color: var(--ink); cursor: pointer;
  background: var(--glass); border: 1px solid var(--rule); border-radius: 0.7rem; padding: 0.45rem 0.7rem;
}
.dk-files li button[aria-current="true"] { border-color: var(--rim-hot); }
.dk-editor { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.dk-editor-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; font-size: 0.9rem; }
#editor-text, #prompt {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--rule);
  border-radius: 0.85rem; padding: 0.7rem 0.85rem; line-height: 1.5; resize: none;
}
#editor-text { flex: 1 1 auto; min-height: 10rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.84rem; }

/* CENTRE — launcher, chat, cards */
.dk-launcher { padding: 1rem 1.1rem; margin-top: 0.25rem; }
.dk-launcher .kicker { margin: 0 0 0.35rem; }
.dk-launch-grid { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); margin: 0.6rem 0; }
.dk-launch {
  display: flex; flex-direction: column; gap: 0.2rem; text-decoration: none; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 0.9rem; padding: 0.7rem 0.8rem; background: var(--panel);
}
.dk-launch:hover, .dk-launch:focus-visible { border-color: var(--rim-hot); color: var(--ink); }
.dk-launch span { color: var(--dim); font-size: 0.8rem; line-height: 1.35; }

.dk-chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.dk-nokey { padding: 1rem 1.1rem; margin-bottom: 0.6rem; }
.dk-nokey p { margin: 0 0 0.5rem; font-size: 0.95rem; }
.dk-context { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.dk-ctx { font-size: 0.74rem; border: 1px solid var(--rule); border-radius: var(--pill); padding: 0.2rem 0.6rem; color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-ctx b { color: var(--ink); font-weight: 600; }
.dk-thread { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 0.6rem; padding: 0.25rem 0.1rem; }
.dk-msg { max-width: 92%; border-radius: 1rem; padding: 0.65rem 0.9rem; font-size: 0.95rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.dk-msg.is-user { align-self: flex-end; background: #7c5cff26; border: 1px solid #7c5cff55; }
.dk-msg.is-model { align-self: flex-start; background: var(--panel); border: 1px solid var(--rule); }
.dk-msg.is-error { align-self: stretch; border: 1px solid #ff4b8a55; background: #ff4b8a12; color: #ffd0da; }
.dk-msg.is-streaming:after { content: "▍"; color: var(--accent); }
.dk-msg.is-waiting {
  display: inline-flex; align-items: center; gap: 0.55rem;
  max-width: max-content; width: auto;
  background: var(--panel-2);
  border: 1px solid #f4f4f728;
  border-radius: 999px; padding: 0.48rem 0.95rem 0.48rem 0.72rem;
  font-size: 0.92rem; line-height: 1.2; color: var(--dim);
  white-space: nowrap;
}
.dk-msg.is-waiting:after { content: none; }
.dk-wait-dots { display: inline-flex; align-items: center; gap: 0.22rem; }
.dk-wait-dots i {
  width: 0.38rem; height: 0.38rem; border-radius: 50%;
  background: currentColor; opacity: 0.28;
}
.dk-wait-line { color: var(--ink); font-weight: 500; letter-spacing: -0.01em; }
@media (prefers-reduced-motion: no-preference) {
  .dk-msg.is-streaming:after { animation: dk-breath 1.8s ease-in-out infinite; }
  @keyframes dk-breath { 0%, 100% { opacity: 0.28; } 50% { opacity: 1; } }
  .dk-wait-dots i { animation: dk-wait-dot 1.7s ease-in-out infinite; }
  .dk-wait-dots i:nth-child(2) { animation-delay: 0.28s; }
  @keyframes dk-wait-dot {
    0%, 100% { opacity: 0.2; transform: scale(0.84); }
    50% { opacity: 0.92; transform: scale(1); }
  }
}
.dk-compose { flex: none; margin-top: 0.5rem; }

.dk-card { padding: 0.7rem 0.85rem; align-self: stretch; }
.dk-connect { border-color: #4cc9f055; background: linear-gradient(135deg, #4cc9f014, transparent 60%), var(--panel); }
.dk-connect-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.45rem; }
.dk-connect-mark { width: 2.2rem; height: 2.2rem; border-radius: 0.7rem; background: #4cc9f0; color: #08080b; display: grid; place-items: center; font-weight: 800; font-size: 1rem; flex: none; }
.dk-connect-titles { flex: 1; min-width: 0; }
.dk-connect-titles .kicker { margin: 0; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.dk-connect-name { margin: 0; font-size: 1.05rem; line-height: 1.2; }
.dk-connect-why { margin: 0 0 0.35rem; font-size: 0.92rem; }
.dk-connect-keep { margin: 0 0 0.5rem; }
.dk-connect[data-state="done"] .dk-approve, .dk-connect[data-state="done"] .dk-hold, .dk-connect[data-state="done"] .dk-signed,
.dk-connect[data-state="held"] .dk-approve, .dk-connect[data-state="held"] .dk-signed, .dk-connect[data-state="held"] .dk-hold { display: none; }
.dk-connect[data-state="waiting"] .dk-approve { display: none; }
.dk-card-head { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.dk-card-summary { margin: 0 0 0.35rem; font-size: 0.92rem; }
.dk-card-body summary { cursor: pointer; color: var(--dim); font-size: 0.82rem; }
.dk-card-body pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.8rem; max-height: 14rem; overflow: auto; background: var(--panel); border-radius: 0.6rem; padding: 0.5rem 0.65rem; margin: 0.35rem 0 0; }
.dk-card[data-state="done"] .dk-card-state { color: #8ee0c0; border-color: #3ddc9744; }
.dk-card[data-state="held"] .dk-card-state, .dk-card[data-state="invalid"] .dk-card-state { color: #ffb0c0; border-color: #ff4b8a44; }
.dk-card[data-state="done"] .dk-approve, .dk-card[data-state="held"] .dk-approve, .dk-card[data-state="invalid"] .dk-approve,
.dk-card[data-state="done"] .dk-hold, .dk-card[data-state="invalid"] .dk-hold { display: none; }

/* RIGHT — course */
.dk-course-nav { margin: 0; flex-wrap: nowrap; }
.dk-select, #model-select {
  font: inherit; font-size: 0.86rem; color: var(--ink); background: var(--panel); border: 1px solid var(--rule);
  border-radius: 0.7rem; padding: 0.4rem 0.6rem; max-width: 14rem; min-width: 0;
}
.dk-frame { flex: 1 1 auto; min-height: 0; width: 100%; border: 1px solid var(--rule); border-radius: 0.9rem; background: var(--bg); }
.dk-answers { flex: none; max-height: 28%; overflow: auto; margin-top: 0.5rem; }

/* Settings dialog */
.dk-dialog { border: 1px solid var(--rim); padding: 1.1rem 1.25rem; width: min(30rem, 92vw); color: var(--ink); }
.dk-dialog::backdrop { background: #08080bcc; }
.dk-dialog h2 { margin: 0 0 0.3rem; font-size: 1.1rem; }
.dk-fieldset { border: 1px solid var(--rule); border-radius: 0.85rem; padding: 0.6rem 0.85rem; margin: 0 0 0.9rem; display: grid; gap: 0.3rem; }
.dk-fieldset legend { padding: 0 0.3rem; font-size: 0.85rem; font-weight: 600; }
.dk-radio { display: flex; gap: 0.5rem; align-items: center; font-size: 0.92rem; }
.dk-radio.is-off { color: var(--dim); }
.dk-radio em { font-style: normal; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.dk-spend { margin: 0.25rem 0 0.9rem; }
.dk-dialog-actions { margin-top: 0.25rem; }

/* Phone: stacked. Course on top, chat below, OS as its own tab. */
@media (max-width: 959px) {
  body.desk { overflow: auto; height: auto; }
  .dk-tabs { display: flex; }
  .dk-grid { display: flex; flex-direction: column; }
  .dk-pane { border-left: 0; border-top: 1px solid var(--rule); overflow: visible; }
  .dk-course { order: 1; }
  .dk-shell { order: 2; min-height: 60vh; }
  .dk-os { order: 3; }
  .dk-frame { height: 62vh; }
  .dk-thread { max-height: 50vh; }
  .dk-files { max-height: none; }
  #editor-text { min-height: 14rem; }
  body[data-view="work"] .dk-os { display: none; }
  body[data-view="os"] .dk-course, body[data-view="os"] .dk-shell { display: none; }
}
