:root {
  color-scheme: light;
  --bg: #f3eee6;
  --bg-strong: #eadfce;
  --paper: rgba(255, 251, 246, 0.92);
  --paper-strong: #fff9f2;
  --ink: #231712;
  --muted: #6f5a4e;
  --line: rgba(76, 43, 21, 0.14);
  --brand: #9d5c31;
  --brand-dark: #6a3919;
  --accent: #c27d34;
  --success: #2d6a4f;
  --danger: #8c3b2c;
  --shadow: 0 22px 50px rgba(80, 48, 24, 0.14);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(219, 170, 111, 0.28), transparent 28%),
    radial-gradient(circle at top right, rgba(133, 88, 51, 0.14), transparent 24%),
    linear-gradient(180deg, #f5efe6 0%, #efe4d3 100%);
  color: var(--ink);
}

body {
  padding: 18px;
}

button,
textarea {
  font: inherit;
}

.page-shell {
  max-width: 1240px;
  margin: 0 auto;
}

.topbar,
.summary-strip,
.mode-row,
.filters,
.content-grid {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 5vw, 2.9rem);
  line-height: 0.98;
}

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

.summary-card,
.list-panel,
.detail-panel,
.warning-card,
.mode-pill,
.ghost-button,
.primary-button,
.filter-chip,
.view-chip {
  border-radius: 18px;
}

.summary-card,
.list-panel,
.detail-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.summary-card {
  padding: 14px 16px;
}

.summary-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-value {
  display: block;
  margin-top: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
}

.mode-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
}

.mode-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  background: rgba(157, 92, 49, 0.12);
  border: 1px solid rgba(157, 92, 49, 0.24);
  color: var(--brand-dark);
  font-weight: 700;
}

.warning-stack {
  display: grid;
  gap: 8px;
  flex: 1;
}

.warning-card {
  padding: 10px 12px;
  background: rgba(194, 125, 52, 0.11);
  border: 1px solid rgba(194, 125, 52, 0.25);
  color: var(--brand-dark);
  font-size: 0.92rem;
}

.view-switcher,
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.view-chip,
.filter-chip,
.ghost-button,
.primary-button {
  border: 1px solid var(--line);
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff8f1;
  border-color: transparent;
  font-weight: 700;
}

.view-chip.is-active,
.filter-chip.is-active {
  background: rgba(157, 92, 49, 0.16);
  border-color: rgba(157, 92, 49, 0.3);
  color: var(--brand-dark);
}

.ghost-button:hover,
.primary-button:hover,
.view-chip:hover,
.filter-chip:hover {
  transform: translateY(-1px);
}

.ghost-button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.list-panel,
.detail-panel {
  min-height: 66vh;
}

.list-panel {
  padding: 16px;
}

.list-header,
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.list-header h2,
.detail-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.list-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.item-card {
  padding: 14px;
  border-radius: 18px;
  background: var(--paper-strong);
  border: 1px solid var(--line);
  cursor: pointer;
}

.item-card.is-active {
  border-color: rgba(157, 92, 49, 0.45);
  box-shadow: inset 0 0 0 1px rgba(157, 92, 49, 0.12);
}

.item-card.is-unread {
  background: linear-gradient(180deg, rgba(255, 247, 233, 0.96) 0%, rgba(255, 250, 244, 0.92) 100%);
}

.item-top,
.item-meta,
.thread-row,
.composer {
  display: flex;
  gap: 10px;
}

.item-top {
  align-items: center;
  justify-content: space-between;
}

.item-title {
  font-weight: 700;
}

.item-subtitle,
.item-time,
.muted {
  color: var(--muted);
}

.item-snippet {
  margin-top: 8px;
  font-size: 0.95rem;
  line-height: 1.35;
}

.item-meta {
  flex-wrap: wrap;
  margin-top: 10px;
}

.tag,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.tag {
  background: rgba(157, 92, 49, 0.1);
  color: var(--brand-dark);
}

.badge {
  min-width: 26px;
  background: rgba(45, 106, 79, 0.14);
  color: var(--success);
  font-weight: 700;
}

.detail-panel {
  padding: 18px;
  display: flex;
}

.detail-empty,
.detail-card {
  width: 100%;
}

.detail-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 30px;
}

.is-hidden {
  display: none !important;
}

.detail-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.detail-note {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(194, 125, 52, 0.1);
  border: 1px solid rgba(194, 125, 52, 0.18);
  color: var(--brand-dark);
  font-size: 0.88rem;
  line-height: 1.35;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.thread-box {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  max-height: 56vh;
  overflow: auto;
  padding-right: 4px;
}

.thread-row {
  align-items: flex-start;
}

.thread-row.out {
  justify-content: flex-end;
}

.bubble {
  max-width: min(82%, 620px);
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 250, 244, 0.95);
  border: 1px solid var(--line);
}

.thread-row.out .bubble {
  background: linear-gradient(135deg, rgba(157, 92, 49, 0.95) 0%, rgba(194, 125, 52, 0.88) 100%);
  color: #fff8f1;
  border-color: transparent;
}

.bubble-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
}

.bubble-text {
  margin-top: 8px;
  line-height: 1.42;
  white-space: pre-wrap;
}

.composer {
  flex-direction: column;
  margin-top: 16px;
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 248, 0.95);
  color: var(--ink);
}

.empty-state {
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 960px) {
  body {
    padding: 12px;
  }

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

  .content-grid {
    grid-template-columns: 1fr;
  }

  .list-panel,
  .detail-panel {
    min-height: auto;
  }

  .thread-box {
    max-height: 44vh;
  }
}

@media (max-width: 640px) {
  .topbar,
  .mode-row {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .summary-strip {
    grid-template-columns: 1fr 1fr;
  }

  .detail-actions {
    width: 100%;
  }

  .detail-actions .ghost-button,
  .composer .primary-button,
  .ghost-button {
    width: 100%;
  }

  .bubble {
    max-width: 100%;
  }
}
