:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-soft: #f6f9fc;
  --panel-2: #eef4f9;
  --line: #d8e1ea;
  --text: #213142;
  --muted: #6f8397;
  --blue: #3390ec;
  --blue-dark: #2b7fd1;
  --green: #3f8c5a;
  --danger: #cf5656;
  --shadow: 0 18px 45px rgba(35, 52, 73, 0.08);
  --chip-bg: #edf3f8;
  --chip-text: #60768b;
  --hover-bg: #edf4fb;
  --active-bg: #e1eefb;
  --input-bg: #ffffff;
  --bubble-user-start: #d7ebbe;
  --bubble-user-end: #c8e09f;
  --bubble-user-text: #2c3f1f;
  --bubble-assistant: #ffffff;
  --bubble-system: #f2f6fa;
  --calendar-empty: #eef3f7;
  --panel-glass: rgba(255, 255, 255, 0.9);
  --panel-glass-border: rgba(216, 225, 234, 0.95);
  --secondary-bg: #e8f0f8;
  --secondary-hover: #dde9f5;
  --secondary-text: #38516c;
  --warn-bg: #fdeaea;
  --warn-hover: #f9dede;
  --warn-text: #a84444;
  --badge-bg: rgba(57, 81, 108, 0.1);
  --error-bg: #fff1f1;
  --error-border: #f0c9c9;
  --error-text: #b14b4b;
  --status-bg: #e8f0f8;
  --status-text: #54708d;
  --status-warn-bg: #fdeaea;
  --status-warn-text: #b35757;
  --status-ok-bg: #e7f6ec;
  --status-ok-text: #2f7b50;
}

body.theme-light {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-soft: #f6f9fc;
  --panel-2: #eef4f9;
  --line: #d8e1ea;
  --text: #213142;
  --muted: #6f8397;
  --blue: #3390ec;
  --blue-dark: #2b7fd1;
  --green: #3f8c5a;
  --danger: #cf5656;
  --shadow: 0 18px 45px rgba(35, 52, 73, 0.08);
  --chip-bg: #edf3f8;
  --chip-text: #60768b;
  --hover-bg: #edf4fb;
  --active-bg: #e1eefb;
  --input-bg: #ffffff;
  --bubble-user-start: #d7ebbe;
  --bubble-user-end: #c8e09f;
  --bubble-user-text: #2c3f1f;
  --bubble-assistant: #ffffff;
  --bubble-system: #f2f6fa;
  --calendar-empty: #eef3f7;
  --panel-glass: rgba(255, 255, 255, 0.9);
  --panel-glass-border: rgba(216, 225, 234, 0.95);
  --secondary-bg: #e8f0f8;
  --secondary-hover: #dde9f5;
  --secondary-text: #38516c;
  --warn-bg: #fdeaea;
  --warn-hover: #f9dede;
  --warn-text: #a84444;
  --badge-bg: rgba(57, 81, 108, 0.1);
  --error-bg: #fff1f1;
  --error-border: #f0c9c9;
  --error-text: #b14b4b;
  --status-bg: #e8f0f8;
  --status-text: #54708d;
  --status-warn-bg: #fdeaea;
  --status-warn-text: #b35757;
  --status-ok-bg: #e7f6ec;
  --status-ok-text: #2f7b50;
}

