:root {
  --bg: #0a0a0a;
  --surface: #191919;
  --raised: #1a1c20;
  --ink: #ffffff;
  --body: #dadbdf;
  --muted: #7d8187;
  --accent: #c6c6c6;
  --danger: #c47a7a;
  --hairline: #212327;
  --pill-border: rgba(255, 255, 255, 0.25);
  --on-primary: #0a0a0a;
  --radius-card: 8px;
  --radius-pill: 9999px;
  --font-ui: Inter, system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  --font-quote: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 400;
}

.shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 48px 20px 64px;
  transition: max-width 0.2s ease;
}

.shell.shell-wide {
  max-width: 1100px;
}

.env-status {
  margin: 0 0 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.brand-row img {
  display: block;
  flex-shrink: 0;
  margin-top: 4px;
}

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

.app-version {
  flex-shrink: 0;
  align-self: flex-start;
  margin: 4px 0 0;
  min-height: 32px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 1.2px;
  text-transform: lowercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--pill-border);
  border-radius: var(--radius-pill);
}

.app-version:hover:not(:disabled) {
  background: var(--raised);
}

.app-version:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.app-version:focus-visible,
.tab:focus-visible,
.ghost:focus-visible,
.color-chip:focus-visible,
select:focus-visible,
input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

h1 {
  margin: 0;
  font-family: var(--font-ui);
  font-size: clamp(1.75rem, 4vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.sub,
.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.sub {
  margin: 8px 0 0;
  color: var(--body);
}

.top {
  margin-bottom: 24px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hairline);
}

.tab {
  background: transparent;
  color: var(--muted);
  min-height: 32px;
  padding: 6px 16px;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0;
  text-transform: none;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
}

.tab:hover {
  color: var(--ink);
  background: var(--raised);
}

.tab.active {
  color: var(--ink);
  border-color: var(--pill-border);
  background: transparent;
}

.log-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 12px;
}

.log-toolbar[hidden] {
  display: none !important;
}

.log-row .log-copy {
  margin-left: auto;
  min-height: 32px;
  padding: 4px 12px;
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0;
}

.log-row:hover .log-copy,
.log-row:focus-within .log-copy {
  opacity: 1;
}

.log-feed {
  margin-top: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  background: var(--bg);
  padding: 6px 0;
  max-height: min(70vh, 52rem);
  overflow-y: auto;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.log-row {
  padding: 8px 16px;
  background: transparent;
  font-size: 12px;
  line-height: 1.4;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
}

.log-row:hover {
  background: var(--raised);
}

.log-row.level-warn {
  border-left: 3px solid #a89a5c;
}

.log-row.level-error {
  border-left: 3px solid var(--danger);
}

.log-row.level-info {
  border-left: 3px solid #3a3a3a;
}

.log-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
}

.log-event {
  font-weight: 400;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-size: 12px;
}

.log-row.level-warn .log-event {
  color: #c9b86a;
}

.log-row.level-error .log-event {
  color: var(--danger);
}

.log-msg {
  flex: 1;
  min-width: 12rem;
}

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

.log-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.log-detail {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: var(--raised);
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 8rem;
  overflow-y: auto;
  border-radius: var(--radius-card);
}

.search {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.search span,
.toolbar label > span,
.color-bar > span {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.color-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.color-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.color-chip {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid var(--pill-border);
  border-radius: var(--radius-pill);
  background: var(--chip, var(--surface));
  cursor: pointer;
}

.color-chip.on {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);
}

.color-chip.all {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
}

.color-chip.all.on {
  color: var(--ink);
}

.toolbar[hidden],
.search[hidden],
.color-bar[hidden],
.feed[hidden],
.log-feed[hidden],
#empty[hidden],
#empty-logs[hidden],
.toast[hidden] {
  display: none !important;
}

.toolbar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 8rem;
}

select {
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 8px 12px;
  min-height: 40px;
  font: inherit;
  outline: none;
  cursor: pointer;
}

select:focus {
  border-color: var(--pill-border);
}

input {
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  min-height: 44px;
  font: inherit;
  outline: none;
}

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

input:focus {
  border-color: var(--pill-border);
}

button {
  font: inherit;
  font-weight: 400;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  padding: 8px 16px;
  min-height: 40px;
  background: var(--ink);
  color: var(--on-primary);
}

button:hover:not(:disabled) {
  filter: brightness(0.96);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

.ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border: 1px solid transparent;
}

.ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--raised);
  border-color: var(--pill-border);
  filter: none;
}

.danger:hover:not(:disabled) {
  color: var(--danger);
  border-color: rgba(196, 122, 122, 0.4);
}

.empty-state {
  margin: 32px 0 0;
  padding: 48px 24px;
  text-align: center;
  color: var(--body);
  font-size: 16px;
  line-height: 24px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}

.feed {
  margin-top: 8px;
}

.group {
  margin-top: 32px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 400;
  line-height: 28px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.group-swatch {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--pill-border);
  flex-shrink: 0;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list.view-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.row {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  cursor: pointer;
}

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

.view-grid .row {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 16px;
  min-height: 11rem;
}

.view-grid .swatch {
  width: 100%;
  height: 4px;
  min-height: 4px;
  border-radius: var(--radius-pill);
}

.view-grid .body {
  min-width: 0;
}

.view-grid blockquote {
  font-size: 1rem;
  display: block;
  max-height: 12.5em;
  overflow-y: auto;
  overflow-wrap: break-word;
}

.view-grid .note {
  white-space: pre-wrap;
  word-break: break-word;
}

.view-grid .meta {
  flex-direction: column;
  gap: 4px;
}

.view-grid .meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.view-grid .actions {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}

.swatch {
  width: 6px;
  min-height: 3rem;
  align-self: stretch;
  border-radius: 4px;
}

blockquote {
  margin: 0;
  font-family: var(--font-quote);
  font-size: 1.15rem;
  line-height: 1.45;
  font-weight: 400;
}

.quote-link {
  color: inherit;
  text-decoration: none;
}

.quote-link:hover blockquote {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note {
  margin: 8px 0 0;
  font: 0.8rem/1.4 var(--font-mono);
  color: var(--muted);
  white-space: pre-wrap;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.meta a {
  color: var(--body);
  text-decoration: none;
}

.meta a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 16px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  font-size: 14px;
  line-height: 20px;
}

.toast.err {
  color: var(--danger);
}

.detail-dialog {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border: none;
  background: transparent;
  color: var(--ink);
}

.detail-dialog[open] {
  display: grid;
  place-items: center;
}

.detail-dialog::backdrop {
  background: rgb(0 0 0 / 0.85);
}

.detail-panel {
  position: relative;
  width: min(40rem, 100%);
  max-height: min(85dvh, 44rem);
  overflow: auto;
  padding: 28px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}

.detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.detail-swatch {
  display: block;
  width: 100%;
  height: 4px;
  margin: 0 36px 16px 0;
  border-radius: var(--radius-pill);
}

.detail-dialog blockquote {
  max-height: none;
  overflow: visible;
}

@media (max-width: 640px) {
  .view-list .row {
    grid-template-columns: 4px 1fr;
  }
  .view-list .actions {
    grid-column: 2;
    flex-direction: row;
    justify-self: start;
    align-items: center;
  }
  .toolbar {
    flex-direction: column;
  }
  .toolbar label {
    min-width: 0;
    width: 100%;
  }
  .color-chip {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .app-version,
  .tab,
  .ghost,
  button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
  button:active:not(:disabled) {
    transform: none;
  }
}
