:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  --page: #0b0e19;
  --surface: #12182a;
  --field: #141b2e;
  --input: #0e1425;
  --ink: #f2f3ff;
  --muted: #a4aec9;
  --line: #303957;
  --accent: #d7c8ff;
  --aqua: #91eef7;
  --danger: #ffb8cb;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.apk-update { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; }
#download-apk { margin-top: 12px; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #181935, transparent 60%), var(--page);
  color: var(--ink);
}

h1, h2, p { margin: 0; }
button, input, textarea, select { font: inherit; }
input, select, textarea, button { color: inherit; }

button, select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--field);
}

button { cursor: pointer; padding: 7px 12px; }
button:hover:not(:disabled), select:hover:not(:disabled) { border-color: #7482a7; }
button:disabled, select:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--aqua); outline-offset: 3px; }
textarea { resize: vertical; }

input:not([type="checkbox"]), textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--input);
  line-height: 1.35;
}

input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.primary { color: #171127; background: var(--accent); border-color: transparent; font-weight: 650; }
.danger { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

.topbar {
  background: #0d111ee8;
  border-bottom: 1px solid #2c3450;
}

.topbar-inner {
  max-width: 1216px;
  margin: 0 auto;
  padding: 12px clamp(12px, 3vw, 24px);
  min-height: 66px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-size: 1.24rem;
  font-weight: 650;
  letter-spacing: -.045em;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 42% 58% 56% 44% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 30% 22%, #f8ffff, transparent 38%), linear-gradient(143deg, #527ee5, #7ce9e3 49%, #a271df);
  border: 1px solid #dfd6ff88;
  box-shadow: 0 0 15px #a672ef5a;
}

.project-picker { display: flex; flex: 1 1 240px; align-items: center; gap: 8px; min-width: 0; }
.project-picker select { width: min(100%, 240px); padding-inline: 8px; min-width: 0; }
.project-picker button { flex-shrink: 0; font-size: .84rem; }
.server-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.server-actions > button:first-child { font-size: .8rem; }
.connection-help { margin-bottom: 15px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
#connection-form label { display: block; margin-bottom: 5px; }
.model-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; }
.model-status i { width: 7px; height: 7px; border-radius: 50%; background: #8a97ba; }
.model-status[data-state="ready"] i { background: #8aefd2; box-shadow: 0 0 9px #86ffcc68; }
.model-status:is([data-state="offline"], [data-state="missing"]) i { background: #f2ae8d; }

.layout {
  max-width: 1216px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.36fr) minmax(280px, .94fr);
  align-items: start;
  gap: 16px;
  padding: clamp(12px, 3vw, 24px);
}

.card { min-width: 0; border: 1px solid var(--line); border-radius: 23px; background: var(--surface); }
.board { overflow: hidden; }
.board-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 19px 6px; }
.board-heading h1 { font-weight: 600; font-size: clamp(1.25rem, 2.8vw, 1.7rem); letter-spacing: -.035em; overflow-wrap: anywhere; }
.board-heading p { margin-top: 5px; color: var(--muted); font-size: .8375rem; line-height: 1.5; overflow-wrap: anywhere; }
.board-heading button { flex-shrink: 0; font-size: .84rem; }

.stage {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  padding: 3px 9px 21px;
  min-width: 0;
}

.stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: radial-gradient(ellipse 50% 48% at 50% 48%, #303d7a55, transparent 92%);
  pointer-events: none;
}

.orb {
  position: relative;
  width: min(92%, 416px);
  aspect-ratio: 1;
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  isolation: isolate;
  user-select: none;
}

.orb:active { cursor: grabbing; }
.orb[data-dragging="true"] { touch-action: none; }
.orb canvas, .orb-ideas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.orb-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .86rem; pointer-events: none; }
.orb-hint { margin-top: -5px; min-height: 19px; text-align: center; color: var(--muted); font-size: .8rem; }

.idea {
  position: absolute;
  left: 0;
  top: 0;
  min-height: 0;
  max-width: var(--idea-width, 150px);
  padding: 3px;
  border: 0;
  background: transparent;
  line-height: 1.18;
  letter-spacing: -.02em;
  text-align: center;
  opacity: .92;
  visibility: hidden;
  color: #fbfcff;
  text-shadow: 0 1px 6px #090d24, 0 0 12px #111931;
  font-weight: 570;
}

.idea-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.idea.is-new .idea-text { animation: arrival .66s cubic-bezier(.13, .7, .24, 1) both; }
@keyframes arrival { from { transform: translateY(9px) scale(.56); opacity: 0; filter: blur(5px); } to { transform: none; opacity: 1; filter: none; } }

.orb[data-editing="true"] .idea {
  pointer-events: auto;
  background: #232734ed;
  border: 1px solid #798197;
  border-radius: 18px;
  padding: 5px 8px;
  text-shadow: none;
}

.orb[data-editing="true"] .idea[aria-pressed="true"] { background: #444c61; border-color: #e6eaff; }

.board-controls { width: min(calc(100% - 26px), 484px); margin: 0 auto 14px; }
.idea-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 46px; gap: 8px; }
.idea-entry { position: relative; display: flex; align-items: center; }
.idea-entry input { height: 46px; padding-right: 80px; }
.idea-entry button { position: absolute; right: 4px; min-height: 36px; padding: 4px 7px; color: var(--accent); font-weight: 650; font-size: .75rem; }
.editing-hint {
  display: grid;
  align-content: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  padding: 0 9px;
  font-size: .82rem;
  color: var(--muted);
  background: var(--input);
}

#edit-mode[aria-pressed="true"] { background: #333b4d; border-color: #858ea4; }
.idea-editor { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.idea-editor label, dialog label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .83rem; }
.editor-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.idea-index { margin: 8px 0 0; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.idea-index summary { cursor: pointer; padding: 5px; color: var(--muted); font-size: .86rem; }
.idea-index ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.idea-index li { max-width: 100%; }
.idea-index button { min-height: 35px; text-align: left; font-size: .8rem; overflow-wrap: anywhere; }
.idea-index button[aria-pressed="true"] { border-color: var(--accent); }

.notice { color: var(--muted); margin-top: 8px; font-size: .84rem; line-height: 1.45; overflow-wrap: anywhere; }
.notice[data-error="true"] { color: var(--danger); }
.review {
  margin: 0 13px 14px;
  min-width: 0;
  background: #161c30;
  border: 1px solid #394466;
  border-radius: 16px;
  overflow: hidden;
}

.review header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 11px 13px;
}

.review h2, .chat h2, dialog h2 { font-weight: 620; font-size: 1rem; letter-spacing: -.018em; }
.review-status { min-height: 16px; display: flex; align-items: center; gap: 6px; font-size: .77rem; color: var(--muted); }
.wave { display: none; align-items: center; gap: 2px; height: 12px; color: var(--aqua); }
.review[data-busy="true"] .wave { display: flex; }
.wave i { width: 2px; height: 9px; background: currentColor; border-radius: 3px; animation: pulse .7s ease-in-out infinite alternate; }
.wave i:nth-child(2) { animation-delay: -.25s; }
.wave i:nth-child(3) { animation-delay: -.48s; }
.wave i:nth-child(4) { animation-delay: -.17s; }
@keyframes pulse { from { transform: scaleY(.3); } to { transform: scaleY(1.17); } }

.review-light { position: relative; height: 2px; background: #293254; overflow: hidden; }
.review[data-busy="true"] .review-light::after {
  content: "";
  display: block;
  width: 46%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--aqua), #c5a4fc, transparent);
  animation: sweep 1.6s ease-in-out infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(315%); } }

.review-body { padding: 12px 13px; }
#review-text, .suggestion p { font-size: .9rem; line-height: 1.57; overflow-wrap: anywhere; }
#review-again { margin-top: 9px; font-size: .84rem; }
.suggestion { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.suggestion p { flex: 1 1 180px; color: var(--accent); }
.suggestion button { font-size: .82rem; }

.chat { overflow: hidden; }
.chat-heading { padding: 16px; border-bottom: 1px solid var(--line); }
.chat-scroll { height: clamp(230px, 53vh, 500px); overflow-y: auto; overscroll-behavior: contain; padding: 15px 13px; }
.chat-empty { color: var(--muted); font-size: .86rem; line-height: 1.5; }
#messages { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.message { padding: 9px 11px; border-radius: 13px; border: 1px solid var(--line); background: var(--field); min-width: 0; }
.message[data-role="user"] { justify-self: end; max-width: 90%; background: #272445; }
.message strong { color: var(--accent); font-size: .78rem; }
.message p { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .89rem; line-height: 1.5; }
.message p.is-status { color: var(--muted); }
.message button { margin-top: 6px; min-height: 36px; font-size: .8rem; }
.chat-form { display: grid; gap: 8px; padding: 11px 13px 13px; border-top: 1px solid var(--line); }
.chat-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.check { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: .83rem; }
.check input { accent-color: var(--accent); }

dialog {
  background: var(--surface);
  color: var(--ink);
  padding: 19px;
  width: min(460px, calc(100% - 24px));
  border-radius: 18px;
  border: 1px solid var(--line);
}
dialog::backdrop { background: #060814bf; }
dialog h2 { margin-bottom: 13px; }
dialog label:not(:first-of-type) { margin-top: 12px; }

@media (max-width: 740px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .chat-scroll { height: clamp(200px, 46vh, 360px); }
}

@media (max-width: 495px) {
  .topbar-inner { gap: 8px 10px; }
  .brand { order: 0; }
  .server-actions { order: 1; gap: 5px; }
  .model-status { min-height: 34px; font-size: .72rem; }
  .project-picker { flex: 1 0 100%; order: 2; }
  .project-picker select { width: 100%; }
  .board-heading { padding: 14px 13px 5px; }
  .idea-entry input { padding-left: 7px; font-size: .87rem; padding-right: 68px; }
  .idea-entry button { padding-inline: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}
