:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #16202a;
  --muted: #667788;
  --border: #dde3ea;
  --green: #16a34a;
  --green-bg: #e8f8ee;
  --yellow: #d97706;
  --yellow-bg: #fdf3e3;
  --red: #dc2626;
  --red-bg: #fdecec;
  --grey: #64748b;
  --grey-bg: #f1f5f9;
  --accent: #1d4ed8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  padding: 2rem 1.25rem 0.5rem;
  max-width: 760px;
  margin: 0 auto;
}

.site-header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.site-header p { margin: 0; color: var(--muted); }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
}

label { display: block; font-weight: 600; margin-bottom: 0.5rem; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font: 0.95rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

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

.actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:disabled { opacity: 0.55; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }

.worker-status { color: var(--muted); font-size: 0.85rem; }
.worker-status.is-warn { color: var(--yellow); }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; padding: 0.85rem 1.25rem; }
.legend-item { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; color: var(--muted); }

.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.swatch-green { background: var(--green); }
.swatch-yellow { background: var(--yellow); }
.swatch-red { background: var(--red); }

.results-header { display: flex; align-items: center; justify-content: space-between; }
.results-header h2 { font-size: 1.05rem; margin: 1rem 0 0.5rem; }

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

.result {
  display: flex;
  gap: 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 6px solid var(--grey);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.result .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 0.4rem;
  flex: none;
  background: var(--grey);
}

.result.is-green { border-left-color: var(--green); background: var(--green-bg); }
.result.is-green .dot { background: var(--green); }
.result.is-yellow { border-left-color: var(--yellow); background: var(--yellow-bg); }
.result.is-yellow .dot { background: var(--yellow); }
.result.is-red { border-left-color: var(--red); background: var(--red-bg); }
.result.is-red .dot { background: var(--red); }
.result.is-error { border-left-color: var(--grey); background: var(--grey-bg); }
.result.is-pending .dot { animation: pulse 1s infinite ease-in-out; }

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.row-head strong { font-size: 1rem; word-break: break-all; }

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--grey);
}

.is-green .badge { background: #d0f0dc; color: var(--green); }
.is-yellow .badge { background: #f9e3bd; color: var(--yellow); }
.is-red .badge { background: #f9d4d4; color: var(--red); }

.reason { font-size: 0.9rem; color: var(--text); margin-top: 0.15rem; }
.meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; word-break: break-word; }

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

.interval-label {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  background: var(--card);
}

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

.watch-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.watch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.watch-head strong { word-break: break-all; }
.watch-meta { margin-left: auto; color: var(--muted); font-size: 0.8rem; }

.chip {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--grey);
}

.chip-pending { background: #e0e7ff; color: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
.chip-busy { background: var(--red-bg); color: var(--red); }
.chip-inactive { background: var(--yellow-bg); color: var(--yellow); }
.chip-found { background: #d0f0dc; color: var(--green); animation: none; }
.chip-error { background: var(--grey-bg); color: var(--grey); }

.feed {
  background: #0f172a;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  padding: 0.6rem 0.9rem;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.feed-line { padding: 0.05rem 0; }
.feed-time { color: #64748b; margin-right: 0.6rem; }
.feed-label { font-weight: 700; }
.feed-reason { color: #94a3b8; }
.feed-details { color: #64748b; }

.feed-line.is-green .feed-label { color: #4ade80; }
.feed-line.is-yellow .feed-label { color: #fbbf24; }
.feed-line.is-red .feed-label { color: #f87171; }
.feed-line.is-grey .feed-label { color: #94a3b8; }

.found-banner {
  background: var(--green-bg);
  border: 2px solid var(--green);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.8rem;
}

.found-item {
  color: var(--green);
  font-weight: 700;
  font-size: 0.95rem;
}

.results-actions { display: flex; gap: 0.5rem; }

#watch-section.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
  padding: 1rem 1.25rem 2rem;
  margin: 0;
  max-width: none;
  width: 100%;
}

#watch-section.is-fullscreen .feed { max-height: 42vh; }

#watch-section:fullscreen {
  background: var(--bg);
  overflow-y: auto;
  padding: 1rem 1.25rem 2rem;
}

#watch-section:fullscreen .feed { max-height: 42vh; }
