:root {
  color-scheme: light;
  --bg: #f5f2ed;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --text: #17201d;
  --muted: #65706c;
  --line: #dfe4dc;
  --line-strong: #cbd4ca;
  --accent: #1f7a5a;
  --accent-strong: #155f46;
  --accent-soft: #e5f3ec;
  --ink: #24364a;
  --ink-soft: #e8eef4;
  --danger: #a5282c;
  --danger-soft: #feecec;
  --success: #1d6d43;
  --warning: #8a5a00;
  --shadow: 0 10px 28px rgba(36, 54, 74, 0.08);
  --shadow-soft: 0 1px 2px rgba(23, 32, 29, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fffaf4 0, var(--bg) 320px),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0 14px;
  font-weight: 700;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary,
.icon-button {
  background: #fff;
  color: var(--accent);
}

button.secondary:hover,
.icon-button:hover {
  background: var(--accent-soft);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  min-width: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(31, 122, 90, 0.18);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.12;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 15px;
}

.app-shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -18px 16px;
  padding: 12px 18px;
  background: rgba(255, 250, 244, 0.92);
  border-bottom: 1px solid rgba(203, 212, 202, 0.72);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.language-picker {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 8px;
  white-space: nowrap;
}

.language-picker select {
  min-width: 126px;
}

.session-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  min-width: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 7px;
  box-shadow: var(--shadow-soft);
}

.session-label {
  border-radius: 999px;
  background: var(--ink-soft);
  color: var(--ink);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.current-user {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.sidebar,
.content-grid {
  display: grid;
  align-content: start;
  gap: 16px;
}

.content-grid {
  grid-template-columns: minmax(0, 1fr);
}

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

.feed-panel {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.account-panel,
.topics-panel {
  background: rgba(255, 255, 255, 0.92);
}

.panel-heading,
.subheading,
.tasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.split-heading {
  align-items: flex-start;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.composer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.composer textarea {
  border-color: transparent;
  background: #fff;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
}

.segmented button.active {
  background: var(--ink);
  color: #fff;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.notice.error {
  border-color: #efb4b4;
  background: var(--danger-soft);
  color: var(--danger);
}

.notice.success {
  border-color: #b7dcc6;
  background: #edf8f1;
  color: var(--success);
}

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

.hidden {
  display: none !important;
}

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

.compact-list {
  margin-top: 14px;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  background: var(--surface-soft);
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.feed-panel .item,
.topic-detail .item {
  border-color: var(--line-strong);
}

.item.selectable {
  cursor: pointer;
}

.item.selectable:hover,
.item.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.item-title {
  font-weight: 750;
  overflow-wrap: anywhere;
}

.item-body {
  color: #2a3442;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: #edf0f4;
  color: #394352;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}

.badge.warning {
  background: #fff4d8;
  color: var(--warning);
}

.detail-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(240px, 0.8fr);
  gap: 16px;
}

.message-column,
.persona-column {
  min-width: 0;
}

#admin-panel {
  background: #fbfbfa;
  box-shadow: none;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-row input {
  width: auto;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filters {
  display: flex;
  gap: 8px;
}

.filters select {
  min-width: 150px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td .button-row {
  flex-wrap: nowrap;
}

td button {
  min-height: 32px;
  padding: 0 10px;
}

tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: column;
  }

  .session-card {
    max-width: none;
    min-width: 0;
  }

  .detail-columns,
  .admin-grid,
  .sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    margin: 0 -12px 12px;
    padding: 12px;
  }

  h1 {
    font-size: 23px;
  }

  h2 {
    font-size: 17px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .topbar-actions,
  .session-card,
  .inline-form,
  .panel-heading,
  .tasks-header,
  .filters {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .language-picker {
    width: 100%;
    align-items: stretch;
  }

  .language-picker select {
    width: 100%;
    min-width: 0;
  }

  .session-card {
    grid-template-columns: 1fr;
  }

  .current-user {
    text-align: left;
    white-space: normal;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .item-header {
    display: grid;
  }

  .meta {
    white-space: normal;
  }
}
