/* TAIZA design system v2 — fresh light theme with terminal-green accents.
   The terminal component stays intentionally dark as a brand signature. */
:root {
  --bg: #f6f9f8;
  --panel: #ffffff;
  --panel2: #f1f6f4;
  --panel3: #e8f1ee;
  --border: #e3ebe8;
  --border2: #d3e0db;
  --text: #17252f;
  --dim: #5b6d79;
  --dim2: #90a3ab;
  --acc: #0ea672;
  --acc-bright: #10b981;
  --acc-dim: rgba(14, 166, 114, .10);
  --warn: #d97706;
  --err: #dc2626;
  --info: #2563eb;
  --term-bg: #0d1a16;
  --term-line: #8fe3c0;
  --term-tag: #5d7a6e;
  --shadow: 0 10px 34px rgba(23, 37, 47, .08);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans);
  font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(14, 166, 114, .18); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* micro label */
.micro {
  font-family: var(--mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--dim2);
}
.mono { font-family: var(--mono); }

/* heartbeat */
.beat {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--acc); flex: none;
  animation: beat 2.2s ease-in-out infinite;
}
@keyframes beat {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(14,166,114,.35); }
  50% { opacity: .5; box-shadow: 0 0 0 6px rgba(14,166,114,0); }
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border2); border-radius: 9px;
  padding: 9px 16px; font-size: 13px; font-family: var(--sans);
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--acc); color: var(--acc); }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #ffffff; font-weight: 700; box-shadow: 0 4px 14px rgba(14,166,114,.25); }
.btn.primary:hover { background: var(--acc-bright); color: #ffffff; }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--acc); border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

/* inputs */
.input, textarea.input, select.input {
  width: 100%; background: var(--panel); color: var(--text);
  border: 1px solid var(--border2); border-radius: 9px;
  padding: 10px 12px; font-size: 14px; font-family: var(--sans);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(14,166,114,.12); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.6; }
label.field { display: block; margin-bottom: 14px; }
label.field .micro { display: block; margin-bottom: 6px; }

/* cards & panels */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; box-shadow: var(--shadow);
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border2); color: var(--dim);
  background: var(--panel);
}
.pill.running { color: var(--acc); border-color: rgba(14,166,114,.4); background: var(--acc-dim); }
.pill.completed { color: var(--acc); border-color: rgba(14,166,114,.3); }
.pill.failed { color: var(--err); border-color: rgba(220,38,38,.3); background: rgba(220,38,38,.06); }
.pill.stopped { color: var(--warn); border-color: rgba(217,119,6,.35); background: rgba(217,119,6,.07); }
.pill.queued { color: var(--info); }
.pill.level-basic { color: var(--acc); border-color: rgba(14,166,114,.35); }
.pill.level-standard { color: var(--info); border-color: rgba(37,99,235,.3); }
.pill.level-advanced { color: #7c3aed; border-color: rgba(124,58,237,.3); }

/* terminal — stays dark (brand signature) */
.terminal {
  background: var(--term-bg); border: 1px solid #16281f; border-radius: 12px;
  font-family: var(--mono); font-size: 12px; overflow: hidden;
  box-shadow: var(--shadow);
}
.terminal .tbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid #1b2f26;
}
.terminal .tbar .dot { width: 9px; height: 9px; border-radius: 50%; background: #274035; }
.terminal .tbar .dot.g { background: var(--acc-bright); }
.terminal .tbar .micro { color: #557567; }
.terminal .tbody {
  padding: 10px 14px; min-height: 176px; max-height: 300px; overflow-y: auto;
}
.terminal .tline {
  height: 22px; line-height: 22px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--term-line);
}
.terminal .tline .tag { color: var(--term-tag); }
.terminal .cursor::after {
  content: '▊'; color: var(--acc-bright); animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* plan checklist */
.plan-step { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; color: var(--dim); font-size: 13px; }
.plan-step .box {
  flex: none; width: 16px; height: 16px; margin-top: 3px; border-radius: 5px;
  border: 1.5px solid var(--border2); display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--acc); font-family: var(--mono); background: var(--panel);
}
.plan-step.active { color: var(--text); }
.plan-step.active .box { border-color: var(--acc); }
.plan-step.active .box::after { content: '›'; animation: blink 1s steps(1) infinite; }
.plan-step.done { color: var(--dim); }
.plan-step.done .box { border-color: var(--acc); background: var(--acc-dim); }
.plan-step.done .box::after { content: '✓'; }

/* messages */
.msg { display: flex; gap: 12px; margin-bottom: 18px; }
.msg .avatar {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
}
.msg.user .avatar { background: var(--panel2); color: var(--dim); border: 1px solid var(--border2); }
.msg.assistant .avatar { background: var(--acc-dim); color: var(--acc); border: 1px solid rgba(14,166,114,.3); }
.msg .bubble { flex: 1; min-width: 0; padding-top: 4px; white-space: pre-wrap; word-break: break-word; }
.msg.user .bubble { color: var(--text); }
.msg.assistant .bubble { color: #33454f; }

/* artifact chips */
.artifact {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 11px;
  padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 2px 8px rgba(23,37,47,.04);
}
.artifact .aicon {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--acc-dim); border: 1px solid rgba(14,166,114,.25);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 9px; color: var(--acc); letter-spacing: .05em;
}
.artifact .ameta { flex: 1; min-width: 0; }
.artifact .aname { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact .asize { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); }

/* toast */
#toasts { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel); border: 1px solid var(--border2); border-left: 3px solid var(--acc);
  color: var(--text); padding: 12px 16px; border-radius: 10px; font-size: 13px;
  max-width: 380px; box-shadow: 0 12px 34px rgba(23,37,47,.16);
  animation: slidein .2s ease-out;
}
.toast.error { border-left-color: var(--err); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(23, 37, 47, .38); z-index: 900;
  display: flex; align-items: center; justify-content: center; padding: 4vh 4vw;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--panel); border: 1px solid var(--border2); border-radius: 16px;
  width: min(920px, 100%); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 80px rgba(23,37,47,.25);
}
.modal .mhead {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal .mbody { overflow: auto; flex: 1; }

/* markdown preview */
.md { padding: 24px 28px; color: #33454f; font-size: 14px; }
.md h1, .md h2, .md h3 { color: var(--text); line-height: 1.3; margin: 1.2em 0 .5em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 18px; } .md h3 { font-size: 15px; }
.md h1:first-child { margin-top: 0; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--panel3); padding: 2px 5px; border-radius: 4px; }
.md pre { background: #f3f7f5; border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--acc); margin: 1em 0; padding: 2px 0 2px 14px; color: var(--dim); }
.md table { border-collapse: collapse; margin: 1em 0; width: 100%; }
.md th, .md td { border: 1px solid var(--border2); padding: 6px 10px; text-align: left; font-size: 13px; }
.md th { background: var(--panel2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md img { max-width: 100%; }

/* skill / catalog cards */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.skill-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; cursor: pointer; transition: all .15s; position: relative;
  box-shadow: 0 2px 10px rgba(23,37,47,.04);
}
.skill-card:hover { border-color: var(--acc); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(14,166,114,.12); }
.skill-card .glyph { font-size: 26px; margin-bottom: 10px; }
.skill-card h4 { margin: 0 0 6px; font-size: 14.5px; }
.skill-card p { margin: 0; font-size: 12.5px; color: var(--dim); line-height: 1.55; }
.skill-card.disabled { opacity: .45; }
.skill-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border2); background: var(--panel); color: var(--dim);
  border-radius: 999px; padding: 6px 14px; font-size: 12.5px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.skill-chip:hover { border-color: var(--acc); color: var(--text); }
.skill-chip.sel { border-color: var(--acc); background: var(--acc-dim); color: var(--acc); font-weight: 600; }

/* guardrail tag */
.guard {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12px; color: var(--dim); padding: 4px 0;
}
.guard::before { content: '🛡'; font-size: 12px; flex: none; }

/* misc */
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.spin {
  width: 14px; height: 14px; border: 2px solid var(--border2); border-top-color: var(--acc);
  border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; flex: none;
}
@keyframes rot { to { transform: rotate(360deg); } }
.empty { color: var(--dim2); text-align: center; padding: 40px 20px; font-size: 13px; }
.kbd {
  font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--border2);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--dim);
  background: var(--panel);
}

