/* careG — Mobile-First Design System v2.0 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #111111;
  --buff: #F5F0E8;
  --red: #C0392B;
  --dark-red: #922B21;
  --leather: #8C7355;
  --concrete: #C8C4BC;
  --light: #E8E4DC;
  --white: #ffffff;
  --bg: #FAFAF8;
  --surface: #ffffff;
  --border: #E5E2DA;
  --text-primary: #111111;
  --text-secondary: #6B6860;
  --text-tertiary: #A8A49C;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'DM Mono', monospace;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --nav-h: 56px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text-primary); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden; }

/* NAV */
.nav { position: fixed; top: 0; left: 0; right: 0; padding-top: env(safe-area-inset-top); height: var(--nav-h); background: rgba(255,255,255,0.92); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; z-index: 100; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.nav-logo { display: flex; align-items: center; text-decoration: none; }
.nav-logo img { height: 32px; width: auto; }
.nav-actions { display: flex; align-items: center; gap: 4px; }
.nav-icon-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary); font-size: 20px; text-decoration: none; transition: background 0.12s; }
.nav-icon-btn:hover { background: var(--light); }
.nav-menu-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; transition: background 0.12s; }
.nav-menu-btn:hover { background: var(--light); }
.nav-menu-btn span { display: block; width: 18px; height: 1.5px; background: var(--text-primary); border-radius: 2px; }

/* BOTTOM TAB BAR */
.tab-bar { position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: rgba(255,255,255,0.95); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-around; padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 100; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.tab-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--text-tertiary); font-size: 10px; font-weight: 500; padding: 8px 0; transition: color 0.12s; }
.tab-item.active { color: #d86d3a; }

/* MAIN */
.main { position: fixed; top: var(--nav-h); bottom: 64px; left: 0; right: 0; overflow: hidden; }

/* CHAT */
.chat-layout { display: flex; flex-direction: column; height: 100%; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }

/* EMPTY STATE */
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 2rem 1.5rem; text-align: center; min-height: 300px; }
.chat-empty-logo { height: 8	0px; width: auto; margin-bottom: 16px; opacity: 0.8; }
.chat-empty-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.chat-empty-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.chat-suggestions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 300px; }
.suggestion { padding: 12px 16px; border: 1px solid var(--border); background: var(--surface); font-family: var(--font); font-size: 13px; color: var(--text-primary); cursor: pointer; border-radius: var(--radius); text-align: left; box-shadow: var(--shadow); transition: all 0.12s; }
.suggestion:active { background: var(--buff); border-color: var(--ink); }

