:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #1c2330; --muted: #677285; --line: #e3e7ee;
  --accent: #2f5bea; --accent-ink: #ffffff; --ok: #1f8a4c; --warn: #b7791f; --err: #c53030; --info: #2b6cb0;
  --code-bg: #f3f5f8; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --card: #181e27; --ink: #e6e9ef; --muted: #98a2b3; --line: #2a3241;
    --accent: #6b8cff; --accent-ink: #0b0f16; --code-bg: #121820;
  }
  :root:not([data-theme="light"]) .CodeMirror { background: #121820; color: #e6e9ef; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); cursor: pointer; text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 18px; margin: 0 0 8px; } h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { color: var(--ink); font-weight: 700; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.brand small { color: var(--muted); font-weight: 400; }
.account-badge { font-size: 12px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.account-badge.subscription { color: var(--ok); border-color: var(--ok); } .account-badge.api { color: var(--warn); border-color: var(--warn); }
.account-badge.cloud { color: var(--info); border-color: var(--info); } .account-badge.unknown { color: var(--err); border-color: var(--err); }
.logo { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 2px 6px; font-size: 13px; }
main { padding: 16px 20px 40px; max-width: 1600px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; min-width: 0; }
.muted { color: var(--muted); } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
label { display: block; margin: 8px 0; font-weight: 600; font-size: 13px; }
label.inline { display: inline-flex; gap: 4px; font-weight: 400; margin: 0; }
input, textarea, select { width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; font-weight: 400; }
input[type=checkbox] { width: auto; margin: 0; }
textarea { resize: vertical; }
button { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font: inherit; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--err); }
button:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hidden { display: none !important; }
.home { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); gap: 16px; align-items: start; }
.list .item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--code-bg); }
.pill.running { background: #e3ecff; color: var(--info); } .pill.done { background: #dff3e7; color: var(--ok); }
.pill.waiting_user { background: #fff3d6; color: var(--warn); } .pill.error { background: #fde2e2; color: var(--err); }
.pill.rate_limited { background: #efe4ff; color: #6b46c1; } .pill.paused { background: var(--code-bg); color: var(--muted); }
.phead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.pactions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dropdown { position: relative; } .dropdown .menu { display: none; position: absolute; right: 0; top: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; min-width: 200px; z-index: 5; padding: 4px 0; }
.dropdown:hover .menu, .dropdown:focus-within .menu { display: block; } .dropdown .menu a { display: block; padding: 6px 12px; color: var(--ink); } .dropdown .menu a:hover { background: var(--code-bg); }
.stepper { display: flex; list-style: none; padding: 0; margin: 14px 0; gap: 4px; overflow-x: auto; }
.stepper li { flex: 1; min-width: 110px; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--muted); }
.stepper li.done { border-color: var(--ok); color: var(--ok); } .stepper li.current { border-color: var(--accent); color: var(--ink); font-weight: 700; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: #fff8e6; border-color: #f3d38a; color: #7a5310; } .banner.err { background: #fdecec; border-color: #f2b3b3; color: #8a1f1f; }
.banner.info { background: #ebf2ff; border-color: #b9cdf7; color: #1d3f86; } .banner.ok { background: #e8f6ee; border-color: #a9dcbd; color: #155c33; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.grid-progress { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; }
.grid-plan { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
.log { height: 520px; overflow-y: auto; font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--code-bg); border-radius: 8px; padding: 8px; }
.log .ev { padding: 3px 0; border-bottom: 1px dashed var(--line); white-space: pre-wrap; word-break: break-word; }
.log .ev .t { color: var(--muted); margin-right: 6px; } .log .ev.text { color: var(--ink); } .log .ev.tool { color: var(--info); }
.log .ev.tool_result { color: var(--muted); max-height: 4.5em; overflow: hidden; } .log .ev.tool_error, .log .ev.error { color: var(--err); }
.log .ev.orchestrator { color: var(--ok); font-weight: 600; } .log .ev.supervisor { color: #9c4221; font-weight: 600; }
.supervisor-card { border-left: 3px solid #dd6b20; } .log .ev.rate_limit { color: #6b46c1; font-weight: 600; } .log .ev.user { color: var(--warn); font-weight: 600; }
.md { overflow-x: auto; } .md table { border-collapse: collapse; font-size: 13px; } .md td, .md th { border: 1px solid var(--line); padding: 4px 8px; } .md pre { background: var(--code-bg); padding: 8px; border-radius: 6px; overflow-x: auto; }
.md code { background: var(--code-bg); padding: 1px 4px; border-radius: 4px; }
table.simple { width: 100%; border-collapse: collapse; font-size: 13px; } table.simple td, table.simple th { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge { font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--code-bg); white-space: nowrap; }
.badge.done { color: var(--ok); } .badge.running, .badge.implemented, .badge.review { color: var(--info); } .badge.needs_fix, .badge.done_with_issues, .badge.blocked { color: var(--warn); } .badge.error, .badge.interrupted { color: var(--err); }
.editor-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; }
.paper-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.filelist { max-height: 78vh; overflow-y: auto; } .filelist .f { display: block; padding: 3px 4px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; border-radius: 4px; color: var(--ink); word-break: break-all; }
.filelist .f.active, .filelist .f:hover { background: var(--code-bg); }
.editor-card .CodeMirror { height: 70vh; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; margin-top: 8px; }
.pdf-card iframe { width: 100%; height: 74vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.compile-out { max-height: 200px; overflow: auto; background: var(--code-bg); padding: 8px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; }
.messages .msg { padding: 8px 10px; background: var(--code-bg); border-radius: 8px; margin-top: 8px; white-space: pre-wrap; }
.messages .msg small { color: var(--muted); display: block; }
.req-form .grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.kv b { color: var(--muted); font-weight: 600; }
.warnlist li { color: var(--warn); }
details summary { cursor: pointer; color: var(--muted); }
pre.raw { background: var(--code-bg); padding: 8px; border-radius: 6px; font-size: 12px; overflow-x: auto; }
/* Barra fija de "Claude trabajando" */
.working-bar { position: sticky; top: 45px; z-index: 9; height: 4px; overflow: hidden; background: color-mix(in srgb, var(--accent) 15%, transparent); }
.working-bar .bar { position: absolute; top: 0; bottom: 0; width: 35%; border-radius: 4px;
  background: linear-gradient(90deg, transparent, var(--accent), #dd6b20, var(--accent), transparent);
  animation: wb-slide 1.6s ease-in-out infinite; }
@keyframes wb-slide { 0% { left: -35%; } 100% { left: 100%; } }
.working { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--accent); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.dot-live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .working-bar .bar { animation-duration: 4s; } .spinner { animation-duration: 2.5s; } .dot-live { animation: none; }
}
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.settings-card summary { cursor: pointer; }
.model-badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; }
.model-badge.opus { color: #6b46c1; border-color: #b794f4; } .model-badge.sonnet { color: var(--info); } .model-badge.haiku { color: var(--ok); }
@media (max-width: 1100px) { .grid3 { grid-template-columns: minmax(0, 1fr); } }
/* Escribir a Claude en mitad de la ejecución */
.steer-card { border-left: 3px solid var(--accent); }
.steer-form textarea { min-height: 52px; }
/* Botones de copiar */
button.copy { padding: 3px 10px; font-size: 12px; }
button.copy.copied { color: var(--ok); border-color: var(--ok); }
details > button.copy { margin: 6px 0; }
.compile-wrap { position: relative; } .compile-wrap .copy { position: absolute; right: 8px; top: 6px; }
.step-copy { float: right; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 99; max-width: 420px; }
@media (max-width: 1100px) {
  .home, .grid-progress, .grid-plan, .grid2, .editor-layout, .paper-layout { grid-template-columns: minmax(0, 1fr); }
  main { padding: 12px 16px 40px; }
}
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; padding: 24px; }
.login-card .brand { margin-bottom: 14px; }
.login-card button { width: 100%; margin-top: 8px; }
.login-err { color: var(--err); min-height: 1.5em; font-size: 13px; }
.import-btn { display: inline-block; margin: 0; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-weight: 400; font-size: 14px; }
.import-btn:hover { border-color: var(--accent); }
.import-progress { margin: 8px 0 4px; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.progress > div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .2s; }
.progress > div.indeterminate { width: 35% !important; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .progress > div.indeterminate { animation: none; width: 100% !important; opacity: .5; } }
