:root {
  --bg: #080c16;
  --bg-elev: #101726;
  --bg-card: rgba(20, 29, 48, 0.88);
  --border: rgba(148, 163, 184, 0.14);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --purple: #a78bfa;
  --amber: #fbbf24;
  --emerald: #34d399;
  --danger: #f87171;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  word-break: keep-all;
  overflow-wrap: break-word;
  overscroll-behavior: none;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  html, body {
    height: 100vh;
    min-height: 100vh;
  }
}

.hidden {
  display: none !important;
}

/* iOS PWA & Safari 100% fullscreen container (no height: 100dvh override so bottom: 0 reaches physical edge) */
.app-shell {
  position: fixed;
  top: 0;
  right: 0;
  bottom: var(--kb-offset, 0px);
  left: 0;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% 24%, #111a30 0%, var(--bg) 65%);
}

/* Top bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(4px + env(safe-area-inset-top)) 10px 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.room-heading-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
  width: 100%;
  line-height: 1.25;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 3px 6px;
  margin-left: -2px;
  color: inherit;
  cursor: pointer;
  text-align: left;
  max-width: 100%;
  overflow: hidden;
}

.room-heading-btn:active {
  background: rgba(148, 163, 184, 0.12);
}

.room-chevron {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.room-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.brand-dot.online {
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}

.brand-dot.agy-connected {
  background: var(--purple);
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.85);
}

.brand-dot.working {
  background: var(--amber);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
}

.room-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-sub {
  display: block;
  width: 100%;
  max-width: 100%;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#btn-refresh.spinning svg {
  animation: spin 0.7s linear infinite;
}

.icon-btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.active-driving {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.5);
  color: var(--emerald);
}

/* Setup banner */
.setup-banner {
  padding: 8px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.banner-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(96, 165, 250, 0.32);
  font-size: 12px;
}

.banner-item.banner-warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(251, 191, 36, 0.35);
}

/* Main stage */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 10px;
  position: relative;
  overflow-x: hidden;
}

.orb-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 0 6px;
  flex: 1 1 auto;
  transition: all 0.25s ease;
}

.orb-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

/* Compact voice bar when chat has messages */
.stage.has-messages .orb-zone {
  flex: 0 0 auto;
  flex-direction: row;
  justify-content: flex-start;
  gap: 8px;
  padding: 4px 9px;
  margin: 3px 0 2px;
  background: rgba(16, 23, 38, 0.85);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.stage.has-messages .voice-orb {
  width: 32px;
  height: 32px;
}

.stage.has-messages .orb-core {
  width: 28px;
  height: 28px;
}

.stage.has-messages .orb-core svg {
  width: 15px;
  height: 15px;
}

.stage.has-messages .orb-meta {
  margin-top: 0;
  align-items: flex-start;
  min-width: 0;
  flex: 1;
}

.stage.has-messages .orb-state-label {
  margin-top: 0;
  text-align: left;
  font-size: 12px;
}

.speaker-mute-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.stage:not(.has-messages) .speaker-mute-btn {
  margin-top: 8px;
}

.stage.has-messages .speaker-mute-btn {
  margin-left: auto;
  margin-top: 0;
  padding: 4px 9px;
}

.speaker-mute-btn.muted {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.volume-slider {
  width: 100%;
  accent-color: var(--accent);
  margin: 4px 0;
}

.volume-val {
  color: var(--accent);
  font-weight: 700;
  margin-left: 6px;
}

.stage.has-messages .skill-strip {
  padding: 1px 0 2px;
  margin-bottom: 1px;
}

.stage.has-messages .skill-pill {
  padding: 3px 9px;
  font-size: 11px;
}

.voice-orb {
  position: relative;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.14s ease-out;
  flex-shrink: 0;
}

.orb-core {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #3b4b6b, #172033 75%);
  border: 1.5px solid rgba(148, 163, 184, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.14);
}

.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  opacity: 0;
  pointer-events: none;
}

.voice-orb.state-listening .orb-core {
  background: radial-gradient(circle at 32% 30%, #60a5fa, #2563eb 78%);
  border-color: #93c5fd;
  box-shadow: 0 0 36px rgba(59, 130, 246, 0.55);
}

.voice-orb.state-listening .ring-1 {
  border-color: rgba(96, 165, 250, 0.55);
  opacity: 1;
  animation: pulse-ring 1.8s infinite ease-out;
}

.voice-orb.state-working .orb-core {
  background: radial-gradient(circle at 32% 30%, #fbbf24, #d97706 78%);
  border-color: #fde68a;
  box-shadow: 0 0 36px rgba(251, 191, 36, 0.5);
}

.voice-orb.state-working .ring-1 {
  border-color: rgba(251, 191, 36, 0.65);
  opacity: 1;
  animation: spin-ring 1.4s infinite linear;
}

.voice-orb.state-speaking .orb-core {
  background: radial-gradient(circle at 32% 30%, #c084fc, #7c3aed 78%);
  border-color: #e9d5ff;
  box-shadow: 0 0 38px rgba(167, 139, 250, 0.6);
}

.voice-orb.state-speaking .ring-1,
.voice-orb.state-speaking .ring-2 {
  border-color: rgba(192, 132, 252, 0.55);
  opacity: 1;
  animation: pulse-ring 1.3s infinite ease-out;
}

.voice-orb.state-speaking .ring-2 {
  animation-delay: 0.55s;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.84);
    opacity: 0.85;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

@keyframes spin-ring {
  0% {
    transform: rotate(0deg) scale(1.04);
    border-style: dashed;
  }
  100% {
    transform: rotate(360deg) scale(1.04);
    border-style: dashed;
  }
}

.orb-state-label {
  font-size: 13.5px;
  color: var(--text-muted);
  text-align: center;
}

.mic-meter {
  width: 140px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

#mic-meter-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #60a5fa, #34d399);
  transition: width 0.06s linear;
}

.agy-chip-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  font-size: 12px;
  color: #fde68a;
}

.chip-spinner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(253, 230, 138, 0.35);
  border-top-color: #fbbf24;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.live-caption {
  margin: 2px 0 4px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.live-caption.is-hearing {
  border-color: rgba(56, 189, 248, 0.78);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.16), 0 6px 18px rgba(0, 0, 0, 0.28);
}

.caption-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  overflow: visible;
}

.caption-row-ai {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.caption-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  flex-shrink: 0;
  margin-top: 1px;
}

.user-badge {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}

.ai-badge {
  background: rgba(129, 140, 248, 0.18);
  color: #c7d2fe;
}

.caption-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.6);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.live-caption.is-hearing .caption-dot {
  background: #34d399;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.9);
  animation: captionPulse 0.9s ease-in-out infinite;
}

