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

:root {
  --bg: #FFFFFF;
  --card-bg: #F8F8F8;
  --card-border: #E5E5E5;
  --accent: #333333;
  --text: #333333;
  --text-light: #999999;
  --bubble-self: #E8E8E8;
  --bubble-other: #FFFFFF;
  --tab-bg: #FFFFFF;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(135deg, #e8ddd3 0%, #d4c5b5 25%, #c9bfb3 50%, #ddd5cb 75%, #e5dcd2 100%);
  color: var(--text);
  overflow: hidden;
}

/* --- Pages --- */
.page {
  display: none;
  flex-direction: column;
  height: calc(100% - 68px - var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.page.active { display: flex; }
.page.immersive { height: 100%; }

.page-header {
  padding: 4px 20px 4px;
  padding-top: env(safe-area-inset-top, 0px);
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.42);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.45);
  z-index: 10;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 500;
  color: var(--accent);
  display: inline-block;
  padding: 6px 18px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
}

/* --- Tab Bar --- */
.tab-bar {
  position: fixed;
  bottom: 8px;
  left: 12px;
  right: 12px;
  display: flex;
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 20px;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.04);
}
.tab-bar.hidden { display: none; }
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  cursor: pointer;
  transition: color 0.2s;
  color: var(--text-light);
}
.tab.active { color: var(--accent); }
.tab-icon { width: 24px; height: 24px; }
.tab-icon svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --- Chat List --- */
.chat-list { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.chat-item:active { background: rgba(255, 255, 255, 0.6); }
.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  flex-shrink: 0;
}
.chat-info { flex: 1; min-width: 0; }
.chat-name { font-size: 15px; font-weight: 500; }
.chat-preview { font-size: 13px; color: var(--text-light); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-meta { font-size: 11px; color: var(--text-light); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.chat-date { font-size: 11px; }
.chat-time { font-size: 11px; }
.unread-badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* --- Chat List --- */
#page-chat { position: relative; }
#page-chat::before {
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 0;
  pointer-events: none;
}

/* --- Chat Detail --- */
#page-chat-detail {
  background: #F5F5F5;
  background-color: #F0F0F0;
  position: relative;
}
.glass-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 0;
  pointer-events: none;
}
#page-chat-detail > *:not(.gallery-picker):not(.file-picker):not(.glass-overlay) { position: relative; z-index: 1; }

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: transparent;
  position: sticky;
  top: 0;
  z-index: 10;
}
.back-btn, .menu-btn {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  font-size: 18px;
  color: var(--accent);
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chat-header-name {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4px 18px;
  background: transparent;
  border: none;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  display: flex;
  gap: 8px;
  max-width: 80%;
}
.msg.self { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.msg-bubble {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.msg-bubble code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'Menlo', 'SF Mono', monospace;
  color: #888;
}
.msg-bubble strong {
  font-weight: 600;
}
.msg-bubble em {
  font-style: italic;
  color: #666;
}
.msg-bubble pre {
  background: rgba(0,0,0,0.06);
  padding: 8px 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 4px 0;
}
.msg-bubble pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}

/* Tool call collapsed */
.tool-msg-collapsed {
  padding: 0 12px;
}
.tool-msg-header {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #aaa;
  padding: 2px 0;
  user-select: none;
}
.tool-msg-icon { font-size: 11px; }
.tool-msg-name { font-size: 12px; }
.tool-msg-time { margin-left: 6px; font-size: 10px; opacity: 0.5; }
.tool-msg-chevron {
  margin-left: 2px;
  font-size: 11px;
  transition: transform 0.2s;
  opacity: 0.4;
}
.tool-msg-expanded .tool-msg-chevron { transform: rotate(90deg); }
.tool-msg-body {
  display: none;
  font-size: 12px;
  color: #999;
  padding: 4px 0 4px 20px;
  max-height: 300px;
  overflow-y: auto;
}
.tool-msg-expanded .tool-msg-body { display: block; }
.tool-msg-body code {
  background: rgba(0,0,0,0.05);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
.tool-msg-body pre {
  background: rgba(0,0,0,0.04);
  padding: 6px 8px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 2px 0;
  font-size: 11px;
}
.tool-msg-body pre code { background: none; padding: 0; }

/* Tool group (multiple calls collapsed into one) */
.tool-group-collapsed { padding: 0 12px; }
.tool-group-header {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #aaa;
  padding: 2px 0;
  user-select: none;
}
.tool-group-label { font-size: 12px; }
.tool-group-body { display: none; padding-left: 20px; }
.tool-group-expanded .tool-group-body { display: block; }
.tool-group-expanded .tool-msg-chevron { transform: rotate(90deg); }
.tool-group-item {
  border-left: 1px solid rgba(0,0,0,0.08);
  padding: 3px 0 3px 8px;
  margin: 2px 0;
}
.tool-group-item-name {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 2px;
}
.tool-group-item-body {
  font-size: 11px;
  color: #999;
  max-height: 200px;
  overflow-y: auto;
}
.tool-group-item-body code {
  background: rgba(0,0,0,0.05);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}
.tool-group-item-body pre {
  background: rgba(0,0,0,0.04);
  padding: 4px 6px;
  border-radius: 4px;
  overflow-x: auto;
  margin: 2px 0;
  font-size: 10px;
}
.tool-group-item-body pre code { background: none; padding: 0; }
.msg:not(.self) .msg-bubble {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.10);
}
.msg.self .msg-bubble {
  background: rgba(51, 51, 51, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(51, 51, 51, 0.08);
  color: #333;
}
.msg-time {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 4px;
  text-align: right;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 20px;
  background: transparent;
}
.chat-input-bar input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 22px;
  font-size: 15px;
  outline: none;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.chat-input-bar input:focus { border-color: var(--accent); }
.input-btn {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--accent);
}

/* --- Terminal --- */
#page-terminal {
  background: #1e1e1e;
}
#page-terminal.immersive {
  height: 100%;
}
.terminal-tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top, 0px);
  background: #2d2d2d;
  overflow-x: auto;
}
.term-tab {
  padding: 8px 16px;
  font-size: 13px;
  color: #aaa;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.term-tab.active { color: #fff; border-bottom-color: var(--accent); }
.term-tab-add {
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 12px;
}
.terminal-container {
  flex: 1;
  background: #1e1e1e;
  padding: 8px;
  overflow: hidden;
}
.terminal-container.hidden { display: none; }
.terminal-container .xterm-viewport {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* Activity Stream */
.activity-container {
  flex: 1;
  background: #1a1a1a;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  font-family: 'Menlo', 'DejaVu Sans Mono', monospace;
  font-size: 13px;
  color: #c8c8c8;
}
.activity-container.hidden { display: none; }
.act-entry { margin-bottom: 8px; line-height: 1.5; }
.act-entry .act-time { color: #555; font-size: 11px; margin-right: 8px; }
.act-entry .act-icon { margin-right: 4px; }
.act-chunk { color: #d4d4d4; white-space: pre-wrap; word-break: break-word; }
.act-tool { color: #9cdcfe; }
.act-tool .act-summary { color: #808080; margin-left: 4px; }
.act-thinking { color: #6a9955; cursor: pointer; }
.act-thinking-content {
  display: none;
  color: #6a9955;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 4px 0 4px 20px;
  opacity: 0.8;
  max-height: 300px;
  overflow-y: auto;
}
.act-thinking.expanded .act-thinking-content { display: block; }
.act-status { color: #569cd6; font-style: italic; }
.act-empty { color: #555; text-align: center; padding: 40px 0; }

.term-key-exit {
  background: #553333 !important;
  border-color: #774444 !important;
  color: #ff9999 !important;
}
.term-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px calc(8px + var(--safe-bottom));
  background: #1e1e1e;
}
.term-input-bar input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #444;
  border-radius: 22px;
  font-size: 15px;
  outline: none;
  background: #2a2a2a;
  color: #d4d4d4;
  font-family: 'Menlo', 'DejaVu Sans Mono', monospace;
}
.term-input-bar input:focus { border-color: var(--accent); }

.term-shortcut-bar {
  display: flex;
  gap: 6px;
  padding: 4px 12px;
  background: #252525;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.term-key {
  flex-shrink: 0;
  padding: 5px 10px;
  border: 1px solid #555;
  border-radius: 6px;
  background: #333;
  color: #ccc;
  font-size: 12px;
  font-family: 'Menlo', 'DejaVu Sans Mono', monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.term-key:active { background: #555; }

/* --- Dashboard --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 20px;
}
.dash-card {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.dash-card:active { background: rgba(255, 255, 255, 0.6); }
.card-icon { font-size: 28px; margin-bottom: 8px; }
.card-title { font-size: 14px; font-weight: 500; color: var(--accent); }
.card-desc { font-size: 11px; color: var(--text-light); margin-top: 4px; }

/* --- Settings --- */
.settings-list { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  cursor: pointer;
  font-size: 15px;
}
.settings-item:active { background: rgba(255, 255, 255, 0.6); }
.settings-arrow { color: var(--text-light); }
.settings-footer {
  text-align: center;
  padding: 30px;
  font-size: 12px;
  color: var(--text-light);
}

/* --- Header name with status --- */
.header-name-text { font-size: 15px; font-weight: 500; }
.header-status { font-size: 11px; color: var(--text-light); margin-top: 1px; }

/* --- Chat Menu --- */
.chat-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(0,0,0,0.1);
}
.chat-menu-overlay.hidden { display: none; }
.chat-menu {
  position: fixed;
  top: calc(44px + env(safe-area-inset-top, 0px));
  right: 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(200, 200, 200, 0.5);
  border-radius: 16px;
  padding: 6px 0;
  min-width: 180px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  z-index: 999;
}
.chat-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 16px;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.92);
  border-left: 1px solid rgba(200, 200, 200, 0.5);
  border-top: 1px solid rgba(200, 200, 200, 0.5);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}
.chat-menu[style*="left"]::before {
  right: auto;
  left: 16px;
}
.chat-menu.hidden { display: none; }
.chat-menu-item {
  padding: 12px 18px;
  font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  display: flex; align-items: center; gap: 10px;
}
.menu-icon {
  width: 18px; height: 18px; stroke: #999; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.chat-menu-item:active { background: rgba(0, 0, 0, 0.05); border-radius: 10px; }

/* --- Appearance Panel --- */
.appearance-panel {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px 20px 0 0;
  padding: 16px;
  z-index: 15;
}
.appearance-panel.hidden { display: none; }
.appearance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 500;
}
.appearance-header button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-light);
}
.appearance-section {
  margin-bottom: 14px;
}
.appearance-section label {
  display: block;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}
.appearance-section input[type="file"] {
  font-size: 13px;
}
.avatar-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.5);
}
.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.color-picker-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.color-picker-row input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}
.color-picker-row input[type="text"] {
  flex: 1;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 12px;
  background: rgba(255,255,255,0.3);
  font-size: 13px;
  outline: none;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.slider-row input[type="range"] {
  flex: 1;
  accent-color: #333;
}
.slider-row span {
  font-size: 13px;
  color: var(--text-light);
  min-width: 36px;
  text-align: right;
}

/* --- Typing indicator --- */
.typing-indicator .msg-bubble { opacity: 0.6; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 0.6; } 50% { opacity: 0.3; } }

/* --- Agent Menu (floating cards) --- */
.agent-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.1);
  z-index: 998;
}
.agent-menu-overlay.hidden { display: none; }
.agent-menu-cards {
  position: fixed;
  bottom: 70px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.agent-menu-cards.hidden { display: none; }
.agent-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.agent-card:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.98);
}
.agent-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