/* MESSAGES */
.message { display: flex; flex-direction: column; max-width: 85%; }
.message-user { align-self: flex-end; align-items: flex-end; }
.message-assistant { align-self: flex-start; align-items: flex-start; }
.message-bubble { padding: 10px 14px; font-size: 14px; line-height: 1.6; border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; }
.message-user .message-bubble { background: #d86d3a; color: white; border-bottom-right-radius: 4px; }
.message-assistant .message-bubble { background: var(--surface); border: 1px solid var(--border); color: var(--text-primary); border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.message-time { font-size: 10px; color: var(--text-tertiary); margin-top: 4px; }
.memory-pill { display: inline-block; font-size: 10px; padding: 2px 8px; background: var(--buff); border: 1px solid var(--border); color: var(--leather); border-radius: 20px; margin-top: 4px; margin-right: 4px; }

/* TYPING */
.typing-indicator { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
.typing-indicator span { width: 6px; height: 6px; background: var(--concrete); border-radius: 50%; animation: bounce 1.2s infinite; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* INPUT AREA */
.chat-input-area { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
.memory-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; background: var(--bg); border: 1.5px solid var(--border); border-radius: 22px; padding: 8px 8px 8px 14px; transition: border-color 0.12s; }
.chat-input-row:focus-within { border-color: var(--ink); }
.chat-input { flex: 1; font-family: var(--font); font-size: 15px; color: var(--text-primary); border: none; background: transparent; resize: none; outline: none; max-height: 120px; min-height: 24px; line-height: 1.5; }
.chat-input::placeholder { color: var(--text-tertiary); }
.chat-input-btns { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.input-icon-btn { width: 34px; height: 34px; border-radius: 50%; border: none; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-tertiary); font-size: 18px; transition: all 0.12s; }
.input-icon-btn:hover { color: var(--ink); background: var(--light); }
.chat-send { width: 34px; height: 34px; border-radius: 50%; border: none; background: #d86d3a; color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.12s; flex-shrink: 0; }
.chat-send:hover { background: #b85a2e; }
.chat-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* SLIDE-UP PANEL */
.panel-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.panel-overlay.open { opacity: 1; pointer-events: all; }
.panel { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-radius: 20px 20px 0 0; z-index: 201; padding: 0 0 calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); max-height: 85vh; overflow-y: auto; }
.panel.open { transform: translateY(0); }
.panel-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 12px auto 20px; }
.panel-title { font-size: 16px; font-weight: 700; padding: 0 20px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.panel-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; cursor: pointer; transition: background 0.1s; text-decoration: none; color: var(--text-primary); }
.panel-item:active { background: var(--bg); }
.panel-item-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--bg); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.panel-item-text { font-size: 14px; font-weight: 500; }
.panel-item-sub { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }
.panel-upload { margin: 8px 20px 16px; border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer; transition: border-color 0.12s; }
.panel-upload:active { border-color: var(--ink); }
.panel-upload-icon { font-size: 28px; margin-bottom: 6px; }
.panel-upload-text { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.panel-upload-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }
.upload-status { font-size: 12px; margin-top: 8px; min-height: 16px; color: var(--text-secondary); text-align: center; }
.upload-status.success { color: #166534; }
.upload-status.error { color: var(--red); }

/* PAGES */
.page-wrap { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px 16px 24px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* BUTTONS */
.btn { font-family: var(--font); font-size: 14px; font-weight: 500; padding: 10px 18px; border: 1.5px solid var(--border); background: transparent; color: var(--text-primary); cursor: pointer; border-radius: var(--radius-sm); transition: all 0.12s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: #d86d3a; color: white; border-color: #d86d3a; }
.btn-primary:hover { background: #b85a2e; border-color: #b85a2e; }
.btn-outline:hover { border-color: var(--ink); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* MEMORY CARDS */
.memory-grid { display: flex; flex-direction: column; gap: 10px; }
.memory-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.memory-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.memory-cat { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--leather); background: var(--buff); padding: 3px 8px; border-radius: 20px; }
.memory-delete { width: 28px; height: 28px; border-radius: 50%; border: none; background: transparent; color: var(--text-tertiary); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.memory-delete:active { background: #FEE2E2; color: var(--red); }
.memory-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.memory-content { font-size: 13px; color: var(--text-secondary); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.memory-date { font-size: 11px; color: var(--text-tertiary); margin-top: 8px; }

/* FILTER PILLS */
.filter-pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pill { flex-shrink: 0; padding: 6px 14px; border: 1px solid var(--border); border-radius: 20px; font-size: 13px; font-weight: 500; color: var(--text-secondary); background: var(--surface); cursor: pointer; text-decoration: none; transition: all 0.12s; }
.filter-pill.active { background: #d86d3a !important; color: white !important; border: 1px solid #d86d3a !important; outline: none !important; box-shadow: none !important; }

/* SEARCH */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font); font-size: 14px; background: var(--surface); color: var(--text-primary); outline: none; -webkit-appearance: none; }
.search-input:focus { border-color: var(--ink); }

/* FORM FIELDS */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.field-input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); background: var(--surface); font-family: var(--font); font-size: 15px; color: var(--text-primary); border-radius: var(--radius-sm); outline: none; transition: border-color 0.12s; -webkit-appearance: none; }
.field-input:focus { border-color: var(--ink); }
textarea.field-input { resize: vertical; }

/* AUTH */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1.5rem; background: var(--bg); }
.auth-logo { height: 70px; width: auto; margin-bottom: 8px; }
.auth-tagline { font-size: 13px; color: var(--text-secondary); margin-bottom: 2rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.auth-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-secondary); }
.link { color: var(--ink); font-weight: 500; }
.demo-hint { margin-top: 14px; padding: 10px 14px; background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary); text-align: center; }
.demo-badge { background: var(--red); color: white; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px; margin-right: 6px; }

/* ALERTS */
.alert-error { background: #FEF2F2; border: 1px solid #FCA5A5; color: #991B1B; padding: 10px 14px; font-size: 13px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.alert-success { background: #F0FDF4; border: 1px solid #86EFAC; color: #166534; padding: 10px 14px; font-size: 13px; border-radius: var(--radius-sm); margin-bottom: 14px; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; justify-content: center; z-index: 300; padding: 0; }
@media (min-width: 768px) { .modal-overlay { align-items: center; } .modal { border-radius: 16px; max-height: 80vh; overflow-y: auto; margin-bottom: 0; } }
.modal { background: var(--surface); border-radius: 20px; padding: 8px 20px 24px; width: 100%; max-height: 90vh; overflow-y: auto; margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
.modal-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 20px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--bg); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

/* CIRCLES */
.circles-grid { display: flex; flex-direction: column; gap: 10px; }
.circle-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.circle-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: white; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.circle-info { flex: 1; }
.circle-name { font-size: 15px; font-weight: 600; }
.circle-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.circle-actions { display: flex; align-items: center; gap: 8px; }
.badge { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.badge-owner { background: var(--red); color: white; }
.info-box { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 16px; margin-top: 20px; }
.info-box-title { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 14px; }
.info-grid { display: flex; flex-direction: column; gap: 12px; }
.info-item { display: flex; gap: 12px; align-items: flex-start; }
.info-num { font-size: 22px; font-weight: 700; color: var(--border); line-height: 1; flex-shrink: 0; width: 28px; }
.info-text { font-size: 13px; line-height: 1.5; padding-top: 2px; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 3rem 1.5rem; border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.empty-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.6; }

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

/* DESKTOP */
@media (min-width: 768px) {
  .chat-messages { padding: 24px 15% 8px; }
  .chat-input-area { padding: 12px 15% calc(12px + env(safe-area-inset-bottom, 0px)); }
  .page-wrap { padding: 28px 10% 32px; max-width: 800px; margin: 0 auto; }
}