@keyframes captionPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.35);
    opacity: 0.65;
  }
}

.caption-text {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  line-height: 20px;
  color: #f8fafc;
  word-break: keep-all;
  overflow-wrap: anywhere;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.caption-text::-webkit-scrollbar {
  display: none;
}

.caption-row-user .caption-text {
  max-height: 40px;
}

.caption-row-ai .caption-text {
  max-height: 60px;
}

.caption-text.caption-placeholder {
  font-size: 13px;
  color: rgba(148, 163, 184, 0.78);
}

.caption-text.caption-interim {
  color: #bae6fd;
}

/* Quick suggestions when empty */
.empty-hint {
  margin: auto 0 4px;
  padding: 0 0 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.quick-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 100%;
}

.quick-chip {
  background: rgba(16, 23, 38, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 12px;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
}

.quick-chip:active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(96, 165, 250, 0.4);
}

/* Chat log */
.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 8px;
  scroll-padding-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.chat-log > * {
  flex-shrink: 0;
}

.stage:not(.has-messages) .chat-log {
  display: none;
}

.msg {
  max-width: 92%;
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.msg-user {
  align-self: flex-end;
  background: rgba(59, 130, 246, 0.24);
  border: 1px solid rgba(96, 165, 250, 0.35);
  border-bottom-right-radius: 4px;
}

.msg-assistant {
  align-self: flex-start;
  max-width: 95%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.agy-card {
  align-self: stretch;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: rgba(16, 23, 38, 0.95);
  border: 1px solid rgba(167, 139, 250, 0.32);
  border-radius: 14px;
  padding: 10px 12px;
}

.agy-card.notion-card {
  border-color: rgba(52, 211, 153, 0.36);
}

.agy-card.notion-card .agy-card-head {
  color: var(--emerald);
}

.agy-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--purple);
  font-weight: 700;
}

.agy-card-body {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
}

.msg pre,
.agy-card-body pre {
  background: #020617;
  padding: 8px 10px;
  border-radius: 10px;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.45;
  margin: 6px 0;
}

.msg code,
.agy-card-body code {
  background: rgba(148, 163, 184, 0.16);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.5px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg pre code,
.agy-card-body pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg h2,
.msg h3,
.msg h4,
.agy-card-body h2,
.agy-card-body h3,
.agy-card-body h4 {
  margin: 6px 0 3px;
  font-size: 14px;
  line-height: 1.4;
}

.msg a,
.agy-card-body a {
  color: var(--accent);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg img,
.agy-card-body img {
  max-width: 100%;
  height: auto;
}

.msg table,
.agy-card-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.agy-steps-details {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.agy-steps-details summary {
  cursor: pointer;
}

.agy-live-steps {
  font-size: 12px;
  color: #cbd5e1;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agy-live-steps:empty {
  display: none;
}

.agy-live-step-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Text input bar */
.text-input-bar {
  display: flex;
  gap: 8px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  flex-shrink: 0;
}

.text-input-bar input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 11px;
  font-size: 14px;
}

/* Bottom dock (slim padding tuned for iOS home indicator without extra dead space) */
.bottom-dock {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  gap: 4px;
  padding: 4px 8px max(4px, calc(env(safe-area-inset-bottom, 0px) - 24px));
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 0;
  border-radius: 10px;
}

.dock-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.dock-btn.active {
  color: var(--accent);
}

.dock-btn.navi-mode {
  color: #2dd4bf;
}

.dock-label {
  font-size: 10.5px;
  line-height: 1.15;
}

.mic-main-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.42);
  transition: transform 0.12s ease, background 0.2s ease;
}

.mic-main-btn:active {
  transform: scale(0.93);
}

.mic-main-btn.active {
  background: linear-gradient(135deg, #ef4444, #f97316);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.45);
}

/* Rooms Slide Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  z-index: 60;
  display: flex;
}

.rooms-drawer {
  width: min(86vw, 340px);
  height: 100%;
  background: #0d1322;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 18px 0 48px rgba(0, 0, 0, 0.6);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 17px;
}

.drawer-main-tabs {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.drawer-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#drawer-panel-projects {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}

#agy-projects-list,
#projects-list {
  overflow: visible;
  flex: 0 0 auto;
}

.drawer-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.drawer-section-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 12px 2px 6px;
}

.project-item {
  width: 100%;
  text-align: left;
  background: rgba(16, 23, 38, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.project-item.active {
  border-color: var(--purple);
  background: rgba(167, 139, 250, 0.14);
}

#btn-select-general.active {
  border-color: var(--emerald);
  background: rgba(52, 211, 153, 0.12);
}

.project-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.project-item-path {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.18);
  color: #ddd6fe;
  flex-shrink: 0;
}

.project-tag.general {
  background: rgba(52, 211, 153, 0.18);
  color: #a7f3d0;
}

.project-tag.folder {
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
}

.project-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.project-row .project-item {
  flex: 1;
  min-width: 0;
}

.project-persona-btn {
  background: rgba(16, 23, 38, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 0 9px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.project-persona-btn.has-persona {
  border-color: rgba(167, 139, 250, 0.45);
  color: #ddd6fe;
  background: rgba(167, 139, 250, 0.12);
}

.persona-preview-box {
  margin: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.field textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
  resize: vertical;
}

.drawer-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.drawer-search {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-strong);
  color: #ffffff;
}

.rooms-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-item {
  width: 100%;
  text-align: left;
  background: rgba(16, 23, 38, 0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.room-item.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.16);
}

.room-item-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.room-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.room-source-tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
}

.room-source-tag.desktop {
  background: rgba(167, 139, 250, 0.2);
  color: #ddd6fe;
}

.room-source-tag.cli {
  background: rgba(52, 211, 153, 0.18);
  color: #a7f3d0;
}

.room-source-tag.voice {
  background: rgba(56, 189, 248, 0.18);
  color: #bae6fd;
}

.room-project-tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.room-row .room-item {
  flex: 1;
  min-width: 0;
}

.room-copy-btn {
  width: 36px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.room-copy-btn:active {
  background: rgba(56, 189, 248, 0.18);
  color: #e0f2fe;
}

.room-delete-btn {
  width: 34px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
}

.room-delete-btn:hover,
.room-delete-btn:active {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.settings-quick-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.settings-quick-btn {
  padding: 9px 10px;
  font-size: 12.5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  text-align: center;
}

.project-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}

.project-expand-btn {
  width: 30px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
}

.project-room-count {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  font-size: 10.5px;
  font-weight: 600;
  flex-shrink: 0;
}

.project-rooms-sub {
  margin: 5px 0 6px 10px;
  padding-left: 10px;
  border-left: 1px solid rgba(148, 163, 184, 0.22);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.project-new-room-btn {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
  color: #bae6fd;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.project-new-room-btn:active {
  background: rgba(56, 189, 248, 0.18);
}

.project-sub-row {
  display: flex;
  align-items: stretch;
  gap: 5px;
}

.project-sub-room {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.project-sub-room.active {
  border-color: rgba(167, 139, 250, 0.6);
  background: rgba(167, 139, 250, 0.14);
}

.project-sub-title {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-sub-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
}

.rooms-project-filter-btn {
  width: 100%;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  cursor: pointer;
}

.rooms-project-filter-btn.active {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.16);
  color: #e0f2fe;
  font-weight: 600;
}

.rooms-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
}

/* Buttons */
.btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #ffffff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-xs {
  padding: 5px 10px;
  font-size: 11.5px;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
  padding: 11px;
}

/* Overlays & Modals */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 70;
}

