/* OpenKuro web GUI demo (js/demos/kuro.js) */

.dm-kuro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  color: #e0e0e0;
  font: 400 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}
.dm-kuro.is-reset *,
.dm-kuro.is-reset *::before,
.dm-kuro.is-reset *::after {
  transition: none !important;
}
.dm-kuro b { font-weight: 600; }
.dm-kuro i,
.dm-kuro em { font-style: normal; }

/* Top nav */
.dm-kuro .kd-nav {
  flex: none;
  height: 48px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  background: #12122a;
  border-bottom: 1px solid #2a2a4a;
}
.dm-kuro .kd-logo {
  font-size: 19.2px;
  font-weight: 700;
  color: #6c63ff;
  letter-spacing: 1px;
}
.dm-kuro .kd-logo span { font-size: 16px; opacity: 0.7; }
.dm-kuro .kd-links { display: flex; gap: 4px; }
.dm-kuro .kd-links span {
  padding: 6.4px 12.8px;
  border-radius: 8px;
  font-size: 13.6px;
  line-height: 1.3;
  color: #a0a0b8;
  transition: background 0.2s, color 0.2s;
}
.dm-kuro .kd-links span.is-on { background: #6c63ff; color: #fff; }
.dm-kuro .kd-ctrl {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dm-kuro .kd-ib {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 17px;
  line-height: 1;
  color: #a0a0b8;
  filter: saturate(0.35);
  opacity: 0.85;
}
.dm-kuro[data-page="dashboard"] .kd-ib,
.dm-kuro[data-page="security"] .kd-ib { display: none; }
.dm-kuro .kd-lang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
  padding: 4px 10px;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  background: #252545;
  font-size: 12.5px;
  color: #e0e0e0;
}
.dm-kuro .kd-lang i,
.dm-kuro .kd-select i,
.dm-kuro .kd-agent i { font-size: 10px; color: #6c6c8a; }

/* Pages */
.dm-kuro .kd-pages { position: relative; flex: 1; min-height: 0; }
.dm-kuro .kd-page {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}
.dm-kuro[data-page="chat"] .kd-chat,
.dm-kuro[data-page="dashboard"] .kd-dash,
.dm-kuro[data-page="security"] .kd-sec {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease;
}

/* Chat page */
.dm-kuro .kd-chat { display: flex; flex-direction: column; }
.dm-kuro .kd-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5.6px 16px;
  background: #16213e;
  border-bottom: 1px solid #2a2a4a;
}
.dm-kuro .kd-lb {
  display: grid;
  place-items: center;
  padding: 4px 6px;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  background: #252545;
  color: #6c6c8a;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.dm-kuro .kd-lb svg { display: block; width: 16px; height: 16px; }
.dm-kuro .kd-lb.is-on { background: #6c63ff; border-color: #6c63ff; color: #fff; }
.dm-kuro .kd-lbl { margin-left: 10px; font-size: 12.8px; color: #6c6c8a; }

.dm-kuro .kd-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  background: #0f0f23;
}
.dm-kuro .kd-panel {
  flex: 0 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 0 solid #2a2a4a;
  transition: flex-grow 0.7s cubic-bezier(0.65, 0, 0.25, 1);
}
.dm-kuro .kd-panel.is-open { flex-grow: 1; }
.dm-kuro .kd-grid.is-multi .kd-panel.is-open { border-width: 1px; }

.dm-kuro .kd-phd {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 0;
  padding: 0 9.6px;
  overflow: hidden;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 0 solid #2a2a4a;
  transition: height 0.45s ease;
}
.dm-kuro .kd-grid.is-multi .kd-phd { height: 34px; border-bottom-width: 1px; }
.dm-kuro .kd-agent {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 160px;
  padding: 2px 6px 2px 8px;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  background: #252545;
  font-size: 12px;
  line-height: 1.5;
}
.dm-kuro .kd-agent b { font-weight: 500; }
.dm-kuro .kd-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
}
.dm-kuro .kd-model {
  padding: 2px 8px;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  background: #252545;
  font-size: 12px;
  line-height: 1.5;
  color: #6c63ff;
}

.dm-kuro .kd-msgs {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 12px;
}
.dm-kuro .kd-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}
.dm-kuro .kd-grid.is-multi .kd-col { max-width: none; }
.dm-kuro .kd-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.dm-kuro .kd-msg.is-user {
  align-self: flex-end;
  background: #2d2d5e;
  border-bottom-right-radius: 4px;
}
.dm-kuro .kd-msg.is-ai {
  align-self: flex-start;
  background: #1e1e3e;
  border-bottom-left-radius: 4px;
}
.dm-kuro .kd-grid.is-multi .kd-msg {
  max-width: 95%;
  padding: 8px 12px;
  font-size: 13.6px;
}
.dm-kuro .kd-msg.is-new { animation: kd-msg-in 0.3s ease-out; }
.dm-kuro .kd-msg b { font-weight: 700; }
.dm-kuro .kd-msg pre {
  margin: 6px 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font: 12px/1.55 "Cascadia Code", "Fira Code", Consolas, monospace;
  white-space: pre;
  overflow: hidden;
  color: #e0e0e0;
}
.dm-kuro .kd-msg code {
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  font: 0.9em "Cascadia Code", "Fira Code", Consolas, monospace;
}
.dm-kuro .kd-msg.is-wait { color: #6c6c8a; font-style: italic; min-width: 52px; }
.dm-kuro .kd-dots i { opacity: 0; font-weight: 700; }
.dm-kuro .kd-dots i:nth-child(1) { animation: kd-dot1 1.5s linear infinite; }
.dm-kuro .kd-dots i:nth-child(2) { animation: kd-dot2 1.5s linear infinite; }
.dm-kuro .kd-dots i:nth-child(3) { animation: kd-dot3 1.5s linear infinite; }

.dm-kuro .kd-input {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6.4px 9.6px;
  background: #16213e;
  border-top: 1px solid #2a2a4a;
}
.dm-kuro .kd-ta {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 6.4px 9.6px;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  background: #252545;
  font-size: 13.6px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  transition: border-color 0.2s;
}
.dm-kuro .kd-ta.is-focus { border-color: #6c63ff; }
.dm-kuro .kd-hint {
  position: absolute;
  left: 9.6px;
  top: 6.4px;
  color: #6c6c8a;
}
.dm-kuro .kd-typed:not(:empty) ~ .kd-hint { display: none; }
.dm-kuro .kd-send {
  flex: none;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0 11.2px;
  border-radius: 8px;
  background: #6c63ff;
  color: #fff;
  font-size: 16px;
  transition: opacity 0.2s, background 0.2s;
}
.dm-kuro .kd-panel.is-busy .kd-send { opacity: 0.5; }

/* Approval modal */
.dm-kuro .kd-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.dm-kuro .kd-modal.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease;
}
.dm-kuro .kd-mcard {
  width: 500px;
  padding: 24px;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  background: #16213e;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dm-kuro .kd-modal.is-on .kd-mcard { transform: none; }
.dm-kuro .kd-mt {
  margin-bottom: 14px;
  font-size: 17.6px;
  font-weight: 600;
  color: #f39c12;
}
.dm-kuro .kd-mf {
  margin-bottom: 6px;
  font-size: 14.4px;
  color: #a0a0b8;
}
.dm-kuro .kd-mf b { font-weight: 500; color: #e0e0e0; }
.dm-kuro .kd-high { font-weight: 600; color: #e74c3c; }
.dm-kuro .kd-pre {
  margin: 12px 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font: 13.6px/1.6 "Cascadia Code", "Fira Code", Consolas, monospace;
  white-space: pre;
  color: #e0e0e0;
}
.dm-kuro .kd-magent {
  margin-bottom: 18px;
  font-size: 14.4px;
  font-weight: 600;
  color: #6c63ff;
}
.dm-kuro .kd-mbtns { display: flex; justify-content: flex-end; gap: 8px; }
.dm-kuro .kd-mb {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14.4px;
  font-weight: 500;
  color: #fff;
  transition: background 0.2s, transform 0.15s;
}
.dm-kuro .kd-mb.is-ok { background: #2ecc71; }
.dm-kuro .kd-mb.is-ok.is-hover { background: #3ddb80; }
.dm-kuro .kd-mb.is-no { background: #e74c3c; }
.dm-kuro .kd-mb.is-trust { background: #6c63ff; }
.dm-kuro .kd-mb.is-press { transform: scale(0.95); }

/* Dashboard + security shell */
.dm-kuro .kd-shell {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 16px;
  padding: 16px;
}
.dm-kuro .kd-side {
  flex: none;
  align-self: flex-start;
  width: 230px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  background: #16213e;
}
.dm-kuro .kd-side-t {
  margin-bottom: 8px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6c6c8a;
}
.dm-kuro .kd-side span {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13.4px;
  color: #a0a0b8;
}
.dm-kuro .kd-side span.is-on { background: #252545; color: #e0e0e0; }
.dm-kuro .kd-main {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.dm-kuro .kd-scroll {
  display: flex;
  flex-direction: column;
  gap: 16px;
  will-change: transform;
}
.dm-kuro .kd-card {
  padding: 20px;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  background: #16213e;
}
.dm-kuro .kd-h {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #6c63ff;
}
.dm-kuro .kd-filter {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  font-size: 14px;
}
.dm-kuro .kd-select {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  min-width: 220px;
  padding: 5px 10px;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  background: #252545;
  font-size: 13.6px;
}

.dm-kuro .kd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.dm-kuro .kd-stat {
  padding: 14px 10px;
  border-radius: 8px;
  background: #252545;
  text-align: center;
}
.dm-kuro .kd-stat b,
.dm-kuro .kd-s4 b {
  display: block;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.dm-kuro .kd-stat span,
.dm-kuro .kd-s4 span { font-size: 12.8px; color: #6c6c8a; }
.dm-kuro .is-accent b { color: #6c63ff; }
.dm-kuro .is-ok b { color: #2ecc71; }
.dm-kuro .is-err b { color: #e74c3c; }
.dm-kuro .kd-s4.is-warn b { color: #f39c12; }

.dm-kuro .kd-agents { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dm-kuro .kd-ag { padding: 12px; border-radius: 8px; background: #252545; }
.dm-kuro .kd-ag-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dm-kuro .kd-ag-h i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6c6c8a;
  transition: background 0.3s, box-shadow 0.3s;
}
.dm-kuro .kd-ag-h b { font-size: 14.4px; }
.dm-kuro .kd-ag-h em {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(108, 108, 138, 0.2);
  font-size: 11px;
  color: #a0a0b8;
  transition: background 0.3s, color 0.3s;
}
.dm-kuro .kd-ag.is-busy .kd-ag-h i { background: #2ecc71; box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.18); }
.dm-kuro .kd-ag.is-busy .kd-ag-h em { background: rgba(46, 204, 113, 0.15); color: #2ecc71; }
.dm-kuro .kd-ag-m {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  gap: 2px 18px;
  font-size: 12.8px;
  color: #a0a0b8;
  white-space: nowrap;
}
.dm-kuro .kd-ag-m span { font-variant-numeric: tabular-nums; }

.dm-kuro .kd-live {
  font-size: 12px;
  font-weight: 600;
  color: #e74c3c;
  animation: kd-live 2s ease-in-out infinite;
}
.dm-kuro .kd-tl {
  display: flex;
  flex-direction: column;
  gap: 6.4px;
  overflow: hidden;
}
.dm-kuro .kd-ev {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 9.6px;
  border-left: 3px solid #2a2a4a;
  border-radius: 8px;
  background: #252545;
  font-size: 12.8px;
  white-space: nowrap;
}
.dm-kuro .kd-ev.is-new { animation: kd-ev-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), kd-ev-hl 1.6s ease-out; }
.dm-kuro .kd-ev[data-type="message_received"] { border-left-color: #6c63ff; }
.dm-kuro .kd-ev[data-type="tool_call"] { border-left-color: #f39c12; }
.dm-kuro .kd-ev[data-type="delegation"] { border-left-color: #8b5cf6; }
.dm-kuro .kd-ev[data-type="response"] { border-left-color: #2ecc71; }
.dm-kuro .kd-ev-i { width: 18px; text-align: center; font-size: 13px; }
.dm-kuro .kd-ev-t { font-size: 11.2px; color: #6c6c8a; font-variant-numeric: tabular-nums; }
.dm-kuro .kd-ev-a { font-size: 12px; font-weight: 600; color: #6c63ff; }
.dm-kuro .kd-ev-b {
  padding: 1px 6px;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  background: #16213e;
  font: 10.4px/1.5 "Cascadia Code", "Fira Code", Consolas, monospace;
  color: #a0a0b8;
}
.dm-kuro .kd-ev-c {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #a0a0b8;
}

/* Security */
.dm-kuro .kd-sec-main { display: flex; flex-direction: column; gap: 16px; }
.dm-kuro .kd-pagetitle { font-size: 19px; font-weight: 600; color: #e0e0e0; }
.dm-kuro .kd-score { display: flex; align-items: center; gap: 30px; padding: 18px 24px; }
.dm-kuro .kd-ringw { position: relative; flex: none; width: 120px; height: 120px; }
.dm-kuro .kd-ring { display: block; width: 120px; height: 120px; transform: rotate(-90deg); }
.dm-kuro .kd-ring circle { fill: none; stroke-width: 8; }
.dm-kuro .kd-ring-bg { stroke: #252545; }
.dm-kuro .kd-ring-fg { stroke: #2ecc71; stroke-linecap: round; }
.dm-kuro .kd-ring-n {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dm-kuro .kd-grade { margin-bottom: 10px; font-size: 19px; font-weight: 600; }
.dm-kuro .kd-grade span {
  display: inline-block;
  color: #2ecc71;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.4s, transform 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.dm-kuro .kd-grade.is-in span { opacity: 1; transform: none; }
.dm-kuro .kd-factors { display: grid; gap: 6px; font-size: 13.6px; color: #a0a0b8; }
.dm-kuro .kd-factors span {
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.4s, transform 0.4s;
}
.dm-kuro .kd-factors span.is-in { opacity: 1; transform: none; }
.dm-kuro .kd-factors i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 50%;
  background: #2ecc71;
}
.dm-kuro .kd-factors .is-warn i { background: #f39c12; }

.dm-kuro .kd-stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.dm-kuro .kd-s4 { padding: 14px 10px; text-align: center; transition: border-color 0.4s, box-shadow 0.4s; }
.dm-kuro .kd-s4 b { font-size: 28px; }
.dm-kuro .kd-s4.is-flash { border-color: #2ecc71; box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.15); }

.dm-kuro .kd-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dm-kuro .kd-risks,
.dm-kuro .kd-tools { padding: 18px 20px 10px; }
.dm-kuro .kd-row {
  display: grid;
  grid-template-columns: 96px 1fr 36px;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12.8px;
}
.dm-kuro .kd-rl { color: #a0a0b8; letter-spacing: 0.04em; }
.dm-kuro .kd-row.is-tool .kd-rl { font: 12.5px "Cascadia Code", "Fira Code", Consolas, monospace; letter-spacing: 0; }
.dm-kuro .kd-row b { text-align: right; font-variant-numeric: tabular-nums; }
.dm-kuro .kd-bar {
  height: 20px;
  border-radius: 4px;
  background: #252545;
  overflow: hidden;
}
.dm-kuro .kd-row.is-tool .kd-bar { height: 10px; }
.dm-kuro .kd-bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: #6c63ff;
  transform: scaleX(0);
  transform-origin: left;
}
.dm-kuro .is-low .kd-bar i { background: #2ecc71; }
.dm-kuro .is-medium .kd-bar i { background: #f39c12; }
.dm-kuro .is-high .kd-bar i { background: #e74c3c; }
.dm-kuro .is-critical .kd-bar i { background: #ff0040; }

@keyframes kd-msg-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes kd-dot1 { 0%, 24.9% { opacity: 0; } 25%, 100% { opacity: 1; } }
@keyframes kd-dot2 { 0%, 49.9% { opacity: 0; } 50%, 100% { opacity: 1; } }
@keyframes kd-dot3 { 0%, 74.9% { opacity: 0; } 75%, 100% { opacity: 1; } }
@keyframes kd-live { 50% { opacity: 0.4; } }
@keyframes kd-ev-in { from { margin-top: -38.4px; opacity: 0; } }
@keyframes kd-ev-hl { from { background: #34346e; } }
