/* NCT Hub · iOS-style interface */

:root {
  --bg: #000; --bg2: #1c1c1e; --bg3: #2c2c2e; --bg4: #3a3a3c;
  --fg: #fff; --fg-dim: #8e8e93; --fg-sec: #aeaeb2;
  --azure: #00b8ff; --teal: #00d4aa; --warn: #ffd93d; --err: #ff453a;
  --border: rgba(255,255,255,0.1);
  --hover: rgba(255,255,255,0.05);
  --user-color: var(--azure); --model-color: #c9d1d9; --title-color: var(--teal);
}
[data-theme="light"] {
  --bg: #fff; --bg2: #f2f2f7; --bg3: #e5e5ea; --bg4: #d1d1d6;
  --fg: #000; --fg-dim: #8e8e93; --fg-sec: #3c3c43;
  --border: rgba(0,0,0,0.1); --hover: rgba(0,0,0,0.04);
  --azure: #0066ff; --model-color: #3a4452;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, "SF Pro", BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--fg); margin: 0; font-size: 15px;
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
  --user-color: var(--user-color); --model-color: var(--model-color); --title-color: var(--title-color); }

/* Top bar iOS-style */
.ios-topbar { position: sticky; top: 0; z-index: 100;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); }
[data-theme="light"] .ios-topbar { background: rgba(255,255,255,0.85); }
.ios-status { display: flex; justify-content: space-between; padding: 6px 20px;
  font-size: 14px; font-weight: 600; }
.ios-status-right { display: flex; gap: 6px; font-size: 12px; }
.ios-nav { display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; position: relative; }
.ios-back, .ios-action { background: transparent; border: 0; color: var(--azure);
  font-size: 24px; cursor: pointer; padding: 4px 12px; font-weight: 300; }
.ios-title { position: absolute; left: 50%; transform: translateX(-50%);
  margin: 0; font-size: 17px; font-weight: 600; }
.ios-tabs { display: flex; padding: 0 8px 8px; gap: 4px; }
.ios-tab { flex: 1; background: transparent; border: 0; color: var(--fg-dim);
  padding: 8px 4px; font-size: 12px; border-radius: 8px; cursor: pointer;
  font-weight: 500; }
.ios-tab.active { background: var(--bg3); color: var(--azure); }

/* Main */
.ios-main { padding: 12px 16px 100px; max-width: 900px; margin: auto; }
.view { display: none; }
.view.active { display: block; }

