:root {
  --bg: #070b12;
  --bg2: #0c1220;
  --card: rgba(18, 26, 40, 0.82);
  --card-solid: #121a28;
  --line: rgba(120, 160, 220, 0.16);
  --text: #eef3fb;
  --muted: rgba(190, 205, 230, 0.62);
  --accent: #5eb1ff;
  --accent2: #3d8bfd;
  --ok: #3ddc84;
  --danger: #5a2030;
  --danger-text: #ffb4c0;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  position: relative;
  overflow: hidden;
}

.aurora {
  pointer-events: none;
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 55vh;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(61, 139, 253, 0.28), transparent 70%),
    radial-gradient(ellipse 50% 40% at 85% 10%, rgba(94, 177, 255, 0.14), transparent 65%),
    radial-gradient(ellipse 40% 35% at 55% 60%, rgba(30, 90, 160, 0.18), transparent 70%);
  filter: blur(8px);
  z-index: 0;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(0, 18px, 0) scale(1.04); }
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.screen.chat-screen {
  position: relative;
}
.screen.chat-screen .chat-chrome {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 11, 18, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.chat-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  grid-template-rows: 44px auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 8px;
  padding: 10px 12px 8px;
  padding-top: max(10px, env(safe-area-inset-top));
  box-sizing: border-box;
}
.back-btn {
  grid-column: 1;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  margin: 0;
  border-radius: 12px;
  border: 1px solid rgba(94, 177, 255, 0.28);
  background: rgba(94, 177, 255, 0.14);
  color: var(--text);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
}
.back-btn .back-arrow {
  font-size: 22px;
  line-height: 1;
  display: block;
  transform: translateY(-1px);
}
.back-btn:active {
  background: rgba(94, 177, 255, 0.24);
}
.chat-quota {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  justify-self: center;
  max-width: 100%;
}
.chat-quota .quota-chip {
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  max-width: 100%;
}
.chat-header .btn-icon,
.chat-header .top-spacer {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  width: 44px;
  height: 44px;
  min-width: 44px;
  margin: 0;
  box-sizing: border-box;
}
.chat-header .top-spacer {
  display: block;
  visibility: hidden;
  pointer-events: none;
}
.chat-title-wrap {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  justify-content: center;
  min-width: 0;
  width: 100%;
}
.chat-title {
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;
  min-height: 36px;
  height: auto;
  margin: 0;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(94, 177, 255, 0.28);
  background: rgba(94, 177, 255, 0.14);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.chat-banner {
  margin: 0 12px 10px !important;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 8px;
}
.brand-row.brand-center {
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 20px 20px 14px;
}
.brand-center .brand-text {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.brand-center .brand-text h1 {
  text-align: center;
}
.brand-center .brand-text .tag {
  text-align: center;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}
.home-screen {
  position: relative;
}
.home-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  padding: 4px 0 calc(88px + env(safe-area-inset-bottom));
  overflow: auto;
}
.home-main .section-title {
  text-align: center;
}
.home-main .card.license {
  max-width: 420px;
  width: calc(100% - 32px);
  margin-left: auto;
  margin-right: auto;
  position: relative;
  padding: 16px 16px 16px 28px;
}
.card.license .lic-corner {
  position: absolute;
  top: 11px;
  left: 11px;
  width: 9px;
  height: 9px;
  margin: 0;
  flex: none;
}
.lic-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  min-height: 36px;
}
.lic-title-row .lic-id {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
}
.lic-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.lic-edit,
.card.license .lic-del {
  position: static;
  top: auto;
  right: auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  z-index: auto;
  flex: 0 0 auto;
}
.lic-edit {
  background: rgba(126, 196, 255, 0.12);
  color: #9ecfff;
}
.lic-edit:active {
  background: rgba(126, 196, 255, 0.22);
}
.card.license .lic-del {
  background: rgba(255, 80, 100, 0.12);
  color: #ff6b7a;
  font-size: 22px;
}
.card.license .lic-del:active {
  background: rgba(255, 80, 100, 0.22);
}
.lic-code {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card.license .btn-row {
  margin-top: 14px;
}
.card.license .btn-row .btn-primary {
  width: 100%;
}
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  /* odd size = true center pixel; text "+" has baseline bias */
  width: 55px;
  height: 55px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(180deg, #7ec4ff, var(--accent2));
  color: #041018;
  box-shadow: 0 14px 36px rgba(61, 139, 253, 0.45);
  cursor: pointer;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 0;
  font-size: 0;
}
.fab svg {
  width: 23px;
  height: 23px;
  display: block;
}
.fab:active { transform: scale(0.96); }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, #6ec0ff, #2f6fe0 55%, #1a3f8a);
  box-shadow: 0 10px 28px rgba(61, 139, 253, 0.35);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  color: #041018;
  letter-spacing: -0.04em;
}
.brand-text h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.brand-text .tag {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.top {
  display: grid;
  grid-template-columns: minmax(44px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  column-gap: 8px;
  padding: 14px 16px 10px;
  min-height: 60px;
  box-sizing: border-box;
}
.top > .btn-icon:first-child {
  justify-self: start;
}
.top h1 {
  margin: 0;
  grid-column: 2;
  justify-self: center;
  text-align: center;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(52vw, 220px);
}
.top-actions-3 {
  grid-template-columns: minmax(96px, 1fr) auto minmax(96px, 1fr);
}
.top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  grid-column: 3;
}
.key-banner {
  display: block;
  box-sizing: border-box;
  width: calc(100% - 32px);
  max-width: none;
  margin: 0 16px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(255, 196, 90, 0.35);
  background: rgba(255, 196, 90, 0.08);
  color: #ffd59a;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.key-banner.ok {
  border-style: solid;
  border-color: rgba(61, 220, 132, 0.28);
  background: rgba(61, 220, 132, 0.08);
  color: #9af0c0;
}
.key-banner:active {
  filter: brightness(1.08);
}
.top-spacer {
  width: 44px;
  height: 44px;
  visibility: hidden;
  pointer-events: none;
}

.lead {
  padding: 4px 20px 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}
.lead code {
  font-family: var(--mono);
  font-size: 12px;
  color: #b8d7ff;
  background: rgba(94, 177, 255, 0.1);
  padding: 2px 7px;
  border-radius: 6px;
}

.quota-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 16px 14px;
}
.quota-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(120, 160, 220, 0.14);
  line-height: 1;
}
.quota-chip .q-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b7588;
  flex-shrink: 0;
}
.quota-chip .q-k {
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  color: var(--muted);
}
.quota-chip .q-v {
  font-size: 12px;
  font-weight: 650;
  font-family: var(--mono);
  color: var(--text);
  letter-spacing: -0.01em;
}
.quota-chip.ok {
  background: rgba(61, 220, 132, 0.08);
  border-color: rgba(61, 220, 132, 0.22);
}
.quota-chip.ok .q-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.14);
}
.quota-chip.ok .q-v { color: #9af0c0; }
.quota-chip.warn {
  background: rgba(255, 160, 80, 0.08);
  border-color: rgba(255, 160, 80, 0.22);
}
.quota-chip.warn .q-v { color: #ffc48a; }
.quota-chip.mute .q-v {
  font-family: var(--font);
  font-weight: 500;
  color: var(--muted);
}

.card {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 16px 14px;
  box-shadow: var(--shadow);
}
.card.license {
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card.license:active {
  transform: scale(0.985);
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(180deg, #7ec4ff, var(--accent2));
  color: #041018;
  box-shadow: 0 10px 24px rgba(61, 139, 253, 0.35);
  width: 100%;
}
.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 10px 8px;
}
.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.btn-row .btn-primary { flex: 1; width: auto; }
.btn-icon {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid var(--line);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.btn-icon:active { background: rgba(255,255,255,0.08); }
.btn-icon:disabled,
.btn-icon.is-busy {
  opacity: 0.9;
  pointer-events: none;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(238, 243, 251, 0.22);
  border-top-color: #eef3fb;
  border-radius: 50%;
  display: block;
  animation: spin 0.65s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.input, .textarea {
  width: 100%;
  background: rgba(7, 11, 18, 0.75);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 14px;
  font-size: 15px;
  outline: none;
  font-family: var(--mono);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { font-family: var(--font); }
.input:focus, .textarea:focus {
  border-color: rgba(94, 177, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(94, 177, 255, 0.15);
}
.input::placeholder, .textarea::placeholder { color: rgba(190, 205, 230, 0.35); }
.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0 0 8px;
}
.field { margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.err {
  background: linear-gradient(180deg, #4a1a28, var(--danger));
  color: var(--danger-text);
  padding: 12px 14px;
  margin: 0 16px 12px;
  border-radius: 14px;
  font-size: 13px;
  border: 1px solid rgba(255, 140, 160, 0.2);
}

.list {
  flex: 1;
  overflow: auto;
  padding: 0 0 calc(28px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.list-section {
  padding: 4px 16px 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(190, 205, 230, 0.42);
  text-align: center;
}
.list-section + .proj { margin-top: 0; }
.proj {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 18px;
  align-items: center;
  column-gap: 14px;
  min-height: 72px;
  width: calc(100% - 32px);
  margin: 0 16px 10px;
  padding: 14px 14px;
  box-sizing: border-box;
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 16px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.proj:active {
  border-color: rgba(94, 177, 255, 0.4);
  background: #152033;
}
.proj.is-locked {
  opacity: 0.55;
}
.proj.is-locked .chev {
  font-size: 14px;
  opacity: 0.9;
}
.proj.is-locked:active {
  border-color: var(--line);
  background: var(--card-solid);
}
.proj .ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(94, 177, 255, 0.12);
  border: 1px solid rgba(94, 177, 255, 0.18);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}
.proj .ico svg {
  width: 20px;
  height: 20px;
  display: block;
}
.proj .ico.pc {
  background: rgba(255, 196, 90, 0.1);
  border-color: rgba(255, 196, 90, 0.22);
  color: #ffc45a;
}
.proj .meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.proj .name {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.015em;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj .sub {
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj .chev {
  width: 18px;
  height: 18px;
  color: rgba(190, 205, 230, 0.35);
  display: grid;
  place-items: center;
}
.proj .chev svg {
  width: 16px;
  height: 16px;
  display: block;
}

.link-row {
  display: block;
  width: calc(100% - 32px);
  margin: 6px 16px 14px;
  padding: 14px 12px;
  border: 1px dashed rgba(120, 160, 220, 0.28);
  border-radius: 14px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}
.link-row:active {
  background: rgba(94, 177, 255, 0.08);
}

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 14px 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.bubble {
  max-width: 92%;
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 16px;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.5;
  animation: pop 0.18s ease;
}
.bubble.user { white-space: pre-wrap; }
@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.bubble.user {
  margin-left: auto;
  background: linear-gradient(160deg, #1e3f66, #163250);
  border: 1px solid rgba(94, 177, 255, 0.22);
  border-bottom-right-radius: 6px;
}
.bubble.assistant {
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  max-width: 96%;
}
.bubble.assistant.is-typing {
  width: fit-content;
  min-width: 64px;
  padding: 14px 18px;
}
.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 14px;
}
.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9eb6d8;
  display: block;
  animation: typing-bounce 1.1s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.bubble.assistant .md-plain {
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.2em;
}
.bubble.assistant .bubble-body {
  min-width: 0;
}
.bubble.assistant .md-p {
  margin: 0 0 10px;
}
.bubble.assistant .md-p:last-child { margin-bottom: 0; }
.bubble.assistant .md-gap { height: 8px; }
.bubble.assistant .md-ul {
  margin: 0 0 10px;
  padding-left: 1.2em;
}
.bubble.assistant .md-ul li { margin: 3px 0; }
.bubble.assistant strong { font-weight: 700; color: #fff; }
.bubble.assistant code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(94, 177, 255, 0.12);
  padding: 1px 5px;
  border-radius: 5px;
}
.md-kv {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(7, 11, 18, 0.55);
}
.md-kv-row {
  display: grid;
  grid-template-columns: minmax(96px, 38%) 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(120, 160, 220, 0.12);
  align-items: start;
}
.md-kv-row:last-child { border-bottom: 0; }
.md-kv-row .k {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}
.md-kv-row .v {
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.bubble.assistant .md-pre {
  margin: 8px 0;
  padding: 10px 12px;
  overflow-x: auto;
  max-width: 100%;
  border-radius: 12px;
  background: #0a1018;
  border: 1px solid var(--line);
}
.bubble.assistant .md-pre.is-open {
  border-style: dashed;
  opacity: 0.92;
}
.bubble.assistant .md-pre code {
  display: block;
  background: none;
  padding: 0;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.bubble.assistant .md-pipe {
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.9;
}
.md-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: var(--mono);
  min-width: 420px;
}
.md-table th,
.md-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(120, 160, 220, 0.12);
  white-space: nowrap;
}
.md-table th {
  background: rgba(94, 177, 255, 0.1);
  color: #cfe3ff;
  font-weight: 650;
  position: sticky;
  top: 0;
}
.md-table tr:last-child td { border-bottom: 0; }
.md-table td { color: #d7e3f4; }
.bubble.system {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  max-width: 100%;
  border: 0;
  padding: 4px 8px;
}

.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(7, 11, 18, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 6;
  box-sizing: border-box;
}
.composer .textarea {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  min-height: 48px;
  max-height: 120px;
  height: 48px;
  margin: 0;
  padding: 12px 14px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
  box-sizing: border-box;
  border-radius: 14px;
}
.composer .btn-primary {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0;
  border-radius: 14px;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  align-self: center;
  box-shadow: 0 8px 18px rgba(61, 139, 253, 0.32);
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 20px;
  animation: fade 0.18s ease;
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  width: min(420px, 100%);
  background: #101826;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
}
.modal h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.25;
}
.modal-head {
  margin: 0 0 12px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: #b8d7ff;
  line-height: 1.3;
  word-break: break-all;
}
.modal .muted {
  margin: 0 0 16px;
  text-align: center;
  white-space: pre-line;
  line-height: 1.55;
}
.modal-err {
  margin: 0 0 10px;
  color: var(--danger-text);
  font-size: 13px;
  text-align: center;
}
.modal .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.modal .actions .btn-primary,
.modal .actions .btn-ghost {
  width: 100%;
  min-width: 0;
  margin: 0;
}
.modal .actions .btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
}
.modal-form .field {
  text-align: left;
}
.modal-form .label {
  text-align: left;
}
.modal-form .hint {
  text-align: left;
}
.modal-center .actions:has(#m-ok:only-child),
.modal .actions:has(> :only-child) {
  grid-template-columns: 1fr;
}

.empty {
  padding: 48px 28px;
  text-align: center;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}
.empty-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(94, 177, 255, 0.1);
  border: 1px solid rgba(94, 177, 255, 0.18);
  font-size: 22px;
}

.lic-id {
  font-size: 17px;
  font-weight: 700;
}
.lic-meta {
  margin: 8px 0 4px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.12);
}
.dot.on { background: var(--ok); }
.dot.off {
  background: #6b7588;
  box-shadow: none;
}

.section-title {
  padding: 8px 20px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(190, 205, 230, 0.45);
  text-align: center;
}