/* --- Agent Detail Panel --- */
.agent-detail-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(248, 248, 248, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px 24px 0 0;
  padding: 0 20px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
}
.agent-detail-panel.hidden { display: none; }
.agent-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 12px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}
.agent-detail-header button {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-light);
  cursor: pointer;
}
.agent-detail-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-detail-body textarea {
  width: 100%;
  min-height: 220px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  padding: 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: none;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  box-sizing: border-box;
}
.agent-detail-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.agent-detail-body textarea::placeholder {
  color: var(--text-light);
}
.glass-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.glass-btn:active { background: rgba(255, 255, 255, 0.6); }

/* --- Notes --- */
.notes-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.notes-header-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.notes-history-btn, .notes-back-btn, .notes-new-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.notes-history-btn svg {
  fill: currentColor;
  stroke: none;
}
.notes-back-btn svg, .notes-new-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.notes-history-btn .notes-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 50vh;
}
.note-item {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s;
}
.note-item:active { background: rgba(255, 255, 255, 0.65); }
.note-item-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}
.note-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.note-item-time {
  font-size: 12px;
  color: var(--text-light);
}
.note-item-del {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 2px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.note-item-del:active { opacity: 1; }
.note-item-del svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cot-display {
  min-height: 200px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-y: auto;
}
.model-dropdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.model-dropdown-arrow {
  color: var(--text-light);
  font-size: 12px;
}
.model-dropdown-list {
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
}
.model-dropdown-list.hidden { display: none; }
.model-dropdown-list .model-search {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.model-dropdown-list .model-search::placeholder { color: var(--text-light); }
.model-scroll-wrap {
  position: relative;
}
.model-scroll-wrap::after {
  content: '';
  position: sticky;
  bottom: 0;
  display: block;
  height: 28px;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.55));
  pointer-events: none;
  border-radius: 0 0 16px 16px;
}
.model-scroll {
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.model-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 14px 4px;
}
.model-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.api-field label {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.api-field input, .api-field select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 14px;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
}
.api-field input:focus, .api-field select:focus { border-color: var(--accent); }
.model-item {
  padding: 10px 14px;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text);
}
.model-item:active { background: rgba(0, 0, 0, 0.04); }
.model-item.active {
  background: rgba(51, 51, 51, 0.08);
  color: var(--accent);
}


