:root {
  color-scheme: dark;
  --page: #09090B;
  --page-2: #0F0F12;
  --surface: #151518;
  --surface-2: #1A1A1E;
  --surface-3: #202025;
  --surface-4: #25252B;
  --border: #29292F;
  --border-strong: #35353D;
  --text: #F5F5F7;
  --text-2: #B9B9C2;
  --muted: #85858F;
  --dim: #65656F;
  --focus: #E4E4E7;
  --primary: #F4F4F5;
  --primary-hover: #DFDFE3;
  --primary-text: #09090B;
  --success: #90C1A2;
  --warning: #CAB07D;
  --error: #D59290;
  --info: #98B0CD;
  --radius: 9px;
  --radius-lg: 13px;
  --fast: 140ms;
  --normal: 210ms;
  --slow: 380ms;
  --ease: cubic-bezier(.2, .72, .2, 1);
  --spring: cubic-bezier(.22, 1, .36, 1);
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

button,
select {
  cursor: pointer;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--text-2);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

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

h1 {
  font-size: 20px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

h3 {
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

.note {
  color: var(--text-2);
  font-size: 13px;
}

.button {
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  transition:
    background var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}

a.button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.button:active:not(:disabled) {
  background: var(--surface-4);
}

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

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

.button.small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.button.danger {
  border-color: var(--error);
  color: var(--error);
}

.button.danger:hover:not(:disabled) {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--text);
}

input,
select {
  min-height: 36px;
  padding: 7px 10px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--primary);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.tag {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius) - 4px);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.tag.error {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent);
  color: var(--error);
}

.tag.warning {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--warning);
}

.tag.success {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
}

.message {
  padding: 10px 12px;
  border: 1px solid;
  border-radius: var(--radius);
}

.message.error {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, var(--surface));
  color: var(--error);
}

.message.success {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  color: var(--success);
}

.gate {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 24px;
}

.gate-panel {
  display: grid;
  width: min(100%, 400px);
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.gate-panel p {
  color: var(--text-2);
}

.gate-panel .button {
  justify-self: start;
}

.app-shell {
  display: grid;
  height: 100vh;
  height: 100dvh;
  grid-template-columns: 228px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--page-2);
}

.brand {
  padding: 20px 18px 14px;
  font-weight: 700;
}

.sidebar nav {
  display: grid;
  gap: 16px;
  padding: 6px 10px 12px;
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-label {
  padding: 0 10px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  text-align: left;
  text-decoration: none;
  transition:
    background var(--fast) var(--ease),
    color var(--fast) var(--ease);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  border-color: var(--border);
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
}

.nav-count {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.sidebar-bottom {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 4px 10px;
}

.account div {
  display: grid;
  min-width: 0;
}

.account strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.page-head {
  display: grid;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

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

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

.filters input {
  flex: 1 1 260px;
  width: auto;
}

.filters .button {
  flex: 0 0 auto;
}

.load-more {
  display: flex;
  justify-content: center;
  padding: 14px 16px;
}

.section-head input[type="search"] {
  width: auto;
  flex: 0 1 220px;
}

.transcript-line.same {
  padding-top: 0;
}

.transcript-line:has(+ .same) {
  padding-bottom: 4px;
  border-bottom-color: transparent;
}

.filters select {
  flex: 0 1 190px;
  width: auto;
}

.toast {
  position: fixed;
  z-index: 20;
  top: 16px;
  right: 18px;
  display: flex;
  max-width: min(420px, calc(100vw - 36px));
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.toast button {
  padding: 2px 6px;
  border: 1px solid currentColor;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 600;
}

.split {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(280px, 34%) minmax(0, 1fr);
}

.list {
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--page-2);
}

.row {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  transition: background var(--fast) var(--ease);
}

.row:hover {
  background: var(--surface-2);
}

.row.selected {
  background: var(--surface-3);
}

.row:focus-visible {
  outline-offset: -2px;
}

.row-top,
.row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-top strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-top time,
.row-sub,
.row-meta {
  color: var(--muted);
  font-size: 12px;
}

.row-top time {
  flex: 0 0 auto;
}

.row-text {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-2);
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.row-meta {
  justify-content: flex-start;
  margin-top: 2px;
}

.detail {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
}

.detail-inner {
  display: grid;
  max-width: 860px;
  gap: 22px;
  padding: 20px 22px 32px;
}

.back {
  display: none;
  justify-self: start;
}

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

.detail-head > div:first-child {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.detail-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: var(--text-2);
  font-size: 13px;
}

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

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

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

.section-head select {
  width: auto;
  min-height: 30px;
  padding: 3px 8px;
  font-size: 13px;
}

.block {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.block-part {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.block-head span,
.block-meta {
  color: var(--muted);
  font-size: 12px;
}

.block p,
.event p {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.block .button {
  justify-self: start;
}

.block-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.block.reply {
  margin-left: 28px;
  background: var(--surface-2);
}

.reply-form {
  display: grid;
  gap: 10px;
}

.reply-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
}

.reply-options select {
  width: auto;
  min-height: 30px;
  padding: 3px 8px;
  font-size: 13px;
}

.reply-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.facts {
  margin: 0;
  border-top: 1px solid var(--border);
}

.fact {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  grid-template-columns: 170px minmax(0, 1fr);
}

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

.fact dd {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}

.fact dd > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.copy {
  flex: 0 0 auto;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: background var(--fast) var(--ease);
}

.copy:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.raw {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--page-2);
  color: var(--text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.events {
  border-top: 1px solid var(--border);
}

.event {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.event-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.event-head time,
.event > span {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  display: grid;
  gap: 4px;
  padding: 28px 20px;
  color: var(--text-2);
}

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

.settings {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
}

.settings-inner {
  display: grid;
  max-width: 760px;
  gap: 34px;
  padding: 22px 22px 40px;
}

.settings-section {
  display: grid;
  gap: 14px;
}

.settings-section > h2 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

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

.person {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.person > div:first-child {
  display: grid;
  min-width: 0;
}

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

.field-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.copy-field {
  display: flex;
  gap: 8px;
}

.copy-field input {
  min-width: 0;
  flex: 1;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
}

.provider {
  display: grid;
  min-width: 0;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.provider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

@media (max-width: 760px) {
  html,
  body {
    height: auto;
  }

  .app-shell {
    display: block;
    height: auto;
  }

  .sidebar {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand {
    padding: 14px 16px 6px;
  }

  .sidebar nav {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 6px 10px 10px;
  }

  .nav-group {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
  }

  .nav-label {
    display: none;
  }

  .nav-item {
    width: auto;
    min-height: 40px;
    flex: 0 0 auto;
  }

  .sidebar-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .account {
    flex: 1;
  }

  .page-head {
    padding: 14px 14px 12px;
  }

  .filters select {
    flex: 1 1 140px;
  }

  .workspace:has(.split.open) .page-head {
    display: none;
  }

  .split {
    display: block;
  }

  .list {
    border-right: 0;
  }

  .split:not(.open) .detail,
  .split.open .list {
    display: none;
  }

  .back {
    display: inline-flex;
    align-items: center;
  }

  .detail-inner,
  .settings-inner {
    padding: 16px 14px 28px;
  }

  .block.reply {
    margin-left: 12px;
  }

  .fact {
    gap: 2px;
    grid-template-columns: 1fr;
  }

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

  .row {
    padding: 12px 14px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: enter var(--normal) var(--spring);
  }

  @keyframes enter {
    from {
      opacity: 0;
      transform: translateY(-4px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