.auth-card, .modal-card {
  width: 100%;
  max-width: 420px;
  background: #0f172a;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  max-height: 88dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

.auth-card {
  text-align: center;
}

.auth-icon-wrap {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  box-shadow: 0 10px 26px rgba(59, 130, 246, 0.28);
}

.auth-app-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
}

.auth-desc {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  text-align: center;
  font-size: 20px;
  letter-spacing: 0.25em;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
}

.field select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px 15px;
}

.field textarea {
  resize: vertical;
  font-family: inherit;
  line-height: 1.45;
}

.field small {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.field small a {
  color: var(--accent);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 480px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.field-check label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
}

.field-check input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.field-check-hint {
  display: block;
  margin: 4px 0 0 26px;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.4;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* 설정 모달 전용 카드 · 스크롤 · 하단 고정 바 */
.settings-modal-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 88dvh;
}

.settings-modal-card .modal-header {
  padding: 16px 18px 12px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.settings-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-group {
  background: rgba(8, 12, 22, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
}

.settings-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.settings-modal-card .modal-footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  margin-top: 0;
  border-top: 1px solid var(--border);
  background: #0f172a;
  flex-shrink: 0;
}

.settings-modal-card .modal-footer button[type="submit"] {
  margin-left: auto;
}

.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

.badge.ok {
  background: rgba(52, 211, 153, 0.2);
  color: var(--emerald);
}

.badge.warn {
  background: rgba(251, 191, 36, 0.2);
  color: var(--amber);
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

.qr-body {
  text-align: center;
}

.qr-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.qr-box {
  background: #ffffff;
  padding: 12px;
  border-radius: 14px;
  display: inline-block;
  margin: 0 auto;
}

.qr-box img {
  display: block;
  width: 210px;
  height: 210px;
}

.pin-box {
  font-size: 14px;
  background: var(--bg);
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.pin-box strong {
  font-size: 18px;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-left: 6px;
}

.url-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.url-item {
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.url-label {
  color: var(--text-muted);
  font-size: 11px;
}

.perm-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.perm-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.perm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.perm-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 7px 9px;
  border-radius: 9px;
  cursor: pointer;
}

.perm-toggle input {
  accent-color: var(--accent);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.approval-voice-hint {
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.42);
  color: #a7f3d0;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.45;
}

.approval-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.approval-prompt {
  font-size: 13.5px;
  line-height: 1.5;
  margin-top: 4px;
  color: var(--text);
}

.approval-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 90;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

@media (max-width: 420px) {
  .top-actions {
    gap: 4px;
  }
  .top-actions .icon-btn {
    width: 34px;
    height: 34px;
  }
}

/* Antigravity Voice Skill Strip */
.skill-strip {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  padding: 2px 0 4px;
  margin-bottom: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

.skill-strip::-webkit-scrollbar {
  display: none;
}

.skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.78);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.skill-pill.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.65);
  color: #e0f2fe;
  font-weight: 600;
}

.skill-pill.manage-pill {
  border-style: dashed;
  color: #94a3b8;
}

/* Skills Management Modal */
.skills-tabs {
  margin-bottom: 12px;
}

.skills-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.skill-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skill-card.disabled {
  opacity: 0.6;
}

.skill-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.skill-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.skill-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.skill-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.skill-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.skill-switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.skill-editor-box {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.skill-editor-row {
  display: flex;
  gap: 8px;
}

.skill-project-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 110px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.skill-project-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
}

.agy-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