body:not(.theme-light) {
  --bg: #0b1220;
  --panel: #131c2b;
  --panel-soft: #192334;
  --panel-2: #223146;
  --line: #253347;
  --text: #e6edf6;
  --muted: #91a2b7;
  --blue: #5aa8ff;
  --blue-dark: #4a95ea;
  --green: #59c281;
  --danger: #f07171;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
  --chip-bg: #1a2536;
  --chip-text: #afbed1;
  --hover-bg: #1f2d42;
  --active-bg: #233754;
  --input-bg: #101827;
  --bubble-user-start: #2d4f17;
  --bubble-user-end: #426f22;
  --bubble-user-text: #f1f8ea;
  --bubble-assistant: #172131;
  --bubble-system: #121a27;
  --calendar-empty: #111926;
  --panel-glass: rgba(19, 28, 43, 0.92);
  --panel-glass-border: rgba(37, 51, 71, 0.95);
  --secondary-bg: #1b2840;
  --secondary-hover: #21304b;
  --secondary-text: #dce8f8;
  --warn-bg: #3a1f24;
  --warn-hover: #47252b;
  --warn-text: #ffb6b6;
  --badge-bg: rgba(10, 16, 27, 0.58);
  --error-bg: #2a151a;
  --error-border: #5b2b34;
  --error-text: #ffb5b5;
  --status-bg: #1c2940;
  --status-text: #c5d5e9;
  --status-warn-bg: #341b1f;
  --status-warn-text: #ffb4b4;
  --status-ok-bg: #173024;
  --status-ok-text: #9de0b7;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

.hidden { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  color-scheme: light;
  background:
    radial-gradient(circle at top left, rgba(51, 144, 236, 0.14), transparent 22%),
    linear-gradient(180deg, #f7fafc 0%, #eef3f7 100%);
}

body.theme-light {
  color-scheme: light;
  background:
    radial-gradient(circle at top left, rgba(51, 144, 236, 0.14), transparent 22%),
    linear-gradient(180deg, #f7fafc 0%, #eef3f7 100%);
}

body:not(.theme-light) {
  color-scheme: dark;
  background:
    radial-gradient(circle at top left, rgba(90, 168, 255, 0.14), transparent 22%),
    linear-gradient(180deg, #0f1726 0%, #0a101b 100%);
}

button, textarea, select, input { font: inherit; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(100%, 440px);
  padding: 22px;
}

.auth-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.auth-theme-toggle {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
}

.auth-form,
.field,
.inline-grid {
  display: grid;
  gap: 10px;
}

.auth-form {
  margin-top: 16px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
}

.field-help {
  font-size: 12px;
  color: var(--muted);
}

.auth-error {
  margin-top: 12px;
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  width: min(100%, 1540px);
  margin: 0 auto;
  padding: 14px;
  display: grid;
  gap: 14px;
}

@media (min-width: 1120px) {
  html,
  body {
    height: 100vh;
    overflow: hidden;
  }

  .app-shell {
    min-height: 100vh;
    height: 100vh;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    overflow: hidden;
  }

  .chat {
    width: 100%;
    height: 100%;
  }

  .sidebar,
  .details {
    height: 100%;
  }
}

.panel {
  min-width: 0;
  background: var(--panel-glass);
  border: 1px solid var(--panel-glass-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.sidebar,
.chat,
.details {
  min-width: 0;
  min-height: 0;
}

.sidebar,
.details {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.sidebar {
  padding: 14px;
}

.chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px;
}

.details {
  grid-template-rows: auto 1fr auto;
  padding: 14px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2 {
  margin: 0;
  font-weight: 700;
}

h1 { font-size: 24px; }
h2 { font-size: 19px; }

.muted {
  color: var(--muted);
  font-size: 13px;
}

.sidebar-top,
.chat-top,
.details-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.details-swipe-hint {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.chat-tools {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.sidebar-top {
  display: grid;
  gap: 10px;
}

.account-card {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 10px 12px;
}

.account-name {
  font-weight: 700;
  font-size: 15px;
}

.account-actions {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.account-theme {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--input-bg);
  border-radius: 14px;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  min-height: 68px;
  resize: vertical;
}

button {
  border: none;
  border-radius: 12px;
  background: var(--blue);
  color: #ffffff;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  white-space: normal;
  line-height: 1.2;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
  -webkit-tap-highlight-color: transparent;
}

button:focus {
  outline: none;
}

button:hover { background: var(--blue-dark); }
button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}
button.secondary {
  background: var(--secondary-bg);
  color: var(--secondary-text);
}
button.secondary:hover { background: var(--secondary-hover); }
button.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}
button.warn:hover { background: var(--warn-hover); }

.sidebar-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.sidebar-actions button,
.pane-tab {
  min-height: 46px;
}

.pane-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.pane-tab {
  background: var(--secondary-bg);
  color: var(--secondary-text);
  padding: 10px 8px;
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
  text-align: center;
  font-size: 18px;
  line-height: 1;
}

.pane-tab.active {
  background: var(--blue);
  color: #fff;
}

.pane-tab:focus {
  outline: none;
}

.pane-tab.touch-active {
  background: var(--blue);
  color: #fff;
}

.badge {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.2;
  background: var(--badge-bg);
  color: inherit;
}

.sidebar-head {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.list-filters {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.details-body .list-filters {
  margin-bottom: 12px;
}

.details-body .list-filters + .pane-stack {
  margin-top: 12px;
}

.reminder-filter-rows {
  display: grid;
  gap: 6px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  border: 1px solid var(--line);
  background: var(--chip-bg);
  color: var(--chip-text);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.2;
}

.filter-chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.drawer-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
}

.drawer-backdrop {
  display: none;
}

.sidebar-list {
  margin-top: 10px;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.list-row {
  border: 1px solid transparent;
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.list-row:hover {
  background: var(--hover-bg);
  border-color: #315077;
}

.list-row.active {
  background: var(--active-bg);
  border-color: #4270a8;
}

.row-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.row-title.mono {
  font-size: 13px;
  line-height: 1.35;
}

.row-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.row-tag {
  margin-top: 6px;
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--chip-bg);
  color: var(--chip-text);
  border: 1px solid var(--line);
}

.deal-row .row-title {
  font-size: 16px;
  line-height: 1.35;
}

.deal-row .row-title.mono {
  font-size: 15px;
  line-height: 1.4;
}

.deal-row .row-meta {
  font-size: 13px;
  line-height: 1.35;
}

.deal-row .row-tag {
  font-size: 12px;
}

.chat-feed {
  min-height: 0;
  overflow-y: auto;
  padding: 8px 4px 8px 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.bubble {
  max-width: min(78%, 540px);
  padding: 8px 11px;
  border-radius: 18px;
  line-height: 1.3;
  white-space: pre-wrap;
  font-size: 14px;
  overflow-wrap: anywhere;
  width: fit-content;
}

.bubble.user {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--bubble-user-start) 0%, var(--bubble-user-end) 100%);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 8px;
}

.bubble.assistant {
  background: var(--bubble-assistant);
  border: 1px solid var(--line);
  border-bottom-left-radius: 8px;
}

.bubble.system {
  background: var(--bubble-system);
  border: 1px dashed #314257;
  color: var(--muted);
}

.bubble.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 62px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #6f86a2;
  animation: typing-pulse 1s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.18s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typing-pulse {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.chat-status {
  margin-top: 4px;
  min-height: 18px;
}

.chat-status.processing {
  color: var(--blue);
}

.composer {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.details-body {
  margin-top: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.details-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.details-ok {
  min-width: 96px;
  background: var(--blue) !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(51, 144, 236, 0.22);
}

.details-ok:hover {
  background: var(--blue-dark) !important;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
}

.list-divider {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
  padding: 8px 6px 2px;
  font-weight: 700;
}

.stack {
  display: grid;
  gap: 10px;
}

.pane-stack {
  margin-top: 10px;
}

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

.card.card-tap {
  cursor: pointer;
}

.notification-card {
  padding: 14px;
}

.notification-card .actions {
  margin-top: 12px;
}

.card-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-title.mono {
  font-size: 14px;
}

.card-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.3;
}

.birthday-meta-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-top: 5px;
}

.birthday-meta-row .card-meta {
  margin-top: 0;
  flex: 1 1 auto;
}

.icon-action {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.icon-action:hover {
  background: var(--panel-2);
}

.birthday-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.birthday-card-head .row-meta,
.birthday-card-head .card-meta {
  margin-top: 5px;
}

.deal-card .card-title {
  font-size: 17px;
  line-height: 1.35;
}

.deal-card .card-meta {
  font-size: 14px;
  line-height: 1.35;
}

.deal-card .checklist-preview-item span {
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.actions button {
  width: auto;
  flex: 1 1 148px;
  padding: 7px 9px;
  border-radius: 10px;
  font-size: 13px;
}

.actions.lightning-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 6px;
}

.actions.lightning-grid button {
  width: 100%;
  flex: none;
}

.notice {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.details-error {
  border: 1px solid var(--error-border);
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 10px;
}

.week-stack {
  gap: 8px;
}

.week-card {
  padding: 10px 12px;
}

.week-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.week-metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 7px 8px;
  display: grid;
  gap: 4px;
}

.week-metric span {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.week-metric strong {
  font-size: 18px;
  line-height: 1;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 8px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 3px;
}

.days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.day {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 8px;
  text-align: center;
  width: 100%;
}

.tiny {
  font-size: 11px;
}

.checklist-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.checklist-text.done {
  text-decoration: line-through;
  color: var(--muted);
}

.checklist-text {
  overflow-wrap: anywhere;
}

.checklist-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}

.checklist-main.done {
  opacity: 0.75;
}

.checklist-preview {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.checklist-preview.compact {
  gap: 4px;
}

.checklist-preview-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.35;
  cursor: pointer;
}

.checklist-preview-item input {
  width: 15px;
  height: 15px;
  margin: 1px 0 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.checklist-preview-item span {
  overflow-wrap: anywhere;
}

.checklist-preview-item.done span {
  text-decoration: line-through;
  color: var(--muted);
}

.checklist-box {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: var(--green);
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}

.checklist-actions {
  margin-top: 0;
  flex: 0 0 auto;
}

.checklist-actions button {
  flex: 0 0 auto;
}

.checklist-delete-icon {
  flex: 0 0 auto;
  align-self: flex-start;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

.checklist-delete-icon:hover {
  background: var(--panel-2);
}

.inline-input {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.checklist-inline-editor {
  margin-top: 4px;
}

.subtle-box {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 12px;
}

.mono {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--status-bg);
  color: var(--status-text);
  font-size: 12px;
}

.status-tag.warn {
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
}

.status-tag.ok {
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
}

.calendar-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.calendar-title {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  text-transform: capitalize;
}

.calendar-nav {
  min-height: 38px;
  padding: 8px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.calendar-cell {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 14px;
  min-height: 68px;
  padding: 8px 6px;
  display: grid;
  align-content: space-between;
  justify-items: center;
  text-align: center;
  color: var(--text);
}

.calendar-cell-empty {
  background: var(--calendar-empty);
  border-style: dashed;
}

.calendar-cell.active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(90, 168, 255, 0.4);
}

.calendar-cell.today {
  border-color: rgba(90, 168, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(90, 168, 255, 0.22);
}

.calendar-cell.today .calendar-day {
  color: var(--blue);
}

.calendar-cell:hover {
  background: var(--hover-bg);
  border-color: #315077;
}

.hour-card {
  width: 100%;
  text-align: left;
}

.calendar-day {
  font-weight: 700;
  font-size: 14px;
}

.calendar-mark {
  font-size: 14px;
  min-height: 18px;
}

.calendar-total {
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}

.calendar-status-done .calendar-mark { color: #8fe3a9; }
.calendar-status-failed .calendar-mark { color: #ff8c8c; }
.calendar-status-pending .calendar-mark { color: #f8d56f; }
.calendar-status-partial .calendar-mark { color: #83c5ff; }
.calendar-status-empty .calendar-mark,
.calendar-status-empty .calendar-total { color: transparent; }

@media (max-width: 1119px) {
  html,
  body {
    height: 100dvh;
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    min-height: 100dvh;
    height: 100dvh;
    padding: 8px;
    gap: 8px;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .sidebar {
    position: relative;
    order: 1;
    padding: 10px;
  }

  .details {
    display: none;
  }

  .sidebar-top {
    gap: 8px;
  }

  .sidebar-top h1 {
    font-size: 21px;
  }

  .account-card {
    padding: 8px 10px;
  }

  .account-actions {
    gap: 8px;
  }

  .account-theme {
    min-height: 30px;
    padding: 6px 9px;
    font-size: 11px;
  }

  .composer {
    grid-template-columns: 1fr;
    margin-top: 8px;
    gap: 8px;
  }

  .chat {
    order: 2;
    min-height: 0;
    height: 100%;
    padding: 10px;
  }

  .chat-feed {
    min-height: 0;
    max-height: none;
    padding-right: 2px;
  }

  .sidebar-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
  }

  .bubble {
    max-width: 92%;
    font-size: 13px;
    padding: 7px 10px;
  }

  .pane-tabs {
    gap: 6px;
    margin-top: 8px;
  }

  .pane-tab,
  .sidebar-actions button {
    min-height: 40px;
    padding: 8px 6px;
    font-size: 13px;
  }

  body:not(.drawer-open) .pane-tab,
  body:not(.drawer-open) .pane-tab.active,
  body:not(.drawer-open) .pane-tab.touch-active,
  body:not(.drawer-open) .pane-tab:hover,
  body:not(.drawer-open) .pane-tab:focus,
  body:not(.drawer-open) .pane-tab:focus-visible,
  body:not(.drawer-open) .pane-tab:active {
    background: var(--secondary-bg);
    color: var(--secondary-text);
  }

  .chat-top .muted {
    font-size: 12px;
  }

  .chat-status {
    min-height: 16px;
    font-size: 12px;
  }

  #chatInput {
    min-height: 56px;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 45, 0.36);
    z-index: 40;
  }

  .drawer-panel {
    display: none;
  }

  body.drawer-open .drawer-backdrop {
    display: block;
  }

  body.drawer-open {
    overflow: hidden;
  }

  body.drawer-open .details {
    display: grid;
    position: fixed;
    right: 8px;
    top: 8px;
    bottom: 8px;
    left: auto;
    width: min(88vw, 420px);
    z-index: 50;
    border: 1px solid var(--line);
    background: var(--panel-glass);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 12px;
    overflow: hidden;
    transition: transform 180ms ease;
    touch-action: pan-y;
  }

  body.drawer-open .details::before {
    display: none;
  }

  body.drawer-open .details.drawer-enter {
    animation: drawer-enter-swipe-hint 420ms cubic-bezier(0.22, 0.9, 0.2, 1);
  }

  body.drawer-open .details.swiping {
    transition: none;
  }

  .details-top {
    flex-direction: column;
    align-items: stretch;
    padding-top: 2px;
    padding-right: 8px;
  }

  body.drawer-open .details-swipe-hint {
    display: inline-flex;
    align-self: center;
    min-height: 32px;
    padding: 7px 14px;
    border-color: var(--panel-glass-border);
    background: var(--panel);
    color: var(--muted);
    touch-action: none;
  }

  .details-body {
    padding-right: 4px;
  }

  .details-ok {
    display: inline-flex !important;
    width: 100%;
    justify-content: center;
  }

  .drawer-panel,
  .drawer-close {
    display: none !important;
  }

  .actions button {
    flex: 1 1 100%;
  }

  .actions.lightning-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions.lightning-grid button {
    width: 100%;
  }

  .week-card {
    padding: 8px 10px;
  }

  .week-metrics {
    gap: 6px;
  }

  .week-metric {
    padding: 6px 7px;
  }

  .week-metric strong {
    font-size: 16px;
  }

  .checklist-item {
    flex-direction: row;
    align-items: flex-start;
  }

  .checklist-delete-icon {
    width: 34px;
    height: 34px;
    margin-top: -2px;
  }
}

@keyframes drawer-enter-swipe-hint {
  0% {
    opacity: 0;
    transform: translateX(34px);
  }
  58% {
    opacity: 1;
    transform: translateX(0);
  }
  78% {
    transform: translateX(12px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 1119px) and (pointer: coarse) {
  .sidebar {
    padding: 12px;
  }

  .sidebar-top h1 {
    font-size: 24px;
  }

  .auth-top {
    gap: 10px;
  }

  .auth-theme-toggle {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 13px;
  }

  .eyebrow,
  .muted,
  .field-help,
  .field-label {
    font-size: 13px;
  }

  .account-card {
    padding: 10px 12px;
  }

  .account-theme {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .pane-tab,
  .sidebar-actions button {
    min-height: 46px;
    padding: 10px 8px;
    font-size: 15px;
  }

  .badge {
    font-size: 12px;
    min-width: 22px;
  }

  .filter-chip {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .list-title,
  #listTitle,
  #detailsTitle,
  h2 {
    font-size: 21px;
  }

  .row-title {
    font-size: 16px;
  }

  .row-title.mono {
    font-size: 15px;
  }

  .row-meta {
    font-size: 13px;
    line-height: 1.35;
  }

  .deal-row .row-title {
    font-size: 18px;
  }

  .deal-row .row-title.mono {
    font-size: 16px;
  }

  .deal-row .row-meta {
    font-size: 14px;
  }

  .row-tag {
    font-size: 12px;
    padding: 4px 9px;
  }

  .chat {
    padding: 12px;
  }

  .bubble {
    max-width: 94%;
    font-size: 15px;
    line-height: 1.4;
    padding: 10px 12px;
  }

  .chat-status {
    min-height: 18px;
    font-size: 13px;
  }

  #chatInput {
    min-height: 64px;
    font-size: 16px;
    padding: 12px 14px;
  }

  .card {
    padding: 14px;
  }

  .card-title {
    font-size: 17px;
  }

  .card-title.mono {
    font-size: 16px;
  }

  .card-meta {
    font-size: 14px;
    line-height: 1.4;
  }

  .notice {
    font-size: 13px;
  }

  .deal-card .card-title {
    font-size: 19px;
  }

  .deal-card .card-meta,
  .deal-card .checklist-preview-item span {
    font-size: 15px;
  }

  .checklist-preview-item {
    font-size: 14px;
  }

  .checklist-delete-icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .details-ok {
    min-height: 48px;
    font-size: 16px;
  }
}