/* Breadcrumb */
.breadcrumb { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.breadcrumb button { background: transparent; border: 0; color: var(--azure);
  font-size: 13px; padding: 4px 8px; cursor: pointer; }

/* Search */
.search-bar { margin-bottom: 8px; }
.search-bar input { width: 100%; background: var(--bg3); color: var(--fg);
  border: 0; padding: 10px 14px; border-radius: 10px; font-size: 15px; }
.search-bar input::placeholder { color: var(--fg-dim); }

/* Filter pills */
.filter-pills { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px;
  padding-bottom: 4px; }
.pill { background: var(--bg3); border: 0; color: var(--fg-dim); padding: 6px 14px;
  border-radius: 14px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.pill.active { background: var(--azure); color: #000; font-weight: 600; }

/* iOS list (Files style) */
.ios-list { background: var(--bg2); border-radius: 12px; overflow: hidden; }
.file-item { display: flex; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; gap: 12px;
  transition: background .1s; }
.file-item:hover { background: var(--hover); }
.file-item.selected { background: rgba(0,184,255,0.15); }
.file-item .file-icon { font-size: 28px; flex-shrink: 0; }
.file-item .file-info { flex: 1; min-width: 0; }
.file-item .file-name { font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item .file-meta { font-size: 12px; color: var(--fg-dim); }
.file-item .file-checkbox { width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--fg-dim); flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; }
.file-item.selected .file-checkbox { background: var(--azure); border-color: var(--azure); color: #000; }
.file-item.starred .file-name::before { content: "⭐ "; }

/* Chat */
.chat-header { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.chat-header select { flex: 1; background: var(--bg3); color: var(--fg);
  border: 0; padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.ios-btn { background: var(--azure); color: #000; border: 0; padding: 8px 14px;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
.ios-btn:hover { background: var(--teal); }
.ios-btn-text { background: transparent; border: 0; color: var(--azure);
  font-size: 15px; cursor: pointer; padding: 4px 8px; }

.chat-anchors { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.anchor-pill { background: var(--bg3); border: 0; color: var(--fg-dim);
  padding: 6px 12px; border-radius: 14px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 4px; }
.anchor-pill.active { background: rgba(0,184,255,0.2); color: var(--azure); }
.anchor-count { background: var(--azure); color: #000; font-size: 9px;
  padding: 0 5px; border-radius: 8px; min-width: 14px; text-align: center; font-weight: 700; }

.chat-messages { min-height: 300px; max-height: 50vh; overflow-y: auto;
  padding: 12px 0; }
.chat-msg { margin-bottom: 12px; padding: 8px 12px; border-radius: 14px;
  max-width: 80%; line-height: 1.4; }
.chat-msg.user { background: var(--user-color); color: #000; margin-left: auto;
  border-bottom-right-radius: 4px; }
.chat-msg.assistant { background: var(--bg2); color: var(--model-color);
  margin-right: auto; border-bottom-left-radius: 4px; }
.chat-msg.system { background: var(--bg3); color: var(--fg-dim); font-size: 12px;
  text-align: center; max-width: 100%; border-radius: 8px; }
.chat-msg .model-tag { font-size: 10px; color: var(--fg-dim); display: block; margin-top: 4px; }

.chat-input-area { display: flex; align-items: flex-end; gap: 8px;
  position: fixed; bottom: 0; left: 0; right: 0; padding: 8px 16px;
  background: rgba(0,0,0,0.9); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border); max-width: 900px; margin: auto; }
[data-theme="light"] .chat-input-area { background: rgba(255,255,255,0.9); }
.chat-input-area textarea { flex: 1; background: var(--bg3); color: var(--fg);
  border: 0; padding: 8px 12px; border-radius: 18px; font-size: 15px;
  font-family: inherit; resize: none; max-height: 120px; }
.ios-btn-icon { background: transparent; border: 0; color: var(--azure);
  font-size: 22px; padding: 8px; cursor: pointer; }
.ios-btn-icon.send { background: var(--azure); color: #000; border-radius: 50%;
  width: 32px; height: 32px; padding: 0; font-size: 16px; }
.ios-btn-icon.send:disabled { opacity: 0.4; }

/* Agents grid */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px; }
.agent-card { background: var(--bg2); border-radius: 14px; padding: 16px;
  cursor: pointer; transition: all .2s; text-align: center; }
.agent-card:hover { transform: translateY(-2px); background: var(--bg3); }
.agent-card .agent-emoji { font-size: 40px; margin-bottom: 8px; display: block; }
.agent-card .agent-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.agent-card .agent-desc { font-size: 11px; color: var(--fg-dim); }
.agent-card .agent-status { width: 8px; height: 8px; border-radius: 50%;
  background: var(--err); margin: 8px auto 0; }
.agent-card.online .agent-status { background: var(--teal); }
.agent-card.binary { border: 1px solid var(--teal); }

/* Memory */
.mem-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-bottom: 12px; }
.mem-stats .stat { background: var(--bg2); padding: 10px; border-radius: 10px; text-align: center; }
.mem-stats .stat b { display: block; font-size: 10px; color: var(--fg-dim); }
.mem-stats .stat span { font-size: 16px; color: var(--azure); font-weight: 700; }

.mem-tabs { display: flex; gap: 4px; margin-bottom: 8px; overflow-x: auto; }
.mem-tab { background: var(--bg3); border: 0; color: var(--fg-dim);
  padding: 6px 12px; border-radius: 14px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.mem-tab.active { background: var(--azure); color: #000; font-weight: 600; }
.mem-content { background: var(--bg2); border-radius: 10px; padding: 8px; }
.mem-textarea { width: 100%; min-height: 200px; background: transparent; color: var(--fg);
  border: 0; padding: 8px; font-family: inherit; font-size: 13px; resize: vertical; }
.mem-content-tab { padding: 4px; }
.mem-list { max-height: 400px; overflow-y: auto; }
.mem-list-item { padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.graph-svg { width: 100%; height: 300px; background: var(--bg3); border-radius: 8px; }

/* Modal iOS style */
.ios-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; flex-direction: column; z-index: 200; }
.ios-modal.open { display: flex; }
.ios-modal-h { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: rgba(0,0,0,0.85); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); }
[data-theme="light"] .ios-modal-h { background: rgba(255,255,255,0.85); }
.ios-modal-h h2 { margin: 0; font-size: 15px; font-weight: 600;
  position: absolute; left: 50%; transform: translateX(-50%);
  color: var(--title-color); }
.ios-modal-b { flex: 1; overflow-y: auto; padding: 16px;
  background: var(--bg); }
.hint { color: var(--fg-dim); font-size: 13px; }

/* Agent picker */
.agent-picker { display: grid; gap: 8px; }
.agent-picker .agent-card { text-align: left; display: flex; align-items: center; gap: 12px; padding: 12px; }
.agent-picker .agent-card .agent-emoji { font-size: 28px; margin: 0; }
.agent-picker .agent-card .agent-name { margin: 0; }

/* Toast */
.ios-toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--bg3); color: var(--fg); padding: 10px 20px;
  border-radius: 20px; font-size: 13px; z-index: 300; opacity: 0;
  transition: opacity .3s; pointer-events: none;
  border: 1px solid var(--border); }
.ios-toast.show { opacity: 1; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fg-dim); border-radius: 2px; }

/* Mobile */
@media (max-width: 600px) {
  .agents-grid { grid-template-columns: repeat(2, 1fr); }
  .mem-stats { grid-template-columns: repeat(2, 1fr); }
  .ios-title { font-size: 16px; }
}