:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-alt: #f9f8f4;
  --text: #171717;
  --muted: #6f6a60;
  --line: #ddd8cd;
  --accent: #176c63;
  --accent-strong: #0f4d47;
  --danger: #b92727;
  --shadow: 0 16px 44px rgba(32, 30, 26, 0.09);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
.buttonLink {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
}

button:hover,
.buttonLink:hover {
  border-color: var(--accent);
}

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

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.plain {
  border-color: transparent;
  background: transparent;
  color: var(--accent-strong);
}

.shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 120px;
}

.authView {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
}

.authPanel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
  padding: 10px 12px;
}

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-alt);
  padding: 2px 5px;
}

textarea {
  min-height: 240px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: #fff;
}

.notice,
.empty,
.muted {
  color: var(--muted);
  font-size: 14px;
}

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

.userbar,
.actions,
.inviteHeader {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button.active,
.archiveList button.active {
  border-color: var(--accent);
  background: #e1f0ed;
  color: var(--accent-strong);
}

.statusGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 18px;
}

.statusGrid div {
  min-width: 0;
  background: rgba(255, 255, 255, 0.72);
  padding: 14px;
}

.statusGrid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.statusGrid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.statusGrid em {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.liveText {
  color: var(--danger);
}

.topicForm {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(180px, 1.1fr) minmax(180px, 1fr) auto;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.importPanel {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(180px, 0.8fr) minmax(260px, 1.4fr) auto;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.importPanel h2 {
  margin-bottom: 4px;
}

.importPanel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.importPanel textarea {
  min-height: 86px;
}

.actions {
  margin-bottom: 14px;
}

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

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

.topic {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.topicTitle,
.topic a {
  color: var(--text);
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
}

.topicTitle:hover,
.topic a:hover {
  color: var(--accent-strong);
}

.topic p {
  margin-bottom: 5px;
}

.urlText {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment {
  margin-top: 8px;
  margin-bottom: 0;
  color: #34312d;
  line-height: 1.45;
}

.topicTools {
  display: grid;
  gap: 8px;
  width: 128px;
}

.timeline {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.timelineList {
  display: grid;
  gap: 8px;
}

.timelineItem {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 13px;
}

.timelineTimeInput {
  width: 92px;
  padding: 5px 6px;
  color: var(--accent-strong);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.timelineTimeInput.invalid {
  border-color: var(--danger);
  color: var(--danger);
}

.timelineItem span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archiveLayout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.archiveList,
.archiveDetails,
.inviteList,
.archiveCard {
  display: grid;
  gap: 10px;
}

.archiveList button {
  justify-content: flex-start;
  text-align: left;
}

.archiveDetails,
.inviteList {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 14px;
}

.compact .topic {
  box-shadow: none;
}

.inviteHeader {
  margin-bottom: 12px;
}

#newInvite {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  font-weight: 700;
}

.inviteItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.inviteItem:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.inviteItem p {
  margin: 0;
}

.chatBox {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(360px, calc(100vw - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chatBox header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.chatBox.collapsed .chatMessages,
.chatBox.collapsed .chatForm {
  display: none;
}

.chatMessages {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 10px;
}

.chatMessage {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  padding: 8px;
}

.chatMessage p {
  margin: 4px 0;
  line-height: 1.35;
}

.chatMessage span {
  color: var(--muted);
  font-size: 12px;
}

.chatForm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .topbar,
  .workspace,
  .archiveLayout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .statusGrid,
  .topicForm,
  .importPanel {
    grid-template-columns: 1fr;
  }

  .timeline {
    position: static;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 20px, 1220px);
    padding-top: 16px;
  }

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

  .topicTools {
    width: 100%;
  }

  .chatBox {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}
