/* Coach. Tokens and base components match dtworkshop.onoffgroup.com. */
:root {
  --orange: #ff6b00;
  --orange-dark: #c45200;
  --orange-soft: #fff4e6;
  --ink: #1a1a1a;
  --ink-2: #4a4a4a;
  --ink-3: #66768c;
  --bg: #faf9f7;
  --card: #ffffff;
  --line: #e6e6e6;
  --line-strong: #cfcfcf;
  --green: #1e7e34;
  --green-soft: #e6f4ea;
  --red: #c5221f;
  --red-soft: #fce8e6;
  --blue-soft: #f4f8fb;
  --coach: #f6f3ff;
  --coach-line: #ddd5fb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(26,26,26,.06), 0 4px 16px rgba(26,26,26,.05);
  --font: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 17px; line-height: 1.5; overflow-x: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--orange-dark); }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: .9rem; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em; padding: .6em 1.1em; min-height: 44px;
  border-radius: 999px; border: 1.5px solid var(--ink); background: var(--ink); color: #fff;
  font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .08s, background .15s;
}
.btn:hover { background: #000; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1a1a1a; }
.btn.primary:hover { background: #ff8326; border-color: #ff8326; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: #fff; border-color: var(--ink); }
.btn.coach-btn { background: var(--coach); color: #4b2fb3; border-color: var(--coach-line); }
.btn.coach-btn:hover { background: #ece6ff; border-color: #b9a8f5; }
.btn.small { min-height: 36px; padding: .35em .9em; font-size: .92rem; }
.btn.link { background: none; border: none; color: var(--orange-dark); padding: .3em .2em; min-height: 36px; text-decoration: underline; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: 1.1rem;
}
.icon-btn:hover { background: var(--orange-soft); color: var(--ink); }

/* Inputs */
.input {
  width: 100%; padding: .65em .85em; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { text-transform: none; }
.input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,107,0,.15); outline: none; }
textarea.input { resize: vertical; line-height: 1.45; min-height: 96px; }
.lbl { display: block; font-weight: 700; margin-bottom: .3em; }
.lbl .opt { font-weight: 400; color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: .93rem; margin: -.1em 0 .55em; }
.field { margin-bottom: 16px; }
.error { color: var(--red); background: var(--red-soft); padding: 10px 12px; border-radius: 8px; margin-top: 12px; }
.success { color: var(--green); background: var(--green-soft); padding: 10px 12px; border-radius: 8px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(250,249,247,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 60px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; flex: none; }
.topbar .brand img { height: 30px; width: auto; }
.topbar .spacer { flex: 1; }
.save-state { font-size: .9rem; color: var(--ink-3); display: inline-flex; align-items: center; gap: .4em; white-space: nowrap; }
.save-state.saved { color: var(--green); }
.save-state.error { color: var(--red); }
.save-state .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Menus (project switcher, account) */
.menu-wrap { position: relative; min-width: 0; }
.menu-btn {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 40px; padding: 6px 12px;
  border: 1.5px solid var(--line-strong); border-radius: 999px; background: #fff; cursor: pointer; font-weight: 700;
}
.menu-btn:hover { border-color: var(--ink); }
.menu-btn .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn .caret { color: var(--ink-3); font-size: .8em; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 240px; max-width: min(340px, calc(100vw - 32px));
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.12); padding: 6px;
}
.menu.right { left: auto; right: 0; }
.menu .item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px;
  border: none; background: none; cursor: pointer; color: var(--ink); text-decoration: none; font-size: .97rem;
}
.menu .item:hover, .menu .item:focus-visible { background: var(--bg); }
.menu .item.on { font-weight: 700; }
.menu .item.on::after { content: "✓"; margin-left: auto; color: var(--orange-dark); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .meta { padding: 8px 12px 4px; color: var(--ink-3); font-size: .85rem; overflow-wrap: anywhere; }

/* Page layout */
.page { max-width: 920px; margin: 0 auto; padding: 28px 20px 96px; }
.page.narrow { max-width: 760px; }
.section { margin-top: 40px; }
.section > h2 { margin-bottom: .2em; }
.section > .sub { color: var(--ink-3); margin-bottom: 16px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); text-decoration: none; font-size: .95rem; margin-bottom: 14px; }
.back:hover { color: var(--ink); text-decoration: underline; }

/* Edit-in-place headings */
.inplace {
  width: 100%; border: 1.5px solid transparent; border-radius: var(--radius-sm); background: transparent; padding: 4px 8px; margin-left: -9px;
  transition: border-color .15s, background .15s; resize: none; overflow: hidden; display: block;
}
.inplace:hover { border-color: var(--line); background: #fff; }
.inplace:focus { border-color: var(--orange); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(255,107,0,.15); }
.inplace.title { font-size: 1.9rem; font-weight: 700; line-height: 1.2; }
.inplace.challenge { font-size: 1.05rem; color: var(--ink-2); line-height: 1.5; min-height: 2.2em; }
.inplace::placeholder { color: var(--ink-3); font-weight: 400; }

/* Landing */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.landing .panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 32px; max-width: 480px; width: 100%; }
.landing .logo { height: 42px; width: auto; margin-bottom: 22px; }
.landing h1 { font-size: 2rem; }
.landing .lead { color: var(--ink-2); font-size: 1.05rem; margin-bottom: 22px; }
.landing .btn { width: 100%; }
.landing .fine { color: var(--ink-3); font-size: .88rem; margin-top: 16px; }
.dev-link { margin-top: 14px; padding: 12px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); font-size: .9rem; }

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

.mlink {
  display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px; margin: 0 -4px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: .93rem; line-height: 1.3;
}
.mlink:hover { background: var(--orange-soft); }
.mlink .pip { width: 12px; height: 12px; margin-top: 3px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.mlink.started .pip { border-color: var(--orange); background: linear-gradient(90deg, var(--orange) 50%, transparent 50%); }
.mlink.done .pip { border-color: var(--green); background: var(--green); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-3); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .pip { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-strong); }
.legend .started .pip { border-color: var(--orange); background: linear-gradient(90deg, var(--orange) 50%, transparent 50%); }
.legend .done .pip { border-color: var(--green); background: var(--green); }

/* Method page */
.method-head .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.tag { display: inline-flex; align-items: center; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--orange-soft); color: var(--orange-dark); }
.tag.plain { background: #eef0f3; color: var(--ink-2); font-weight: 400; }
.tag.done { background: var(--green-soft); color: var(--green); }
.method-head .what { font-size: 1.12rem; color: var(--ink); max-width: 65ch; }
.method-head .when { color: var(--ink-2); max-width: 65ch; }
.tips { margin-top: 14px; background: var(--blue-soft); border-radius: var(--radius); padding: 12px 16px; }
.tips summary { cursor: pointer; font-weight: 700; }
.tips ul { margin: 10px 0 2px; padding-left: 1.2em; color: var(--ink-2); }
.tips li { margin-bottom: .3em; }

.steps { display: flex; flex-direction: column; gap: 18px; margin-top: 28px; }
.step { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.step-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.step-title .num { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: .85rem; font-weight: 700; display: inline-grid; place-items: center; flex: none; transform: translateY(2px); }
.step-title h2 { font-size: 1.2rem; margin: 0; }
.step .prompt { color: var(--ink-2); margin: 0 0 12px 36px; }
.step .answer { margin-left: 36px; }
.step-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 0 36px; }
.step-actions .why { font-size: .88rem; color: var(--ink-3); }

/* List editor */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-row { display: flex; align-items: center; gap: 6px; }
.list-row .bullet { width: 1.4em; text-align: center; color: var(--ink-3); flex: none; }
.list-row .input { flex: 1; min-width: 0; min-height: 40px; padding: .45em .7em; }
.list-row .del { opacity: 0; }
.list-row:hover .del, .list-row:focus-within .del { opacity: 1; }
.list-row.phantom .input { border-style: dashed; background: transparent; }
.list-row.phantom .del { visibility: hidden; }

/* Coach threads */
.thread { margin: 14px 0 0 36px; display: flex; flex-direction: column; gap: 10px; }
.thread:empty { display: none; }
.msg { border-radius: var(--radius); padding: 10px 14px; max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: #f0efec; max-width: 85%; }
.msg.user.ask { background: none; padding: 0 2px; color: var(--ink-3); font-size: .88rem; }
.msg.assistant { background: var(--coach); border: 1px solid var(--coach-line); }
.msg.assistant .who { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #4b2fb3; margin-bottom: 4px; }
.msg.assistant p:last-child, .msg.assistant ul:last-child, .msg.assistant ol:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 .7em; padding-left: 1.3em; }
.msg.error { background: var(--red-soft); color: var(--red); }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #8d7ae0; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea.input { min-height: 44px; height: 44px; resize: none; overflow: hidden; }
.composer .btn { flex: none; }
.thread .composer { margin-top: 2px; }

.ask-coach { margin-top: 28px; background: var(--coach); border: 1.5px solid var(--coach-line); border-radius: var(--radius); padding: 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.ask-coach .body { flex: 1; min-width: 220px; }
.ask-coach h2 { font-size: 1.15rem; margin-bottom: 4px; }
.ask-coach .quota { flex-basis: 100%; margin: 0; }

.done-bar { margin-top: 28px; padding: 20px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.done-bar .body { flex: 1; min-width: 220px; }
.done-bar.is-done { background: var(--green-soft); border-color: #b7dfc2; }
.done-bar .nexts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.quota { font-size: .88rem; color: var(--ink-3); margin-top: 10px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 16px; border-radius: 10px; display: flex; gap: 14px; align-items: center; z-index: 50; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}
.toast button { background: none; border: none; color: var(--orange); font-weight: 700; cursor: pointer; padding: 4px 6px; }

.danger-zone { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line); }
.loading { padding: 80px 20px; text-align: center; color: var(--ink-3); }

/* Admin */
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.admin { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.admin th, table.admin td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.admin th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); background: var(--bg); }
table.admin tr:last-child td { border-bottom: none; }
table.admin td.num, table.admin th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--ink-3); font-size: .88rem; }
.form-grid { display: grid; grid-template-columns: 1fr 200px auto; gap: 10px; align-items: end; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .04em; }
.switch { position: relative; width: 44px; height: 26px; flex: none; border-radius: 999px; border: none; background: var(--line-strong); cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.pill-status { display: inline-flex; gap: 8px; align-items: center; }
.banner { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--orange-soft); color: var(--ink-2); font-size: .93rem; margin-bottom: 8px; }

/* Responsive */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .page { padding: 20px 16px 80px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .brand span { display: none; }
  .save-state .txt { display: none; }
  .inplace.title, h1 { font-size: 1.6rem; }
  .step { padding: 16px; }
  .step .prompt, .step .answer, .step-actions, .thread { margin-left: 0; }
  .list-row .del { opacity: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .landing .panel { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.icon-btn.avatar { background: var(--ink); color: #fff; font-weight: 700; }
.icon-btn.avatar:hover { background: #000; color: #fff; }

/* Project home: chat + worksheets panel */
.project-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: calc(100dvh - 60px); }
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.chat-log { max-width: 760px; margin: 0 auto; padding: 24px 20px 12px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 88%; padding: 11px 15px; border-radius: 16px; overflow-wrap: anywhere; line-height: 1.5; }
.bubble.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 5px; white-space: pre-wrap; }
.bubble.coach { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: var(--shadow); }
.bubble.coach p:last-child, .bubble.coach ul:last-child, .bubble.coach ol:last-child { margin-bottom: 0; }
.bubble.coach ul, .bubble.coach ol { margin: 0 0 .7em; padding-left: 1.3em; }
.bubble.error { align-self: stretch; max-width: none; background: var(--red-soft); color: var(--red); }
.typing-bubble { padding: 12px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 6px; }
.chip {
  border: 1.5px solid var(--line-strong); background: #fff; border-radius: 999px; padding: 8px 14px; min-height: 40px;
  cursor: pointer; font-size: .95rem; text-align: left; color: var(--ink); transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--orange); background: var(--orange-soft); }
.tool-card {
  align-self: flex-start; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 88%;
  font-size: .9rem; color: var(--ink-2); background: var(--green-soft); border: 1px solid #c4e3cd; border-radius: 10px; padding: 7px 12px;
}
.tool-card .ti { width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; display: inline-grid; place-items: center; font-size: .75rem; flex: none; }
.tool-card.bad { background: var(--red-soft); border-color: #f3c3bf; }
.tool-card.bad .ti { background: var(--red); }
.tool-card .tool-link { font-weight: 700; white-space: nowrap; }
.composer-bar { border-top: 1px solid var(--line); background: rgba(250,249,247,.96); padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); }
.composer-bar .composer { max-width: 760px; margin: 0 auto; }
.composer-bar textarea.input { min-height: 48px; height: 48px; max-height: 40vh; overflow-y: auto; border-radius: 24px; padding: .7em 1.1em; }
.composer-bar .btn { min-height: 48px; }
.composer-bar .quota { max-width: 760px; margin: 8px auto 0; }

.side { border-left: 1px solid var(--line); background: #fff; overflow-y: auto; padding: 22px 20px 40px; }
.side .inplace.title { font-size: 1.35rem; }
.side .inplace.challenge { font-size: .97rem; }
.side-h { font-size: 1rem; margin: 26px 0 6px; }
.stage-list { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.stage-row h3 { font-size: .9rem; margin: 0 0 2px; display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.stage-row h3 .n { width: 20px; height: 20px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-dark); font-size: .72rem; display: inline-grid; place-items: center; flex: none; }

.side { display: none; }
.project-layout { grid-template-columns: minmax(0, 1fr); }
.project-layout.panel-open { grid-template-columns: minmax(0, 1fr) 340px; }
.project-layout.panel-open .side { display: block; }
.panel-toggle[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.new-chat span[aria-hidden] { font-size: 1.15em; line-height: 1; }

@media (max-width: 899px) {
  .project-layout, .project-layout.panel-open { grid-template-columns: 1fr; }
  .project-layout.panel-open .chat { display: none; }
  .panel-toggle[aria-pressed="true"] { background: transparent; color: var(--ink); border-color: var(--line-strong); }
  .side { border-left: none; }
  .chat-log { padding: 16px 16px 10px; }
  .composer-bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .bubble, .tool-card { max-width: 94%; }
}
@media (max-width: 640px) {
  .new-chat { padding: .35em .75em; }
  .new-chat .lbl { display: none; }
  .topbar:has(.panel-toggle) .brand { display: none; }
  .topbar > .menu-wrap { max-width: 44vw; }
  .topbar { gap: 6px; }
  .panel-toggle { padding: .35em .75em; }
}
