:root {
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface-soft: #f0ebe5;
  --ink: #221d1b;
  --muted: #6e645e;
  --accent: #e4572e;
  --accent-soft: #fbe6de;
  --teal: #2a6f61;
  --teal-soft: #e2f2ee;
  --danger: #b91c1c;
  --border: #e5ddd5;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; margin: 0; }
.error { color: var(--danger); font-weight: 600; margin: 6px 0 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 180px; }

.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; box-shadow: 0 10px 30px rgba(34,29,27,0.06); }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand-icon { width: 48px; height: 48px; border-radius: 12px; }
.brand-row h1 { margin: 0; font-size: 1.4rem; }

.shell { height: 100%; display: flex; flex-direction: column; max-width: 960px; margin: 0 auto; background: var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand-mini { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mini-icon { width: 28px; height: 28px; border-radius: 8px; }
.pill { font-size: 0.78rem; padding: 3px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tabs { display: flex; gap: 6px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { border: 0; background: var(--surface-soft); color: var(--ink); padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--accent); color: #fff; }

.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.chat-panel { padding: 0; gap: 0; overflow: hidden; }

.focus-bar { padding: 8px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--border); font-size: 0.88rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.team-bar { padding: 8px 14px; background: var(--teal-soft); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.team-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.88rem; }

.chat-feed { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 84%; padding: 10px 13px; border-radius: var(--radius); line-height: 1.42; font-size: 0.96rem; white-space: pre-wrap; word-break: break-word; }
.bubble.ali { align-self: flex-start; background: var(--accent-soft); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--surface); border: 1px solid var(--border); border-bottom-right-radius: 4px; }
.bubble-who { font-size: 0.75rem; font-weight: 700; color: var(--accent); margin-bottom: 3px; }
.bubble.me .bubble-who { color: var(--muted); }
.proposal-box { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(34,29,27,0.12); display: flex; flex-direction: column; gap: 6px; }
.proposal-line { font-size: 0.88rem; }

.quick-actions { display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto; background: var(--bg); }
.attach-preview { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--border); }
.attach-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.attach-meta { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: space-between; font-size: 0.85rem; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; background: var(--surface); border-top: 1px solid var(--border); }
.composer textarea { flex: 1; resize: none; max-height: 110px; border: 1px solid var(--border); border-radius: 16px; padding: 9px 12px; font: inherit; background: var(--bg); color: var(--ink); }
.composer textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.grid-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.grid-form input, .grid-form select { flex: 1 1 150px; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; flex: 1 1 150px; }
input, select { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font: inherit; background: var(--surface); color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 8px 13px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 0.82rem; border-radius: 999px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.icon-btn { padding: 8px 10px; border-radius: 12px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill-btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 5px 11px; border-radius: 999px; font-size: 0.84rem; font-weight: 600; cursor: pointer; }
.pill-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-title { font-weight: 600; word-break: break-word; }
.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-right: 6px; background: var(--surface-soft); color: var(--muted); }
.badge.work { background: var(--teal-soft); color: var(--teal); }
.badge.personal { background: var(--accent-soft); color: var(--accent); }
.badge.urgent { background: #fee2e2; color: var(--danger); }

.toast { position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 0.88rem; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,0.2); }

/* Embedded mode inside Windows WebView2 and Android WebView: cleaner header */
body.embedded .topbar { padding: 6px 10px; }
body.embedded #btn-logout { display: none; }
