/* Mobile-first system styles. */

:root {
  --fg: #1a1a1a;
  --bg: #fafafa;
  --muted: #6b6b6b;
  --line: #e3e3e3;
  --accent: #f6851f;
  --accent-soft: rgba(246, 133, 31, 0.7);
  --accent-fg: #1a1a1a;
  --error: #b3261e;
  --row-bg: #ffffff;
  --section-bg: #f4f4f4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #ececec;
    --bg: #181818;
    --muted: #a0a0a0;
    --line: #2c2c2c;
    --accent: #f6851f;
    --accent-soft: rgba(246, 133, 31, 0.7);
    --accent-fg: #1a1a1a;
    --row-bg: #222222;
    --section-bg: #1f1f1f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 15px;
  line-height: 1.35;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
}

main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 14px;
  align-items: start;
}

.sidebar {
  background: var(--row-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  position: sticky;
  top: 12px;
}

.sidebar h2 {
  font-size: 0.78rem;
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.viewer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
}

.shell-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.shell-header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--error); }

.card {
  background: var(--row-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.briefing-list li {
  border-bottom: 1px solid var(--line);
}

.briefing-list a {
  display: block;
  padding: 6px 4px;
  font-size: 0.92rem;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.briefing-list a:hover { color: var(--accent); }

.briefing-list li.active a {
  color: var(--accent);
  font-weight: 600;
}

.summary, .thread, .needs-review {
  background: var(--row-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
}

.summary { border-left-color: var(--muted); }
.needs-review { border-left-color: var(--error); }
.thread { border-left-color: var(--accent-soft); }

.thread h2, .summary h2, .needs-review h2 {
  font-size: 1.1rem;
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.thread-header {
  position: relative;
  padding: 0 32px 6px 0;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.thread-header > h2 { margin: 0; }
.thread-header > .muted { margin: 2px 0 0; }

.section {
  border-top: 1px solid var(--line);
  padding-top: 6px;
  margin-top: 6px;
}

.section:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 4px;
}

.section h3 {
  font-size: 0.72rem;
  margin: 0 0 2px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

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

.row {
  position: relative;
  padding: 4px 32px 4px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row > .muted { margin: 1px 0 0; }

.row-text { font-weight: 500; }

.controls {
  position: absolute;
  top: 6px;
  right: 4px;
}

.btn-edit {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-edit:hover {
  color: var(--accent);
  border-color: var(--line);
  background: var(--row-bg);
}

.btn-edit.has-feedback {
  color: var(--accent);
  border-color: var(--line);
  background: var(--accent-soft);
}

.btn-edit.has-feedback:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-edit svg { display: block; }

.btn-edit-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  display: none;
}

.btn-edit.has-feedback .btn-edit-count {
  display: inline-block;
}

.popover {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: min(320px, calc(100vw - 32px));
  background: var(--row-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 12px;
  z-index: 10;
}

.popover.hidden { display: none; }

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.popover-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.popover-section-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 6px;
}

.popover-section-heading + .popover-actions,
.popover-history + .popover-section-heading {
  margin-top: 4px;
}

.popover-history {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.popover-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popover-history-item {
  background: var(--section-bg);
  border-radius: 6px;
  padding: 6px 8px;
}

.popover-history-kind {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.popover-history-preview {
  font-size: 0.85rem;
  color: var(--fg);
  margin-top: 2px;
  word-break: break-word;
}

.popover-history-ts {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.popover-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-action {
  font: inherit;
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

.btn-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-submit, .btn-link {
  font: inherit;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

.btn-link:hover { border-color: var(--accent); color: var(--accent); }

.btn-submit {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.btn-submit:disabled { opacity: 0.6; cursor: default; }

.btn-link {
  border-color: transparent;
  background: transparent;
  text-decoration: underline;
  color: var(--muted);
  padding: 0;
}

.btn-close {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.btn-close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.feedback-form {
  background: var(--section-bg);
  padding: 10px 12px;
  border-radius: 6px;
}

.form-heading {
  font-weight: 600;
  margin: 0 0 6px;
}

.form-row { margin: 6px 0; }

.form-row label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-row input,
.form-row textarea {
  display: block;
  width: 100%;
  font: inherit;
  margin-top: 2px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--row-bg);
  color: var(--fg);
}

.form-status {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.shell-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.shell-logo {
  height: 28px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  align-self: center;
  flex-shrink: 0;
}

.shell-title h1 {
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.shell-sep {
  color: var(--line);
}

.shell-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.shell-actions {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.fixture-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  background: #b3261e;
  color: #ffffff;
}

.fixture-sidebar {
  background: var(--section-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
}

.fixture-sidebar h2 {
  font-size: 0.95rem;
  margin: 0 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