/* ===================== premium library (skills / workflows / agents) ===================== */
.lib-wrap { max-width: 1080px; margin: 0 auto; padding: 34px 28px 60px; }
.lib-hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 26px 28px; margin-bottom: 22px; border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #eaf7f1 100%);
  border: 1px solid var(--border);
}
.lib-hero h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -.01em; }
.lib-hero p { margin: 0; color: var(--dim); font-size: 13.5px; max-width: 46em; line-height: 1.6; }
.lib-count { text-align: center; flex: none; }
.lib-count-n {
  display: block; font-family: var(--mono); font-size: 40px; font-weight: 700; line-height: 1;
  color: var(--acc); letter-spacing: -.02em;
}
.lib-count .micro { display: block; margin-top: 4px; }

.lib-bar { margin-bottom: 14px; }
.lib-search { max-width: 100%; }
.lib-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filter-chip {
  --cat: var(--acc);
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border2); background: var(--panel); color: var(--dim);
  border-radius: 999px; padding: 6px 13px; font-size: 12.5px; cursor: pointer; transition: all .15s;
}
.filter-chip:hover { border-color: var(--cat); color: var(--text); }
.filter-chip.on { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 10%, #fff); color: var(--text); font-weight: 600; }
.filter-chip .fc-count { font-family: var(--mono); font-size: 10.5px; color: var(--dim2); }
.filter-chip.on .fc-count { color: var(--cat); }
.dot-cat { --cat: var(--acc); width: 8px; height: 8px; border-radius: 50%; background: var(--cat); flex: none; }

.lib-section-head {
  display: flex; align-items: center; gap: 8px; margin: 26px 0 12px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.lib-section-head:first-child { margin-top: 4px; }
.lib-star { color: var(--acc); }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }

.lib-card {
  --cat: var(--acc);
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; cursor: pointer; overflow: hidden;
  transition: transform .16s, box-shadow .16s, border-color .16s;
  box-shadow: 0 1px 3px rgba(23,37,47,.04);
}
.lib-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--cat); opacity: .85;
}
.lib-card:hover { transform: translateY(-3px); border-color: var(--cat); box-shadow: 0 14px 30px color-mix(in srgb, var(--cat) 18%, transparent); }
.lib-card.disabled { opacity: .5; cursor: default; }
.lib-card.disabled::before { background: var(--border2); }
.lib-card.disabled:hover { transform: none; box-shadow: 0 1px 3px rgba(23,37,47,.04); border-color: var(--border); }

