:root {
  color-scheme: dark;
  --bg: #060607;
  --panel: #0c0d10;
  --card: #111318;
  --field: rgba(255, 255, 255, 0.05);
  --bubble-bot: #15171d;
  --border: rgba(255, 255, 255, 0.09);
  --accent: #ff2d78;
  --accent-2: #ff6a9a;
  --text: #f2f3f7;
  --text-dim: #8b8fa3;
  --danger: #f87171;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: stretch;
  min-height: 100vh;
  position: relative;
}
a { color: inherit; }
main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 820px;
  display: flex;
  padding: 0;
}
main.narrow { max-width: 460px; align-items: center; padding: 28px; }
.shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 18px 18px 0;
  overflow: hidden;
  min-height: 100vh;
}
main.narrow .shell {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px 24px 18px;
  min-height: auto;
  box-shadow: 0 24px 70px -24px rgba(0, 0, 0, 0.65);
}
header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.menu-btn {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; cursor: pointer; }
.logo-ring {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  border: 2px solid var(--accent);
  background: var(--bg);
  box-shadow: 0 0 20px -4px var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
}
header h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin: 0;
  color: var(--text);
}
header h1 .accent { color: var(--accent); }
header p {
  margin: 3px 0 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.header-actions button.icon {
  background: none;
  box-shadow: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.avatar-menu-wrap { position: relative; }
.avatar-btn { cursor: pointer; }
.avatar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 180px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.6);
}
.avatar-dropdown.hidden { display: none; }
.avatar-dropdown-item {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.avatar-dropdown-item:hover { background: rgba(255, 255, 255, 0.06); }
.avatar-dropdown-item.danger { color: var(--danger); }

nav.tabs {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
nav.tabs a {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text-dim);
  border: 1px solid transparent;
}
nav.tabs a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
nav.tabs a:not(.active):hover { border-color: var(--border); }

.bottom-nav {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  margin: 0 -18px;
  position: sticky;
  bottom: 0;
}
.bottom-nav a, .bottom-nav button.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 600;
  min-width: 56px;
  padding: 4px 0;
  margin: 0;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  line-height: 1.3;
}
.bottom-nav a .bn-icon { font-size: 1.15rem; line-height: 1; }
.bottom-nav a.active { color: var(--accent); }

.bn-tile {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  box-sizing: border-box;
  border-radius: 13px;
  background: #15171d;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-dim);
}
.bn-tile svg { width: 21px; height: 21px; }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--panel);
}
.notif-badge.hidden { display: none; }

.notif-panel { width: min(420px, 92vw); height: min(560px, 80vh); }
.notif-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.notif-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bubble-bot); cursor: pointer; text-align: left; }
.notif-row.unread { border-color: var(--accent); background: rgba(255, 45, 120, 0.07); }
.notif-row .notif-title { font-weight: 700; font-size: 0.85rem; }
.notif-row .notif-body { font-size: 0.78rem; color: var(--text-dim); }
.notif-row .notif-time { font-size: 0.68rem; color: var(--text-dim); margin-top: 2px; }
.notif-enable-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); font-size: 0.78rem; }
.notif-enable-row button { width: auto; padding: 7px 12px; font-size: 0.75rem; }
.bottom-nav a:hover .bn-tile { border-color: var(--accent-2); color: var(--text); }
.bn-tile-ava {
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  border: 2px solid var(--accent);
  background: #170a10;
  box-shadow: 0 0 18px 2px rgba(255, 45, 120, 0.55), inset 0 0 8px 1px rgba(255, 106, 154, 0.35);
}
.bottom-nav button.bn-item:hover .bn-tile-ava { box-shadow: 0 0 24px 4px rgba(255, 45, 120, 0.75), inset 0 0 8px 1px rgba(255, 106, 154, 0.45); }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 30; }
.overlay.hidden { display: none; }
.overlay-panel { width: min(640px, 90vw); max-height: 80vh; display: flex; flex-direction: column; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }

.quick-chat-panel { width: min(420px, 92vw); height: min(560px, 80vh); }
.quick-chat-header { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.quick-chat-header strong { flex: 1; font-size: 0.95rem; }
.quick-chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px; }
.quick-chat-log::-webkit-scrollbar { width: 8px; }
.quick-chat-log::-webkit-scrollbar-thumb { background: #2a2e3d; border-radius: 8px; }
.qc-row { display: flex; gap: 8px; align-items: flex-start; }
.qc-row.user { flex-direction: row-reverse; }
.qc-bubble { padding: 9px 13px; border-radius: 13px; max-width: 82%; line-height: 1.45; font-size: 0.88rem; }
.qc-row.bot .qc-bubble { background: var(--bubble-bot); border: 1px solid var(--border); border-top-left-radius: 4px; }
.qc-row.user .qc-bubble { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-top-right-radius: 4px; }
.qc-bubble p { margin: 0 0 6px; }
.qc-bubble p:last-child { margin-bottom: 0; }

.model-toggle {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0 10px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
}
.model-toggle.active { border-color: var(--accent); color: var(--accent); background: rgba(255, 45, 120, 0.12); }
.model-toggle.hidden { display: none; }

.quick-notes-panel { width: min(420px, 92vw); height: min(560px, 80vh); }
.qn-add-row { display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.qn-add-row .qn-input-row { display: flex; gap: 8px; }
.qn-add-row .qn-input-row input { flex: 1; }
.qn-reminder-row { display: flex; align-items: center; gap: 10px; font-size: 0.78rem; color: var(--text-dim); }
.qn-reminder-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.qn-reminder-row input[type="checkbox"] { width: 15px; height: 15px; }
.qn-reminder-row input[type="date"] { width: auto; padding: 6px 8px; font-size: 16px; }
.qn-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.qn-list::-webkit-scrollbar { width: 8px; }
.qn-list::-webkit-scrollbar-thumb { background: #2a2e3d; border-radius: 8px; }
.qn-note { background: var(--bubble-bot); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.qn-note-text { font-size: 0.88rem; line-height: 1.4; }
.qn-note-meta { display: flex; align-items: center; justify-content: space-between; }
.qn-reminder-badge { font-size: 0.68rem; font-weight: 700; color: var(--accent-2); background: rgba(255, 45, 120, 0.1); padding: 2px 8px; border-radius: 999px; }
.qn-note-actions { display: flex; gap: 6px; }
.qn-note-actions button { padding: 5px 9px; font-size: 0.7rem; }

input, textarea, select {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--field);
  color: var(--text);
  font-size: 16px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.25s ease, background 0.25s ease;
}
input:focus, textarea:focus { border-color: var(--accent); background: rgba(255, 255, 255, 0.07); }
textarea { resize: vertical; }

button, .btn {
  padding: 12px 18px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.4s ease, opacity 0.2s ease;
  box-shadow: 0 8px 20px -8px var(--accent);
}
button:hover:not(:disabled), .btn:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--border);
}
button.danger, .btn.danger {
  background: transparent;
  color: var(--danger);
  box-shadow: none;
  border: 1px solid rgba(248, 113, 113, 0.35);
}
button.icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 10px; min-height: 1em; }
.hint { color: var(--text-dim); font-size: 0.85rem; margin-top: 14px; text-align: center; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 18px;
}

.ptr-indicator {
  position: fixed;
  top: 8px;
  left: 50%;
  margin-left: -18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--accent);
  opacity: 0;
  z-index: 50;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  pointer-events: none;
}
.ptr-indicator.ptr-ready {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
