:root {
  color-scheme: dark;
  --ink: #f1eee8;
  --ink-strong: #fffbf2;
  --muted: #aaa49b;
  --line: rgb(241 238 232 / 0.1);
  --page: #0d0e0c;
  --surface: #1b1c19;
  --surface-strong: #22231f;
  --surface-muted: #151612;
  --frost: rgb(241 238 232 / 0.055);
  --accent: #c86f4c;
  --accent-strong: #e09372;
  --coral: #c77770;
  --violet: #8d8fba;
  --yellow: #d6ad43;
  --button-light: #ece8de;
  --button-light-hover: #fffaf1;
  --shadow-soft: 0 18px 48px rgb(0 0 0 / 0.34);
  --shadow-card: none;
  --inner-light: inset 0 1px 0 rgb(255 255 255 / 0.06);
  --serif-display: "New York", "Iowan Old Style", Charter, "Palatino Linotype", Palatino, Georgia, serif;
  --sans-ui: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans-ui);
  font-optical-sizing: auto;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, opacity 120ms ease, color 120ms ease;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

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

.app-shell {
  position: relative;
  isolation: isolate;
  overflow: clip;
  width: min(100%, 760px);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--surface-muted);
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 20px 22px;
  background: #10110f;
  color: white;
  border-bottom: 1px solid var(--line);
  box-shadow: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.94;
}

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

h1 {
  max-width: 13ch;
  margin-bottom: 0;
  color: var(--ink-strong);
  font-family: var(--serif-display);
  font-size: 2.34rem;
  line-height: 0.98;
  font-weight: 400;
}

h2 {
  margin-bottom: 4px;
  color: var(--ink-strong);
  font-size: 1.24rem;
  font-weight: 680;
}

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid rgb(244 242 236 / 0.16);
  background: var(--button-light);
  color: #11120f;
  font-size: 0.78rem;
  font-weight: 720;
  box-shadow: none;
}

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 7px;
  border-bottom: 1px solid var(--line);
  background: #12130f;
  box-shadow: none;
}

.tab {
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.tab.active {
  color: var(--ink-strong);
  background: rgb(244 242 236 / 0.08);
  border-color: rgb(244 242 236 / 0.08);
  box-shadow: none;
}

main {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 22px 20px;
  background: var(--surface-muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#thread-view.active {
  display: flex;
  min-height: calc(100vh - 190px);
  flex-direction: column;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.thread-toolbar {
  align-items: center;
  margin-bottom: 14px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.thread-toolbar #thread-status {
  min-width: 0;
  font-size: 0.92rem;
}

#thread-context {
  max-width: 30ch;
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.thread-list,
.message-list {
  display: grid;
  gap: 10px;
}

.snippet-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.snippet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.snippet-empty {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.snippet-chip {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--frost);
  box-shadow: none;
}

.snippet-send {
  padding: 8px 12px;
  background: var(--button-light);
  color: #11120f;
  font-weight: 700;
}

.snippet-send:hover {
  background: var(--button-light-hover);
}

.snippet-form {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.snippet-form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.snippet-manage-list {
  display: grid;
  gap: 12px;
}

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

.snippet-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.snippet-card p {
  margin-bottom: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.snippet-card-actions {
  display: grid;
  gap: 8px;
}

#thread-view .message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 14px;
  -webkit-overflow-scrolling: touch;
}

.thread-card,
.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.thread-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  width: 100%;
  padding: 14px;
  text-align: left;
  color: var(--ink);
}

.thread-card:hover {
  border-color: rgb(244 242 236 / 0.2);
  background: var(--surface-strong);
  box-shadow: none;
}

.thread-card.unread {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.thread-card h3 {
  overflow-wrap: anywhere;
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.35;
  font-weight: 680;
}

.thread-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.play-mini {
  align-self: center;
  min-width: 56px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(244 242 236 / 0.14);
  border-radius: 8px;
  background: rgb(244 242 236 / 0.06);
  color: var(--ink-strong);
  font-size: 0.88rem;
  font-weight: 680;
  box-shadow: none;
}

.message {
  padding: 16px;
}

.message.root {
  border-color: rgb(208 120 86 / 0.34);
}

.message.unread {
  box-shadow: inset 3px 0 0 var(--yellow);
}

.message-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.message-body,
.message p {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 0.96rem;
  font-weight: 430;
}

.formatted-slack strong {
  font-weight: 900;
}

.formatted-slack em {
  font-style: italic;
}

.formatted-slack a {
  color: var(--accent);
  font-weight: 680;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.formatted-slack code {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  background: rgb(244 242 236 / 0.07);
  color: var(--ink-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.slack-emoji {
  display: inline-block;
  min-width: 1.1em;
}

.reply-panel,
.settings-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.reply-panel {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-right: -18px;
  margin-left: -18px;
  padding: 15px 18px 18px;
  border-top: 1px solid var(--line);
  background: #151612;
  box-shadow: 0 -12px 28px rgb(0 0 0 / 0.26);
}

.reply-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reply-send-actions {
  display: grid;
  grid-template-columns: 1fr minmax(118px, 0.42fr);
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #10110f;
  color: var(--ink);
  box-shadow: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgb(200 111 76 / 0.62);
  outline: 3px solid rgb(208 120 86 / 0.16);
}

textarea {
  resize: vertical;
}

textarea[readonly] {
  background: #121310;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.check-row input {
  width: 20px;
  height: 20px;
}

.settings-hint {
  margin: -4px 0 0 32px;
  color: var(--muted);
  font-size: 0.88rem;
}

.primary-button {
  background: var(--button-light);
  border-color: var(--button-light);
  color: #11120f;
  font-weight: 700;
  box-shadow: none;
}

.primary-button:hover {
  background: var(--button-light-hover);
  border-color: var(--button-light-hover);
}

.primary-button:active {
  background: #e5e2d8;
}

.danger-button {
  background: rgb(199 119 112 / 0.16);
  border-color: rgb(199 119 112 / 0.34);
  color: #efb2aa;
  font-weight: 700;
  box-shadow: none;
}

.ghost-button,
.text-button {
  border: 1px solid var(--line);
  background: var(--frost);
  color: var(--ink);
  font-weight: 680;
  box-shadow: none;
}

.ghost-button:hover,
.text-button:hover {
  background: rgb(244 242 236 / 0.1);
  border-color: rgb(244 242 236 / 0.18);
}

.text-button {
  margin-bottom: 16px;
}

.final-preview {
  min-height: 22px;
  margin-bottom: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: rgb(244 242 236 / 0.04);
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  width: min(calc(100% - 32px), 520px);
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgb(244 242 236 / 0.14);
  background: #0d0e0c;
  color: white;
  text-align: center;
  box-shadow: 0 18px 44px rgb(0 0 0 / 0.36);
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease, padding 160ms ease;
  pointer-events: none;
}

#toast.visible {
  padding: 12px;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 680px) {
  .app-shell {
    min-height: calc(100vh - 32px);
    margin-top: 16px;
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid rgb(244 242 236 / 0.1);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
  }

  .topbar,
  main {
    padding-left: 28px;
    padding-right: 28px;
  }

  .reply-panel {
    margin-right: -28px;
    margin-left: -28px;
    padding-right: 28px;
    padding-left: 28px;
  }

  h1 {
    max-width: none;
  }
}