.lib-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lib-glyph {
  width: 42px; height: 42px; flex: none; border-radius: 12px; font-size: 21px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--cat) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--cat) 22%, transparent);
}
.lib-glyph.big { width: 48px; height: 48px; font-size: 24px; border-radius: 14px; }
.lib-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cat); background: color-mix(in srgb, var(--cat) 9%, #fff);
  border-radius: 999px; padding: 3px 9px; margin-left: auto;
}
.lib-card h4 { margin: 0 0 6px; font-size: 15px; line-height: 1.3; }
.lib-card p { margin: 0; font-size: 12.5px; color: var(--dim); line-height: 1.6; }
.lib-foot { margin-top: 14px; }
.lib-run { font-size: 12px; font-weight: 600; color: var(--cat); opacity: 0; transition: opacity .16s; }
.lib-card:hover .lib-run { opacity: 1; }

.wf-chain { margin-top: 14px; font-size: 17px; letter-spacing: 1px; color: var(--dim2); }
.agent-top { align-items: flex-start; }
.agent-id h4 { margin: 2px 0 2px; }
.lib-role { font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; color: var(--dim2); text-transform: none; }
.guards { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border2); }

/* new-task composer picker */
.mode-row { display: flex; gap: 8px; margin: 20px 0 14px; flex-wrap: wrap; }
.mode-tab {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border2); background: var(--panel); color: var(--dim);
  border-radius: 10px; padding: 8px 15px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.mode-tab:hover { border-color: var(--acc); color: var(--text); }
.mode-tab.on { border-color: var(--acc); background: var(--acc-dim); color: var(--acc); font-weight: 600; }
.picker-area { min-height: 20px; }
.picker-auto { color: var(--dim2); font-size: 12.5px; padding: 4px 0; }
.picker-search { display: flex; gap: 8px; margin-bottom: 10px; }
.picker-chips {
  display: flex; flex-wrap: wrap; gap: 7px; max-height: 168px; overflow-y: auto;
  padding: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel2);
}
.wf-input-hint { font-size: 12.5px; color: var(--dim); margin-top: 8px; }
.wf-input-hint .micro { display: inline; margin-right: 6px; }

@media (max-width: 720px) {
  .lib-hero { flex-direction: column; align-items: flex-start; }
  .lib-count { align-self: flex-end; }
  .lib-grid { grid-template-columns: 1fr; }
}
