:root {
  --bg: #f3eee4;
  --bg-accent: #e7d7c3;
  --ink: #1f1a16;
  --muted: #6f665c;
  --line: rgba(31, 26, 22, 0.12);
  --panel: #fffaf3;
  --panel-2: #f7f0e6;
  --accent: #c45c26;
  --accent-2: #2f5d50;
  --danger: #a32d2d;
  --warn: #b45309;
  --ok: #2f6f4f;
  --shadow: 0 18px 40px rgba(31, 26, 22, 0.08);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

[data-theme="dark"] {
  --bg: #161310;
  --bg-accent: #2a211c;
  --ink: #f4ece3;
  --muted: #b3a79b;
  --line: rgba(244, 236, 227, 0.12);
  --panel: #1e1915;
  --panel-2: #241e19;
  --accent: #e07840;
  --accent-2: #7dbaa6;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--bg-accent), transparent 55%),
    var(--bg);
  color: var(--ink);
}

button, input, textarea, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 84%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.03em;
  text-decoration: none;
  color: inherit;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.ws-switch {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 12px;
  min-width: 140px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  position: relative;
}

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}
.badge[hidden] { display: none; }

.user-chip { font-size: 13px; color: var(--muted); padding: 0 6px; cursor: pointer; }

.main {
  width: min(1120px, calc(100% - 28px));
  margin: 18px auto 28px;
}

.view { display: none; }
.view.is-active { display: block; }

.bottom-nav {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(10px);
}
.bottom-nav button {
  border: 0;
  background: transparent;
  padding: 12px 8px 14px;
  color: var(--muted);
  font-size: 12px;
}
.bottom-nav button.is-active {
  color: var(--ink);
  font-weight: 600;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
}
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn:disabled { opacity: 0.5; cursor: default; }

.field {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
}
textarea.field { min-height: 90px; resize: vertical; }

.h-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item-title { font-weight: 560; }
.item-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex: 0 0 auto;
  background: var(--accent-2);
}
.dot.overdue { background: var(--danger); }
.dot.soon { background: var(--warn); }
.dot.inbox { background: var(--accent); }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.chat {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 420px;
}
.chat-log {
  padding: 8px 4px 16px;
  display: grid;
  gap: 12px;
  max-height: 52vh;
  overflow: auto;
}
.bubble {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.bubble.user {
  margin-left: auto;
  background: var(--ink);
  color: var(--panel);
}
.bubble.assistant {
  background: var(--panel);
  border: 1px solid var(--line);
}
.bubble.tool {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0 4px;
}
.composer {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.home-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 16px;
}
@media (max-width: 860px) {
  .home-grid { grid-template-columns: 1fr; }
  .brand { font-size: 24px; }
}

.section-title {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0 0 8px;
}
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.modal-scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.45);
  display: none;
  place-items: center;
  z-index: 40;
  padding: 18px;
}
.modal-scrim.is-open { display: grid; }
.modal {
  width: min(520px, 100%);
  background: var(--panel);
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--line);
}

.notify-panel {
  position: absolute;
  right: 18px;
  top: 64px;
  width: min(360px, calc(100% - 24px));
  max-height: 70vh;
  overflow: auto;
  display: none;
  z-index: 30;
}
.notify-panel.is-open { display: block; }

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--panel);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  display: none;
  z-index: 50;
}
.toast.is-on { display: block; }

.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.filter-tabs button.is-active { background: var(--ink); color: var(--panel); border-color: transparent; }

.loading-bar {
  height: 2px;
  background: var(--accent);
  position: fixed;
  top: 0;
  left: 0;
  right: 100%;
  z-index: 60;
  opacity: 0;
  transition: right 0.4s ease, opacity 0.2s;
}
.loading-bar.is-on { opacity: 1; right: 35%; }