/* --- Message delivery status --- */
.msg-status {
  font-size: 14px;
  color: var(--text-light);
  margin-left: 4px;
  display: inline-block;
  vertical-align: middle;
}
.msg-status.sending {
  animation: spin 1s linear infinite;
  display: inline-block;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.msg-status.delivered {
  color: var(--accent);
  animation: none;
}
.msg-status.failed {
  color: #e55;
  animation: none;
  font-size: 12px;
}

/* --- Chat List Header --- */
.chatlist-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.chatlist-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 8px rgba(180,180,180,0.10);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
}
.chatlist-btn svg { width: 18px; height: 18px; stroke: #666; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chatlist-title { flex: 1; text-align: center; }
.chatlist-title-main { font-size: 16px; font-weight: 600; color: #333; }

/* --- Global Search Bar (chat list header) --- */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 22px;
}
.search-icon {
  font-size: 14px;
  color: var(--text-light);
  flex-shrink: 0;
}
.search-icon-svg {
  width: 16px; height: 16px;
  stroke: var(--text-light); fill: none;
  stroke-width: 2; stroke-linecap: round;
  flex-shrink: 0;
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
.search-bar input::placeholder {
  color: var(--text-light);
}

/* --- Global Search Results --- */
.global-search-results {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.global-search-results.hidden { display: none; }
.search-result-item {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-result-item:active {
  background: rgba(255, 255, 255, 0.6);
}
.search-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.search-result-channel {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}
.search-result-time {
  font-size: 11px;
  color: var(--text-light);
}
.search-result-snippet {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-result-snippet mark {
  background: rgba(51, 51, 51, 0.15);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

/* --- In-chat Search Panel --- */
.chat-search-panel {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  padding: 8px 12px;
  z-index: 12;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
}
.chat-search-panel.hidden { display: none; }
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-search-bar input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 14px;
  color: var(--text);
  outline: none;
}
.chat-search-bar input:focus {
  border-color: var(--accent);
}
.chat-search-bar input::placeholder {
  color: var(--text-light);
}
.chat-search-close {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
}
.chat-search-results {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 35vh;
}
.chat-search-result {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-search-result:active {
  background: rgba(255, 255, 255, 0.55);
}
.chat-search-result-time {
  font-size: 10px;
  color: var(--text-light);
  margin-bottom: 2px;
}
.chat-search-result-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.chat-search-result-text mark {
  background: rgba(51, 51, 51, 0.15);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

/* --- Shared --- */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-light);
  font-size: 14px;
}

/* --- Attachment Menu --- */
.attach-menu {
  background: transparent;
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 200px;
}
.attach-menu.hidden { max-height: 0; border-top: none; }
.attach-menu-content { display: flex; flex-direction: column; }
.attach-recents {
  min-height: 140px;
  overflow-y: auto;
  padding: 16px;
}
.attach-recents-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  font-size: 14px;
}
.attach-tabs {
  display: flex;
  justify-content: space-around;
  padding: 12px 8px;
  background: transparent;
}
.attach-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 4px;
}
.attach-tab:active .attach-tab-icon { opacity: 0.7; }
.attach-tab-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255,255,255,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.attach-tab-icon svg { width: 24px; height: 24px; fill: #999; }
.attach-tab.active .attach-tab-icon { background: rgba(255,255,255,0.7); }
.attach-tab.active .attach-tab-icon svg { fill: #333; }
.attach-tab-label { font-size: 11px; color: var(--text); }

/* ═══════════════════════════════════════
   GALLERY PICKER — full photo picker
   ═══════════════════════════════════════ */
.gallery-picker {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 250;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}
.gallery-picker.hidden { display: none; }

/* gallery header */
.gallery-header {
  margin: 4px 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.gallery-back-btn {
  width: 40px; height: 40px; border-radius: 14px;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(200,200,200,0.35);
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
}
.gallery-back-btn svg { width: 18px; height: 18px; stroke: #666; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.gallery-header-center { flex: 1; text-align: center; }
.gallery-header-center .gallery-title-main { font-size: 16px; font-weight: 600; color: #333; line-height: 1.2; }
.gallery-header-center .gallery-title-sub { font-size: 12px; color: rgba(120,120,120,0.7); margin-top: 1px; }
.gallery-done-btn {
  padding: 10px 18px; border-radius: 14px;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(200,200,200,0.35);
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
  font-size: 14px; font-weight: 500; color: #555;
  cursor: pointer; flex-shrink: 0;
}

/* album strip */
.gallery-albums {
  display: flex; gap: 6px; padding: 4px 12px; overflow-x: auto;
  scrollbar-width: none; flex-shrink: 0;
}
.gallery-albums::-webkit-scrollbar { display: none; }
.gallery-album-chip {
  padding: 8px 16px; border-radius: 16px;
  background: transparent;
  font-size: 13px; font-weight: 500; color: rgba(150,150,150,0.85);
  white-space: nowrap; cursor: pointer; flex-shrink: 0;
  transition: all 200ms;
}
.gallery-album-chip.active { background: rgba(255,255,255,0.75); color: #333; box-shadow: 0 1px 6px rgba(180,180,180,0.15); }
.gallery-album-chip .album-count { opacity: 0.5; margin-left: 4px; font-weight: 400; }
.gallery-album-chip.active .album-count { opacity: 0.55; }

/* photo grid */
.gallery-grid-scroll { flex: 1; overflow-y: auto; padding: 0 12px; min-height: 0; display: flex; flex-direction: column; }
.gallery-grid-scroll::-webkit-scrollbar { display: none; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255,255,255,0.40);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(220,220,220,0.7);
  padding: 4px;
  box-shadow: 0 8px 32px rgba(180,180,180,0.15), inset 0 1px 0 rgba(255,255,255,0.7);
  flex: 1;
}
.gallery-photo {
  aspect-ratio: 1;
  border-radius: 12px; overflow: hidden;
  position: relative; cursor: pointer;
  background-size: cover; background-position: center;
  transition: transform 180ms cubic-bezier(0.4,0,0.2,1);
}
.gallery-photo:hover { transform: scale(0.98); }
.gallery-photo img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
/* camera tile */
.gallery-photo.camera-tile {
  background: rgba(248,248,248,0.7);
  backdrop-filter: blur(16px);
  border: 0.5px solid rgba(220,220,220,0.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: #999;
}
.gallery-photo.camera-tile svg { width: 24px; height: 24px; stroke: #999; fill: none; stroke-width: 1.6; }
.gallery-photo.camera-tile span { font-size: 10px; color: rgba(120,120,120,0.85); }
/* video badge */
.gallery-video-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(255,255,255,0.50); backdrop-filter: blur(12px);
  border-radius: 8px; padding: 2px 6px;
  font-size: 10px; font-weight: 600; color: #999;
  display: flex; align-items: center; gap: 3px;
}
.gallery-video-badge svg { width: 9px; height: 9px; fill: #999; }
/* selection circle */
.gallery-check {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.35); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  transition: all 180ms;
  z-index: 2;
}
.gallery-photo.selected .gallery-check {
  background: #fff; border-color: rgba(200,200,200,0.5);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.gallery-photo.selected::after {
  content: ''; position: absolute; inset: 0;
  border: 2px solid rgba(255,255,255,0.8); border-radius: 12px;
  pointer-events: none;
}
/* dim non-selected when something is selected */
.gallery-grid.has-selection .gallery-photo:not(.selected):not(.camera-tile) { opacity: 0.85; }

/* gallery empty state */
.gallery-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #999;
  font-size: 15px;
  cursor: pointer;
}

/* bottom area */
.gallery-bottom {
  padding: 4px 12px calc(4px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 4px;
  flex-shrink: 0;
}
/* options pill row */
.gallery-opts {
  display: flex; gap: 6px; padding: 0 2px;
}
.gallery-opt {
  flex: 1;
  padding: 9px 10px; border-radius: 14px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(220,220,220,0.75);
  font-size: 12px; font-weight: 500; color: rgba(120,120,120,0.85);
  text-align: center; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: background 200ms;
}
.gallery-opt:hover { background: rgba(255,255,255,0.7); }
.gallery-opt svg { width: 13px; height: 13px; stroke: rgba(120,120,120,0.85); fill: none; stroke-width: 1.8; }
.gallery-opt.active { color: #333; background: rgba(255,255,255,0.75); border-color: rgba(200,200,200,0.3); box-shadow: 0 1px 6px rgba(180,180,180,0.15); }
.gallery-opt.active svg { stroke: #333; }

/* send bar */
.gallery-send-bar {
  padding: 6px 8px 6px 14px;
  border-radius: 28px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid rgba(180,180,180,0.30);
  box-shadow: 0 6px 24px rgba(180,180,180,0.20), inset 0 1px 0 rgba(255,255,255,0.7);
  display: flex; align-items: center; gap: 10px;
}
.gallery-caption-input {
  flex: 1;
  background: transparent; border: 0; outline: 0;
  color: #555; font-size: 15px; font-family: inherit;
  padding: 4px 6px;
}
.gallery-caption-input::placeholder { color: rgba(150,150,150,0.7); }
.gallery-send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.75);
  border: 0.5px solid rgba(200,200,200,0.35);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
  transition: transform 120ms;
  position: relative;
}
.gallery-send-btn:active { transform: scale(0.94); }
.gallery-send-btn svg { width: 18px; height: 18px; fill: none; stroke: #333; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gallery-send-btn.disabled { background: rgba(240,240,240,0.5); }
.gallery-send-btn.disabled svg { stroke: rgba(180,180,180,0.5); }
.gallery-send-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: #fff; border: 1.5px solid #B0B0B0;
  color: #666; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}
.gallery-send-badge.hidden { display: none; }

/* ═══════════════════════════════════════
   PHOTO EDITOR — full-screen overlay
   ═══════════════════════════════════════ */
.gallery-editor {
  position: absolute;
  inset: 0;
  z-index: 300;
  background: rgba(250,250,250,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 360ms cubic-bezier(0.32, 0.72, 0, 1);
}
.gallery-editor.open { transform: translateY(0); }
.gallery-editor.hidden { display: none; }

/* editor top bar */
.ed-top {
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.ed-top .ed-close-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(20px);
  border: 0.5px solid rgba(180,180,180,0.30);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.ed-top .ed-close-btn svg { width: 18px; height: 18px; stroke: #999; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ed-top .ed-title { font-size: 16px; font-weight: 600; color: #555; }
.ed-top .ed-done-btn {
  padding: 8px 18px; border-radius: 14px;
  background: rgba(255,255,255,0.65); color: #555;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 0.5px solid rgba(200,200,200,0.35);
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
}

/* canvas (photo viewport) */
.ed-canvas {
  flex: 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 12px;
  overflow: hidden;
  min-height: 35vh;
}
.ed-photo {
  width: 100%; height: 100%;
  border-radius: 6px;
  background-size: contain; background-position: center; background-repeat: no-repeat;
  position: relative;
  box-shadow: 0 10px 30px rgba(180,180,180,0.15), 0 0 0 1px rgba(220,220,220,0.5);
}

/* crop tab UI */
.crop-frame {
  position: absolute; inset: 12% 8% 18% 8%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(51,51,51,0.10), 0 0 24px rgba(255,255,255,0.5);
}
.crop-frame::before, .crop-frame::after,
.crop-grid::before, .crop-grid::after {
  content: ''; position: absolute; background: rgba(255,255,255,0.5);
}
.crop-frame::before { top: 33.33%; left: 0; right: 0; height: 1px; }
.crop-frame::after  { top: 66.66%; left: 0; right: 0; height: 1px; }
.crop-grid { position: absolute; inset: 0; }
.crop-grid::before { left: 33.33%; top: 0; bottom: 0; width: 1px; }
.crop-grid::after  { left: 66.66%; top: 0; bottom: 0; width: 1px; }
.crop-handle {
  position: absolute; width: 22px; height: 22px;
  border: 3px solid #fff;
}
.crop-handle.tl { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
.crop-handle.tr { top: -3px; right: -3px; border-left: 0; border-bottom: 0; }
.crop-handle.bl { bottom: -3px; left: -3px; border-right: 0; border-top: 0; }
.crop-handle.br { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }

/* markup overlay */
.markup-layer { position: absolute; inset: 0; pointer-events: none; }

/* text overlay */
.text-overlay {
  position: absolute; left: 50%; top: 38%; transform: translateX(-50%) rotate(-3deg);
  font-size: 26px; font-weight: 800; color: #fff;
  padding: 4px 14px; border-radius: 8px;
  background: rgba(0,0,0,0.0);
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.text-overlay.bg { background: rgba(255,255,255,0.95); color: #555; text-shadow: none; box-shadow: 0 4px 14px rgba(180,180,180,0.30); }

/* tab content area */
.ed-controls { padding: 0 16px 4px; overflow-y: auto; max-height: 28vh; flex-shrink: 0; }

/* aspect ratio chips (crop tab) */
.ratio-chips {
  display: flex; gap: 8px; padding: 0 4px 14px; overflow-x: auto;
  scrollbar-width: none;
}
.ratio-chips::-webkit-scrollbar { display: none; }
.ratio-chip {
  padding: 8px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(180,180,180,0.30);
  font-size: 12px; font-weight: 500; color: rgba(120,120,120,0.85);
  white-space: nowrap; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
}
.ratio-chip.active { background: rgba(255,255,255,0.75); color: #333; border-color: rgba(200,200,200,0.3); box-shadow: 0 1px 6px rgba(180,180,180,0.15); }

.crop-actions {
  display: flex; justify-content: space-around; gap: 10px; padding: 8px 4px 14px;
}
.crop-action {
  flex: 1; padding: 12px 0; border-radius: 14px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(180,180,180,0.30);
  color: #999; font-size: 11px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.crop-action svg { width: 18px; height: 18px; stroke: #999; fill: none; stroke-width: 1.8; }

/* color palette (markup + text) */
.ed-palette {
  display: flex; gap: 10px; justify-content: center; padding: 10px 4px 14px;
}
.ed-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform 150ms;
  box-shadow: 0 0 0 1px rgba(200,200,200,0.3);
}
.ed-swatch.active { border-color: #333; transform: scale(1.15); }

/* brush size slider (markup) */
.ed-slider-row {
  display: flex; align-items: center; gap: 12px; padding: 0 8px 14px;
}
.ed-slider-row .ed-slider-label { font-size: 12px; color: rgba(100,100,100,0.6); width: 44px; }
.ed-slider-row input[type=range] { flex: 1; accent-color: #333; }

/* tool row (markup) */
.ed-tool-row {
  display: flex; gap: 10px; padding: 0 4px 12px; justify-content: center;
}
.ed-tool {
  width: 46px; height: 46px; border-radius: 14px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(180,180,180,0.30);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.ed-tool svg { width: 22px; height: 22px; stroke: #999; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ed-tool.active { background: rgba(255,255,255,0.75); border-color: rgba(200,200,200,0.3); box-shadow: 0 1px 6px rgba(180,180,180,0.15); }
.ed-tool.active svg { stroke: #333; }

/* text styles row */
.ed-text-styles {
  display: flex; gap: 10px; justify-content: center; padding: 0 4px 12px;
}
.ed-text-style {
  padding: 8px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(180,180,180,0.30);
  font-size: 13px; font-weight: 600; color: rgba(100,100,100,0.9);
  cursor: pointer;
}
.ed-text-style.active { background: rgba(255,255,255,0.75); color: #333; border-color: rgba(200,200,200,0.3); box-shadow: 0 1px 6px rgba(180,180,180,0.15); }

/* bottom tab bar (editor) */
.ed-tabs {
  padding: 6px 16px calc(8px + env(safe-area-inset-bottom));
  display: flex; gap: 6px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(28px) saturate(180%);
  border-top: 0.5px solid rgba(220,220,220,0.7);
  flex-shrink: 0;
}
.ed-tab {
  flex: 1; padding: 8px 0; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; color: rgba(120,120,120,0.7);
  font-size: 11px; font-weight: 500;
  transition: all 200ms;
}
.ed-tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ed-tab.active { color: #333; background: rgba(255,255,255,0.75); box-shadow: 0 1px 6px rgba(180,180,180,0.15); }

/* editor pane visibility */
.ed-pane { display: none; }
.ed-pane.active { display: block; }

/* ═══════════════════════════════════════
   FILE PICKER
   ═══════════════════════════════════════ */
.file-picker {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 250;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 8px;
}
.file-picker.hidden { display: none; }

/* fp header */

.fp-header {
  margin: 4px 12px 0;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.fp-back-btn {
  width: 40px; height: 40px; border-radius: 14px;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(200,200,200,0.35);
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer;
}
.fp-back-btn svg { width: 18px; height: 18px; stroke: #666; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.fp-header-center { flex: 1; text-align: center; }
.fp-header-center .fp-title-main { font-size: 16px; font-weight: 600; color: #333; line-height: 1.2; }
.fp-header-center .fp-title-sub { font-size: 12px; color: rgba(120,120,120,0.7); margin-top: 1px; }
.fp-attach-btn {
  padding: 10px 18px; border-radius: 14px;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(200,200,200,0.35);
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
  font-size: 14px; font-weight: 500; color: #555;
  cursor: pointer; flex-shrink: 0;
}

/* fp category tabs */
.fp-tabs {
  display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto;
  scrollbar-width: none; flex-shrink: 0;
}
.fp-tabs::-webkit-scrollbar { display: none; }
.fp-tab {
  padding: 8px 16px; border-radius: 16px;
  background: transparent;
  font-size: 13px; font-weight: 500; color: rgba(150,150,150,0.85);
  white-space: nowrap; cursor: pointer; flex-shrink: 0;
  transition: all 200ms;
}
.fp-tab.active { background: rgba(255,255,255,0.75); color: #333; box-shadow: 0 1px 6px rgba(180,180,180,0.15); }

/* fp search bar */
.fp-search {
  margin: 4px 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(200,200,200,0.3);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.fp-search > svg { width: 18px; height: 18px; stroke: rgba(150,150,150,0.6); fill: none; stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.fp-search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  font-size: 14px; color: #555; font-family: inherit;
}
.fp-search input::placeholder { color: rgba(150,150,150,0.6); }
.fp-filter-btn {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.fp-filter-btn svg { width: 18px; height: 18px; stroke: rgba(150,150,150,0.6); fill: none; stroke-width: 2; stroke-linecap: round; }

/* fp section title */
.fp-section-title {
  padding: 8px 16px 4px;
  font-size: 13px; font-weight: 500; color: rgba(120,120,120,0.7);
  flex-shrink: 0;
}

/* fp quick access folders */
.fp-quick-access {
  display: flex; gap: 8px; padding: 4px 12px 8px; overflow-x: auto;
  scrollbar-width: none; flex-shrink: 0;
}
.fp-quick-access::-webkit-scrollbar { display: none; }
.fp-folder {
  flex: 1; min-width: 72px;
  padding: 14px 8px 10px;
  border-radius: 16px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 0.5px solid rgba(200,200,200,0.3);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer;
}
.fp-folder-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.fp-folder-icon svg { width: 24px; height: 24px; stroke: #999; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fp-folder-name { font-size: 12px; font-weight: 500; color: #555; }
.fp-folder-count { font-size: 10px; color: rgba(120,120,120,0.6); }

/* fp file list */
.fp-file-list {
  flex: 1; overflow-y: auto; padding: 0 12px; min-height: 0;
  display: flex; flex-direction: column;
}
.fp-file-list::-webkit-scrollbar { display: none; }

.fp-empty-state {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #999; font-size: 15px; cursor: pointer; padding: 30px 0;
}

.fp-file-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 0.5px solid rgba(200,200,200,0.25);
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 150ms;
}
.fp-file-item:active { background: rgba(255,255,255,0.7); }

.fp-file-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: rgba(240,240,240,0.7);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fp-file-icon svg { width: 22px; height: 22px; stroke: #999; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fp-file-icon.doc { background: rgba(91,154,217,0.12); }
.fp-file-icon.doc svg { stroke: #5b9ad9; }
.fp-file-icon.pdf { background: rgba(255,90,95,0.10); }
.fp-file-icon.pdf svg { stroke: #ff5a5f; }
.fp-file-icon.img { background: rgba(126,194,126,0.12); }
.fp-file-icon.img svg { stroke: #7ec27e; }
.fp-file-icon.zip { background: rgba(180,150,100,0.12); }
.fp-file-icon.zip svg { stroke: #b49664; }
.fp-file-icon.xls { background: rgba(100,170,100,0.12); }
.fp-file-icon.xls svg { stroke: #5a9a5a; }
.fp-file-icon.vid { background: rgba(150,100,180,0.12); }
.fp-file-icon.vid svg { stroke: #9664b4; }

.fp-file-info { flex: 1; min-width: 0; }
.fp-file-name { font-size: 14px; font-weight: 500; color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-file-meta { font-size: 11px; color: rgba(120,120,120,0.7); margin-top: 2px; }

.fp-file-check {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid rgba(200,200,200,0.5);
  background: rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 180ms;
}
.fp-file-item.selected .fp-file-check {
  background: #fff; border-color: rgba(200,200,200,0.5);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* fp bottom bar */
.fp-bottom {
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.50);
  backdrop-filter: blur(28px) saturate(180%);
  border-top: 0.5px solid rgba(220,220,220,0.5);
  flex-shrink: 0;
}
.fp-bottom.hidden { display: none; }
.fp-selected-info {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 60px;
}
.fp-selected-info span:first-child { font-size: 13px; font-weight: 600; color: #333; }
.fp-selected-info span:last-child { font-size: 11px; color: rgba(120,120,120,0.7); }
.fp-selected-thumbs {
  flex: 1; display: flex; gap: 4px; overflow-x: auto; padding: 0 4px;
  scrollbar-width: none;
}
.fp-selected-thumbs::-webkit-scrollbar { display: none; }
.fp-sel-thumb {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(240,240,240,0.8);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fp-sel-thumb svg { width: 18px; height: 18px; stroke: #999; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fp-add-more {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,0.6);
  border: 0.5px solid rgba(200,200,200,0.35);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.fp-add-more svg { width: 18px; height: 18px; stroke: #666; fill: none; stroke-width: 2; stroke-linecap: round; }
.fp-send-btn {
  padding: 10px 18px; border-radius: 20px;
  background: #333; color: #fff;
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* --- Toast --- */
#toast-container {
  position: fixed;
  top: calc(60px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #444;
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  opacity: 0;
  transform: translateY(-12px) scale(0.95);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
  max-width: 80vw;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.toast.hide {
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
}

/* Editor.js canvas/touch overrides */
#ed-photo {
  overflow: hidden;
  touch-action: none;
}

.editor-base-canvas,
.editor-markup-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.editor-base-canvas {
  z-index: 1;
  pointer-events: none;
}

.editor-markup-canvas {
  z-index: 4;
  pointer-events: none;
}

#ed-photo > .ed-pane {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#ed-photo > .ed-pane[data-pane="crop"].active {
  pointer-events: auto;
}

#ed-photo > .ed-pane[data-pane="text"].active {
  pointer-events: auto;
}

#ed-photo .crop-frame,
#ed-photo .crop-handle,
#ed-photo .text-overlay {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#ed-photo .crop-frame {
  z-index: 6;
}

#ed-photo .text-overlay {
  z-index: 7;
  cursor: grab;
}

#ed-photo .text-overlay:active {
  cursor: grabbing;
}

/* --- Connect Panel (Mobile) --- */
.connect-panel-body {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cp-section { margin-bottom: 24px; }
.cp-section-title {
  font-size: 11px;
  font-weight: 600;
  color: rgba(120,120,120,0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding: 0 4px;
}
.cp-status-card {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid rgba(200,200,200,0.3);
  border-radius: 16px;
  padding: 14px 16px;
}
.cp-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
  color: #333;
}
.cp-status-label { font-weight: 500; }
.cp-status-meta {
  margin-left: auto;
  font-size: 12px;
  color: #999;
}
.cp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
@keyframes cp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.cp-session-id {
  font-size: 11px;
  color: rgba(150,150,150,0.7);
  font-family: 'Menlo', 'SF Mono', monospace;
  margin-top: 6px;
  padding-left: 16px;
}
.cp-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.cp-stat-card {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid rgba(200,200,200,0.3);
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
}
.cp-stat-value {
  font-size: 20px;
  font-weight: 600;
  color: #333;
}
.cp-stat-label {
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}
.cp-meta {
  font-size: 11px;
  color: rgba(150,150,150,0.85);
  text-align: center;
  padding: 4px 0;
}
.cp-btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.cp-btn {
  flex: 1;
  padding: 12px 0;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.cp-btn:active { opacity: 0.85; }
.cp-btn-light {
  background: rgba(255,255,255,0.65);
  border: 0.5px solid rgba(200,200,200,0.35);
  color: #555;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
}
.cp-btn-light:active { background: rgba(255,255,255,0.85); }
.cp-session-list {
  max-height: 320px;
  overflow-y: auto;
}
.cp-session-item {
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 6px;
  cursor: pointer;
}
.cp-session-item:active { background: rgba(255,255,255,0.5); }
.cp-session-item.active {
  background: rgba(255,255,255,0.75);
  border: 0.5px solid rgba(200,200,200,0.3);
  box-shadow: 0 1px 6px rgba(180,180,180,0.15);
}
.cp-session-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cp-session-key {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}
.cp-badge {
  font-size: 10px;
  background: rgba(107,142,123,0.15);
  color: #6B8E7B;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.cp-session-meta {
  margin-left: auto;
  font-size: 12px;
  color: #999;
}
.cp-agent-card {
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(12px);
  border: 0.5px solid rgba(200,200,200,0.35);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.cp-agent-name {
  font-weight: 600;
  font-size: 14px;
  color: #333;
}
.cp-badge-remote {
  background: rgba(100,160,220,0.12);
  color: #6fa8dc;
}
.cp-btn-sm {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 8px;
}

/* --- Project Tree --- */
.fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 500;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.25s, transform 0.25s;
}
.fullscreen-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.projects-view { display: flex; flex-direction: column; height: 100%; }
.projects-view.hidden { display: none; }

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.projects-header-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}
.header-btn {
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(20px);
  border: 0.5px solid rgba(200,200,200,0.35);
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
  border-radius: 14px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.header-btn:active { background: rgba(255,255,255,0.85); }

/* Project cards */
.projects-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 8px 16px 80px;
}
.project-card {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid rgba(200,200,200,0.35);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.project-card:active { background: rgba(255,255,255,0.65); }
.project-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 10px;
}
.project-card-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
}
.project-card-desc {
  font-size: 11px;
  color: rgba(120,120,120,0.7);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-card-stats {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  font-size: 10px;
  color: rgba(150,150,150,0.85);
}

/* Project tabs */
.project-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 8px;
}
.project-tab {
  padding: 6px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(150,150,150,0.85);
  cursor: pointer;
  transition: all 0.2s;
}
.project-tab.active {
  background: rgba(255,255,255,0.75);
  color: #333;
  box-shadow: 0 1px 6px rgba(180,180,180,0.15);
}

/* Tree view */
.project-tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 80px;
}
.tree-node {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.tree-node:active { background: rgba(255,255,255,0.6); }
.tree-node.selected { background: rgba(255,255,255,0.75); box-shadow: 0 1px 6px rgba(180,180,180,0.15); }
.tree-indent { flex-shrink: 0; }
.tree-chevron {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.tree-chevron.expanded { transform: rotate(90deg); }
.tree-chevron svg { width: 10px; height: 10px; stroke: rgba(150,150,150,0.6); fill: none; stroke-width: 2; }
.tree-node-name {
  font-size: 14px;
  color: #333;
  flex: 1;
  margin-left: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-node-desc {
  font-size: 11px;
  color: rgba(120,120,120,0.5);
  margin-left: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.tree-node-detail {
  padding: 6px 12px 12px;
  margin-left: 42px;
  margin-right: 12px;
  margin-top: -4px;
  margin-bottom: 4px;
  font-size: 12px;
  color: rgba(120,120,120,0.7);
  line-height: 1.6;
  background: rgba(255,255,255,0.35);
  border-radius: 0 0 10px 10px;
  border: 0.5px solid rgba(200,200,200,0.2);
  border-top: none;
}
.tree-badge {
  background: rgba(51,51,51,0.08);
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 10px;
  color: rgba(120,120,120,0.7);
  margin-left: auto;
  flex-shrink: 0;
}

/* Kanban */
.project-kanban-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  padding: 0 12px 80px;
  display: flex;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}
.project-kanban-container.hidden { display: none; }
.kanban-column {
  min-width: 200px;
  max-width: 240px;
  flex-shrink: 0;
}
.kanban-column-title {
  font-size: 12px;
  font-weight: 600;
  color: rgba(150,150,150,0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 8px 12px;
}
.kanban-card {
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
  border: 0.5px solid rgba(200,200,200,0.3);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.kanban-card:active { background: rgba(255,255,255,0.75); }
.kanban-card-id {
  font-size: 10px;
  font-weight: 600;
  color: rgba(150,150,150,0.7);
  margin-bottom: 4px;
}
.kanban-card-title {
  font-size: 13px;
  color: #333;
  font-weight: 500;
  margin-bottom: 6px;
}
.kanban-card-assignee {
  font-size: 11px;
  color: rgba(120,120,120,0.6);
}

/* Order detail */
.order-detail-body {
  padding: 0 16px 80px;
}
.order-field {
  margin-bottom: 16px;
}
.order-field-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(150,150,150,0.85);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}
.order-field-value {
  font-size: 14px;
  color: #333;
  line-height: 1.5;
}
.order-status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}
.order-status-draft { background: rgba(150,150,150,0.12); color: #999; }
.order-status-assigned { background: rgba(59,130,246,0.12); color: #3b82f6; }
.order-status-in_progress { background: rgba(245,158,11,0.12); color: #f59e0b; }
.order-status-review_nagi { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.order-status-review_rina { background: rgba(236,72,153,0.12); color: #ec4899; }
.order-status-completed { background: rgba(34,197,94,0.12); color: #22c55e; }
.order-status-archived { background: rgba(120,120,120,0.08); color: #999; }

/* Plan preview */
.plan-preview-body {
  padding: 0 20px 80px;
  font-size: 14px;
  color: #333;
  line-height: 1.8;
  overflow-y: auto;
  flex: 1;
}
.plan-preview-body h1 { font-size: 20px; font-weight: 600; margin: 16px 0 8px; color: #333; }
.plan-preview-body h2 { font-size: 16px; font-weight: 600; margin: 20px 0 8px; color: #444; }
.plan-preview-body h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; color: #555; }
.plan-preview-body p { margin: 6px 0; }
.plan-preview-body ul, .plan-preview-body ol { padding-left: 20px; margin: 6px 0; }
.plan-preview-body li { margin: 3px 0; }
.plan-preview-body code {
  background: rgba(51,51,51,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'SF Mono', monospace;
}
.plan-preview-body pre {
  background: rgba(51,51,51,0.05);
  border-radius: 10px;
  padding: 12px 16px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.6;
}
.plan-preview-body pre code { background: none; padding: 0; }

/* ═══════════════════════════════════════
   ATTACH MENU ROW 2
   ═══════════════════════════════════════ */
.attach-tabs-row2 {
  justify-content: flex-start;
  padding-left: 20px;
  padding-top: 0;
}

/* ═══════════════════════════════════════
   ORDER ACTION SHEET
   ═══════════════════════════════════════ */
.order-sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.15);
  z-index: 900;
}
.order-sheet-overlay.hidden { display: none; }
.order-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 901;
  box-shadow: 0 -2px 12px rgba(180,180,180,0.12);
  border-top: 0.5px solid rgba(200,200,200,0.3);
}
.order-sheet.hidden { display: none; }
.order-sheet-handle {
  width: 36px; height: 4px;
  background: rgba(200,200,200,0.4);
  border-radius: 2px;
  margin: 4px auto 12px;
}
.order-sheet-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  font-size: 15px; color: #333;
  border-radius: 14px;
  cursor: pointer;
}
.order-sheet-item:active {
  background: rgba(255,255,255,0.75);
  box-shadow: 0 1px 6px rgba(180,180,180,0.15);
}
.order-sheet-icon {
  width: 20px; height: 20px;
  fill: none; stroke: #999; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ═══════════════════════════════════════
   NEW ORDER FORM
   ═══════════════════════════════════════ */
.new-order-form {
  padding: 20px 16px;
  overflow-y: auto; flex: 1;
}
.order-form-field {
  margin-bottom: 20px;
}
.order-form-field label {
  display: block;
  font-size: 12px; color: #999;
  margin-bottom: 6px;
  font-weight: 500;
}
.order-form-readonly {
  font-size: 15px; color: #333;
  padding: 10px 14px;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  border: 0.5px solid rgba(200,200,200,0.3);
}
.order-form-field input,
.order-form-field textarea {
  width: 100%;
  font-size: 15px; color: #333;
  padding: 10px 14px;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 14px;
  border: 0.5px solid rgba(200,200,200,0.3);
  outline: none;
  font-family: inherit;
  resize: none;
}
.order-form-field input:focus,
.order-form-field textarea:focus {
  border-color: rgba(200,200,200,0.6);
  background: rgba(255,255,255,0.7);
}
.order-submit-btn {
  width: 100%;
  padding: 14px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.order-submit-btn:active { opacity: 0.85; }

/* ═══════════════════════════════════════
   DISPATCH ORDER LIST
   ═══════════════════════════════════════ */
.dispatch-order-list {
  padding: 12px 16px;
  overflow-y: auto; flex: 1;
}
.dispatch-order-card {
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid rgba(200,200,200,0.3);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
}
.dispatch-order-card:active {
  background: rgba(255,255,255,0.75);
  box-shadow: 0 1px 6px rgba(180,180,180,0.15);
}
.dispatch-order-id {
  font-size: 11px; color: #999;
  font-family: monospace;
  margin-bottom: 4px;
}
.dispatch-order-title {
  font-size: 15px; color: #333;
  font-weight: 500;
}
.dispatch-order-desc {
  font-size: 13px; color: rgba(120,120,120,0.7);
  margin-top: 4px;
}

/* ═══════════════════════════════════════
   ORDER CHAT BUBBLE — frosted glass card
   ═══════════════════════════════════════ */
.order-msg-bubble {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}
.order-bubble {
  width: 220px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 0.5px solid rgba(200,200,200,0.3);
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
}
.order-bubble-accepted {
  background: rgba(255,255,255,0.55);
}
.order-bubble-header {
  padding: 12px 14px 6px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  display: flex; align-items: center; gap: 6px;
}
.order-bubble-icon {
  width: 16px; height: 16px;
  fill: none; stroke: #999; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.order-bubble-title {
  padding: 4px 14px 8px;
  font-size: 13px;
  color: #555;
}
.order-bubble-meta {
  padding: 0 14px 12px;
  font-size: 11px;
  color: rgba(120,120,120,0.7);
}
.order-bubble-stamp {
  padding: 4px 14px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #333;
}
.order-bubble-confirm-btn {
  margin: 2px 14px 12px;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #333;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.order-bubble-confirm-btn:active { opacity: 0.85; }
.order-bubble-confirm-btn.confirmed {
  background: rgba(255,255,255,0.65);
  color: #555;
  box-shadow: 0 2px 8px rgba(180,180,180,0.12);
  pointer-events: none;
}

/* ═══════════════════════════════════════
   ORDER FORM BUTTON ROW
   ═══════════════════════════════════════ */
.order-btn-row {
  display: flex; gap: 10px;
  margin-top: 8px;
}
.order-btn-row .order-submit-btn { flex: 1; }
.order-btn-secondary {
  background: rgba(255,255,255,0.65) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #555 !important;
  border: 0.5px solid rgba(200,200,200,0.35) !important;
  box-shadow: 0 2px 8px rgba(180,180,180,0.12) !important;
  font-weight: 500 !important;
}
.order-btn-secondary:active { opacity: 0.7; }

/* ═══════════════════════════════════════
   GROUP CHAT — sender name + mention menu
   ═══════════════════════════════════════ */
.chat-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}
.chat-input-wrap input {
  width: 100%;
}
.input-inline-btn {
  position: absolute;
  left: 8px;
  background: transparent;
  border: none;
  font-size: 16px;
  color: rgba(150,150,150,0.6);
  cursor: pointer;
  padding: 4px;
  z-index: 1;
  font-weight: 600;
}
.input-inline-btn:active { color: #333; }

.msg-sender {
  font-size: 11px;
  font-weight: 500;
  margin-bottom: 2px;
  padding-left: 2px;
}
.mention-menu {
  min-width: 100px;
  width: auto;
}
.mention-menu::before { display: none; }
.mention-menu .chat-menu-item {
  padding: 10px 18px;
  font-size: 14px;
}

/* ============ Home Page ============ */
.home-widgets {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.glass-card {
  background: rgba(255,255,255,0.42);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 18px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.04);
}
.home-user-widget {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}
.home-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.home-user-name { font-size: 16px; font-weight: 600; }
.home-user-status { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.home-time-widget {
  padding: 20px 24px;
  text-align: center;
}
.home-time {
  font-size: 52px;
  font-weight: 200;
  letter-spacing: 4px;
  line-height: 1;
}
.home-date {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 6px;
}
.home-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  padding: 0 4px;
}
.home-cardwall {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}
.home-cardwall::-webkit-scrollbar { display: none; }
.home-game-card {
  min-width: 156px;
  max-width: 156px;
  overflow: hidden;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.home-game-card:active { transform: scale(0.96); }
.home-card-cover {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0,0,0,0.02), rgba(0,0,0,0.06));
  border-radius: 18px 18px 0 0;
  font-size: 18px;
  font-weight: 300;
  letter-spacing: 6px;
  color: var(--text);
}
.home-card-info {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.home-card-tag {
  font-size: 11px;
  color: var(--text-light);
  background: rgba(0,0,0,0.04);
  padding: 2px 8px;
  border-radius: 8px;
}
.home-card-players { font-size: 11px; color: var(--text-light); }
.home-card-add { border-style: dashed; }

/* Card Detail */
.card-detail-cover {
  height: 180px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0,0,0,0.02), rgba(0,0,0,0.08));
  margin-bottom: 16px;
  font-size: 28px;
  font-weight: 200;
  letter-spacing: 10px;
}
.card-detail-section { margin-bottom: 16px; }
.card-detail-section h3 { font-size: 14px; font-weight: 600; color: var(--text-light); margin-bottom: 8px; }
.card-detail-section p { font-size: 14px; line-height: 1.7; }
.role-list { display: flex; flex-direction: column; gap: 8px; }
.role-option {
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,0.42);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.45);
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 16px rgba(0,0,0,0.04);
}
.role-option:active { transform: scale(0.98); }
.role-option.selected { border-color: var(--accent); }
.role-name { font-weight: 600; font-size: 15px; }
.role-desc { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.start-game-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 16px;
}
.start-game-btn:active { opacity: 0.8; }
.start-game-btn:disabled { opacity: 0.3; }

/* Game messages */
.gmsg { max-width: 85%; padding: 12px 16px; border-radius: 14px; font-size: 14px; line-height: 1.7; animation: gmsgFade 0.3s ease; }
@keyframes gmsgFade { from { opacity: 0; transform: translateY(6px); } }
.gmsg-narration { align-self: center; max-width: 90%; background: rgba(201,169,110,0.08); border: 1px solid rgba(201,169,110,0.15); color: #c9a96e; font-style: italic; text-align: center; border-radius: 20px; padding: 14px 24px; }
.gmsg-npc { align-self: flex-start; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); }
.gmsg-npc .npc-name { font-size: 12px; font-weight: 600; opacity: 0.7; margin-bottom: 4px; }
.gmsg-player { align-self: flex-end; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); }
.gmsg-event { align-self: center; background: rgba(204,68,68,0.1); border: 1px solid rgba(204,68,68,0.2); color: #c44; text-align: center; border-radius: 20px; font-size: 13px; }
.gmsg-system { align-self: center; color: rgba(255,255,255,0.3); font-size: 12px; }
.gmsg-ai-player {
  align-self: flex-start; max-width: 85%; padding: 12px 16px; border-radius: 14px;
  background: rgba(100,140,180,0.12); border: 1px solid rgba(100,140,180,0.2);
  font-size: 14px; line-height: 1.7; animation: gmsgFade 0.3s ease;
}
.ai-player-name { font-size: 12px; font-weight: 600; color: rgba(130,170,210,0.8); margin-bottom: 4px; }
.gmsg-phase { align-self: center; background: rgba(201,169,110,0.12); border: 1px solid rgba(201,169,110,0.25); color: #c9a96e; font-weight: 600; text-align: center; border-radius: 20px; }

/* ============ Game Layout ============ */
.game-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.game-phase { background: rgba(201,169,110,0.15); color: #c9a96e; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.game-loc { font-size: 13px; color: rgba(255,255,255,0.5); flex: 1; }
.game-save-btn {
  background: none; border: none; cursor: pointer; padding: 4px;
  opacity: 0.5; transition: opacity 0.15s;
}
.game-save-btn:active { opacity: 1; }

/* Save panel */
.save-panel {
  position: absolute; top: 50px; right: 12px; z-index: 15;
  width: 280px; max-height: 400px;
  background: rgba(20,20,28,0.95); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  overflow: hidden; display: flex; flex-direction: column;
}
.save-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px 10px; font-size: 15px; font-weight: 600; color: #e8e4df;
}
.save-slots {
  flex: 1; overflow-y: auto; padding: 0 12px 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.save-slots::-webkit-scrollbar { display: none; }
.save-slot {
  padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer; transition: background 0.15s;
}
.save-slot:active { background: rgba(255,255,255,0.12); }
.save-slot-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.save-slot-label { font-size: 13px; font-weight: 600; color: #c9a96e; }
.save-slot-time { font-size: 11px; color: rgba(255,255,255,0.3); }
.save-slot-summary { font-size: 12px; color: rgba(255,255,255,0.5); line-height: 1.5; }
.save-slot-meta { font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 4px; }
.save-slot.empty { border-style: dashed; opacity: 0.5; }
.save-slot.empty .save-slot-summary { color: rgba(255,255,255,0.25); }
.save-actions {
  padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.save-action-btn {
  width: 100%; padding: 10px; border: none; border-radius: 10px;
  background: rgba(201,169,110,0.15); color: #c9a96e;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s;
}
.save-action-btn:active { background: rgba(201,169,110,0.25); }
.game-msg-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.game-msg-list::-webkit-scrollbar { width: 3px; }
.game-msg-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.game-bottom-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.game-textarea {
  flex: 1; padding: 10px 16px; min-height: 40px; max-height: 120px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; color: #e8e4df; font-size: 14px; font-family: inherit;
  outline: none; resize: none; line-height: 1.5;
}
.game-textarea:focus { border-color: rgba(255,255,255,0.2); }
.game-send {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: #c9a96e; color: #111; font-size: 16px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
}
.game-send:active { opacity: 0.7; }

/* Phone trigger button */
.gphone-trigger {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.08); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; transition: background 0.15s;
}
.gphone-trigger:active { background: rgba(255,255,255,0.15); }
.gphone-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #e74c3c; color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* ============ In-game Phone ============ */
.gphone-overlay { display: none; position: absolute; inset: 0; z-index: 20; }
.gphone-overlay.visible { display: flex; align-items: center; justify-content: center; }
.gphone-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.gphone-frame {
  position: relative; width: 88%; max-width: 360px; height: 75vh; max-height: 600px;
  background: rgba(255,255,255,0.94); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 28px; border: 1px solid rgba(255,255,255,0.6);
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; overflow: hidden;
  color: #2c2c2c;
  animation: gphoneIn 0.3s ease;
}
@keyframes gphoneIn { from { transform: scale(0.9) translateY(20px); opacity: 0; } }

.gphone-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px 8px; font-size: 13px; font-weight: 600; color: #2c2c2c;
}
.gphone-close { cursor: pointer; padding: 4px; }

.gphone-screen { flex: 1; overflow: hidden; position: relative; }
.gphone-view { display: none; position: absolute; inset: 0; flex-direction: column; overflow-y: auto; }
.gphone-view.active { display: flex; }
.gphone-view-title { font-size: 22px; font-weight: 700; padding: 8px 18px 12px; }
.gphone-placeholder { padding: 40px 18px; text-align: center; color: #b0b0b0; font-size: 14px; }

/* Phone tab bar */
.gphone-tabbar {
  display: flex; border-top: 1px solid rgba(0,0,0,0.06);
  padding: 6px 0 10px; flex-shrink: 0;
}
.gphone-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; font-size: 10px; color: #b0b0b0; cursor: pointer;
  transition: color 0.15s;
}
.gphone-tab.active { color: #2c2c2c; }

/* Phone contacts */
.gphone-contacts { padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.gphone-contact {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px; cursor: pointer; transition: background 0.12s;
}
.gphone-contact:active { background: rgba(0,0,0,0.04); }
.gphone-contact-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(0,0,0,0.05);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: #999; flex-shrink: 0;
}
.gphone-contact-info { flex: 1; min-width: 0; }
.gphone-contact-name { font-size: 15px; font-weight: 500; }
.gphone-contact-preview { font-size: 12px; color: #999; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gphone-contact-unread {
  min-width: 20px; height: 20px; padding: 0 6px;
  background: #e74c3c; color: #fff; font-size: 11px; font-weight: 600;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
}

/* Phone chat */
.gphone-chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid rgba(0,0,0,0.06);
}
.gphone-chat-back { cursor: pointer; font-size: 20px; color: #999; padding: 0 4px; }
.gphone-chat-name { font-size: 16px; font-weight: 600; }
.gphone-chat-msgs {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.gphone-chat-msgs::-webkit-scrollbar { display: none; }
.gphone-msg {
  max-width: 80%; padding: 8px 14px; border-radius: 14px;
  font-size: 13px; line-height: 1.5; word-break: break-word;
}
.gphone-msg.sent {
  align-self: flex-end; background: #e8e8e8; color: #2c2c2c;
}
.gphone-msg.received {
  align-self: flex-start; background: rgba(0,0,0,0.05); color: #2c2c2c;
}
.gphone-chat-input-area {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px; border-top: 1px solid rgba(0,0,0,0.06);
}
.gphone-chat-textarea {
  flex: 1; padding: 8px 12px; min-height: 34px; max-height: 80px;
  background: rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px; font-size: 13px; font-family: inherit;
  color: #2c2c2c; outline: none; resize: none; line-height: 1.5;
}
.gphone-chat-send {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: #2c2c2c; color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
}
.gphone-chat-send:active { opacity: 0.7; }

/* Phone Map */
.gphone-map { padding: 8px 14px; display: flex; flex-direction: column; gap: 4px; }
.gphone-map-area { margin-bottom: 12px; }
.gphone-map-area-title { font-size: 12px; font-weight: 600; color: #999; padding: 4px 0 6px; letter-spacing: 1px; }
.gphone-map-node {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px; margin-bottom: 4px;
  background: rgba(0,0,0,0.03); transition: all 0.15s; cursor: pointer;
}
.gphone-map-node:active { background: rgba(0,0,0,0.06); }
.gphone-map-node.current { background: rgba(201,169,110,0.12); border: 1px solid rgba(201,169,110,0.3); }
.gphone-map-node.locked { opacity: 0.4; cursor: default; }
.gphone-map-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ccc; flex-shrink: 0;
}
.gphone-map-node.current .gphone-map-dot { background: #c9a96e; }
.gphone-map-node.locked .gphone-map-dot { background: #ddd; }
.gphone-map-node.visited .gphone-map-dot { background: #8ab88a; }
.gphone-map-name { font-size: 14px; font-weight: 500; flex: 1; }
.gphone-map-lock { font-size: 11px; color: #ccc; }
.gphone-map-conn { font-size: 11px; color: #b0b0b0; padding-left: 34px; margin-top: -2px; margin-bottom: 6px; }

/* Phone Clues */
.gphone-clues { padding: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.clue-add-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,0.06); border: none;
  font-size: 20px; color: #666; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.clue-add-btn:active { background: rgba(0,0,0,0.1); }
.clue-item {
  position: relative; padding: 12px 14px; border-radius: 12px;
  background: rgba(0,0,0,0.03); font-size: 14px;
}
.clue-item textarea {
  width: 100%; background: transparent; border: none; outline: none;
  font-size: 14px; font-family: inherit; color: #2c2c2c;
  resize: none; line-height: 1.6; min-height: 20px;
}
.clue-item .clue-time { font-size: 11px; color: #ccc; margin-top: 4px; }
.clue-item .clue-delete {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; font-size: 14px; color: #ccc;
  cursor: pointer; padding: 2px 4px;
}
.clue-item .clue-delete:hover { color: #e74c3c; }
