/* ─────────────────────────────────────────────────────────────────
   news-data.iort.io — CF lite UI
   Same design language as the server UI for visual consistency.
   ───────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:           #0a0b0e;
  --surface:      #111217;
  --surface-2:    #16181f;
  --surface-3:    #1c1f27;
  --border:       #2a2d36;
  --border-soft:  #1f2229;
  --text:         #e8eaed;
  --text-2:       #b3b9c4;
  --text-3:       #8a90a0;
  --text-4:       #5f6573;

  --accent:       #6366f1;
  --accent-hover: #818cf8;
  --accent-soft:  rgba(99, 102, 241, 0.12);
  --accent-line:  rgba(99, 102, 241, 0.35);
  --success:      #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warn:         #f59e0b;
  --warn-soft:    rgba(245, 158, 11, 0.12);
  --danger:       #ef4444;
  --danger-soft:  rgba(239, 68, 68, 0.12);

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px;
  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.2);
  --shadow-2: 0 4px 12px rgba(0,0,0,.25);
  --shadow-3: 0 12px 32px rgba(0,0,0,.4);
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
::selection { background: var(--accent); color: white; }

/* ── topbar ── */
.topbar {
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-6); height: 56px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: var(--s-2); }
.brand .logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
  border-radius: var(--r-md);
  color: white; font-size: 14px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
}
.brand strong { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.env-pill {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px var(--s-2); border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--accent-hover);
  border: 1px solid var(--accent-line);
}
.meta-bar { color: var(--text-3); font-size: 12px; flex: 1; padding-left: var(--s-4); border-left: 1px solid var(--border-soft); }
.status {
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: var(--s-2);
  font-variant-numeric: tabular-nums;
}
.status.ok { color: var(--success); }
.status.err { color: var(--danger); }
.status::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* ── container ── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--s-6);
  display: grid; gap: var(--s-5);
}

/* ── panels ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-header {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: baseline; gap: var(--s-4);
}
.panel-header h2 {
  margin: 0;
  font-size: 14px; font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.panel-sub {
  color: var(--text-3); font-size: 12px;
}
.panel-sub code {
  background: var(--surface-2); padding: 1px 5px;
  border-radius: 3px; font-family: 'JetBrains Mono', monospace; font-size: 11px;
  border: 1px solid var(--border-soft); color: var(--accent-hover);
}
.panel-body { padding: var(--s-5); }

details.panel summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::after {
  content: '▸';
  margin-left: auto;
  font-size: 11px; color: var(--text-4);
  transition: transform var(--t-fast);
}
details.panel[open] summary::after { transform: rotate(90deg); }
details.panel:not([open]) .panel-header { border-bottom: 0; }

/* ── filter grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-3);
}
.grid label {
  display: flex; flex-direction: column; gap: var(--s-1);
  font-size: 11px; color: var(--text-3); font-weight: 500;
}
.hint-inline { font-size: 10px; color: var(--text-4); font-weight: 400; }

input, select, textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 7px var(--s-3);
  font: inherit; font-size: 13px;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}
input::placeholder { color: var(--text-4); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 12px; line-height: 1.6;
  resize: vertical;
  min-height: 120px;
}

.actions { display: flex; gap: var(--s-2); margin-top: var(--s-4); }
button.primary, button.secondary, button.ghost-small {
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 8px var(--s-4);
  font: inherit; font-weight: 500; font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
}
button.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 2px rgba(99,102,241,.3), inset 0 1px 0 rgba(255,255,255,.1);
}
button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(99,102,241,.4);
  transform: translateY(-1px);
}
button.secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--border);
}
button.secondary:hover:not(:disabled) {
  border-color: var(--text-4);
  background: var(--surface-3);
  color: var(--text);
}
button.ghost-small {
  background: var(--surface-2); color: var(--text-3);
  border-color: var(--border-soft);
  padding: 4px var(--s-3); font-size: 11px;
}
button.ghost-small:hover:not(:disabled) {
  color: var(--accent-hover);
  border-color: var(--accent-line);
}
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── result table ── */
#result {
  overflow: auto;
  max-height: 70vh;
}
.empty {
  padding: var(--s-8) var(--s-6);
  text-align: center; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
}
.empty svg { color: var(--text-4); opacity: .6; }
.error-box {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: #ffd7d7;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  white-space: pre-wrap;
  margin: var(--s-3);
  line-height: 1.5;
}

