/* ---------------------------------------------------------------------
   Signal Desk — design tokens (light, card-based console)
--------------------------------------------------------------------- */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-soft-border: #bfdbfe;
  --error: #dc2626;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------------------
   Shell
--------------------------------------------------------------------- */
.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.topbar__mark {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

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

/* ---------------------------------------------------------------------
   Layout: sidebar (query builder) + results panel
--------------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.panel--results {
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.panel__title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.panel__subtitle {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------------------------------------------------------------
   Fields
--------------------------------------------------------------------- */
.field {
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.field__input {
  width: 100%;
  resize: vertical;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 12px;
}

.field__input:focus {
  border-color: var(--accent);
}

.field__input::placeholder {
  color: #9ca3af;
}

.field__hint {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 14px;
}

/* ---------------------------------------------------------------------
   Channel grid
--------------------------------------------------------------------- */
.channels {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.channel {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.channel svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--muted);
  transition: color 0.15s ease;
}

.channel:hover {
  border-color: var(--accent-soft-border);
}

.channel[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.channel[aria-pressed="true"] svg {
  color: var(--accent);
}

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  appearance: none;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* ---------------------------------------------------------------------
   Empty state
--------------------------------------------------------------------- */
.empty-state {
  margin: auto;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state__icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg);
  margin-bottom: 14px;
}

.empty-state__icon svg {
  width: 24px;
  height: 24px;
}

.empty-state p {
  font-size: 14px;
  margin: 0;
}

/* ---------------------------------------------------------------------
   Bulletin (results)
--------------------------------------------------------------------- */
.bulletin {
  animation: reveal 0.25s ease;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.bulletin__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.bulletin__time {
  font-weight: 400;
  color: var(--muted);
}

.bulletin__body {
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: break-word;
  word-break: break-word;
}

.bulletin__body p {
  margin: 0 0 14px;
}

.bulletin__body h1,
.bulletin__body h2,
.bulletin__body h3 {
  margin: 18px 0 8px;
  font-weight: 700;
}

.bulletin__body a {
  color: var(--accent);
}

.bulletin__body code {
  font-family: ui-monospace, Menlo, monospace;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* result list (Search / Contents) */
.result-item {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.result-item:first-child {
  border-top: none;
}

.result-item__title {
  font-weight: 600;
  overflow-wrap: break-word;
}

.result-item__title a {
  color: var(--text);
  text-decoration: none;
}

.result-item__title a:hover {
  color: var(--accent);
}

.result-item__url {
  font-size: 12px;
  color: var(--accent);
  word-break: break-all;
  overflow-wrap: break-word;
}

.result-item__snippet {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* sources / citations */
.bulletin__sources {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  overflow-wrap: break-word;
  word-break: break-word;
}

.bulletin__sources:empty {
  display: none;
  border: none;
  padding: 0;
}

.bulletin__sources-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.source-ref {
  display: block;
  font-size: 12.5px;
  padding: 3px 0;
  color: var(--muted);
}

.source-ref span {
  color: var(--accent);
  font-weight: 600;
  margin-right: 6px;
}

.source-ref a {
  color: var(--muted);
}

.source-ref a:hover {
  color: var(--text);
}

/* error state */
.bulletin--error .bulletin__meta {
  color: var(--error);
}

.bulletin--error .bulletin__body {
  color: var(--error);
}

/* ---------------------------------------------------------------------
   Footer
--------------------------------------------------------------------- */
.foot {
  margin-top: 28px;
  text-align: center;
}

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

/* ---------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------- */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .app {
    padding: 20px 14px 40px;
  }

  .panel {
    padding: 16px;
  }
}