table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
th, td {
  padding: 9px var(--s-3);
  border-bottom: 1px solid var(--border-soft);
  text-align: left; vertical-align: top;
}
th:first-child, td:first-child { padding-left: var(--s-5); }
th:last-child, td:last-child { padding-right: var(--s-5); }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  font-weight: 600; color: var(--text-3);
  text-transform: uppercase;
  font-size: 10px; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
td {
  max-width: 540px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-2);
}
td:hover { white-space: normal; word-break: break-word; color: var(--text); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr { transition: background var(--t-fast); }
tr:hover td { background: var(--surface-2); }

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--accent-line); }

.view-btn {
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  color: var(--text-3);
  padding: 3px 7px;
  border-radius: var(--r-sm);
  font-size: 13px;
  cursor: pointer;
  opacity: 0.6;
  transition: all var(--t-fast);
}
tr:hover .view-btn { opacity: 1; }
.view-btn:hover {
  opacity: 1 !important;
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-hover);
}

.meta { color: var(--text-3); font-weight: 400; font-size: 12px; margin-left: var(--s-3); font-variant-numeric: tabular-nums; }

/* ── footer ── */
.footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-6) var(--s-8);
  color: var(--text-4); font-size: 11px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-3);
}
.footer code { background: var(--surface-2); padding: 1px 5px; border-radius: 3px; font-family: 'JetBrains Mono', monospace; }

/* ── modal (reader drawer) ── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; }
.modal.hidden { display: none; }
.modal-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--t-slow);
}
.modal-panel {
  position: relative;
  width: min(820px, 100%); height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: var(--s-7) var(--s-8);
  overflow-y: auto;
  box-shadow: var(--shadow-3);
  animation: slideIn var(--t-slow);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.modal-close {
  position: absolute; top: var(--s-4); right: var(--s-4);
  background: var(--surface-2);
  color: var(--text-3); font-size: 18px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
}
.modal-close:hover {
  color: var(--text);
  background: var(--surface-3);
  border-color: var(--text-4);
}
.modal-header {
  margin-bottom: var(--s-5);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--border-soft);
}
.modal-header h2 {
  margin: 0 0 var(--s-3) 0;
  font-size: 24px; line-height: 1.35; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em;
}
.modal-meta {
  display: flex; flex-wrap: wrap; gap: var(--s-2);
  font-size: 11px; margin-bottom: var(--s-3);
}
.modal-meta .chip {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  padding: 3px var(--s-2);
  border-radius: 10px;
  color: var(--text-3); font-weight: 500;
}
.modal-meta .chip.lang {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(16,185,129,.3);
}
.modal-link {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: 12px; color: var(--accent-hover);
  text-decoration: none; font-weight: 500;
  padding: 4px var(--s-2);
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
}
.modal-link:hover { background: var(--accent); color: white; text-decoration: none; }
.modal-description {
  color: var(--text-2); font-style: italic;
  font-size: 15px; line-height: 1.6;
  border-left: 3px solid var(--accent);
  padding: var(--s-2) 0 var(--s-2) var(--s-4);
  margin: var(--s-5) 0;
}
.modal-text {
  font-size: 15px; line-height: 1.75;
  color: var(--text);
  font-family: 'Charter', 'Iowan Old Style', 'Georgia', serif;
  max-width: 68ch;
}
.modal-text p { margin: 0 0 1.2em 0; }
