:root {
  --ink: #07111f;
  --ink-soft: #243247;
  --paper: #e7eef8;
  --paper-2: #d5e0ef;
  --line: rgba(7, 17, 31, 0.12);
  --signal: #0f766e;
  --signal-deep: #115e59;
  --glow: #14b8a6;
  --muted: #5b6b80;
  --white: #f7fbff;
  --card: rgba(247, 251, 255, 0.88);
  --shadow: 0 20px 48px rgba(7, 17, 31, 0.12);
  --radius: 16px;
  --font-display: "Newsreader", Georgia, serif;
  --font-body: "Instrument Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1000px 520px at 8% -8%, rgba(20, 184, 166, 0.22), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(37, 99, 235, 0.16), transparent 52%),
    linear-gradient(165deg, #edf3fb 0%, #d9e4f2 48%, #cfdced 100%);
}
.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(7, 17, 31, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(7, 17, 31, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

a { color: inherit; }
img { max-width: 100%; display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  padding-top: max(0.85rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(231, 238, 248, 0.78);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.topnav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.topnav a { text-decoration: none; font-weight: 500; }
.user-chip {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(247, 251, 255, 0.75);
}
.muted { color: var(--muted); font-size: 0.85rem; }

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
  padding-bottom: max(4rem, env(safe-area-inset-bottom));
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--signal-deep);
  margin: 0 0 0.6rem;
}
h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.05;
  margin: 0 0 0.75rem;
  letter-spacing: -0.03em;
}
.lede {
  max-width: 38rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin: 0 0 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--signal);
  color: var(--white);
  border-color: var(--signal-deep);
}
.btn-primary:hover { background: var(--signal-deep); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
}
.btn-block { width: 100%; }
.btn-danger {
  background: transparent;
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.35);
}

.search-panel,
.auth-card,
.admin-card,
.result-item,
.source-pill,
.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.search-panel {
  border-radius: calc(var(--radius) + 4px);
  padding: 1.1rem;
  animation: rise 0.55s ease both;
}
.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}
search-row input[type="search"],
.auth-form input,
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font: inherit;
  color: var(--ink);
  min-height: 48px;
  font-size: 16px; /* iOS zoom engeli */
}
.search-row input[type="search"]:focus,
.auth-form input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: 2px solid rgba(20, 184, 166, 0.28);
  border-color: rgba(15, 118, 110, 0.45);
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.filters fieldset {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 0.85rem 1rem;
}
.filters legend {
  padding: 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.filters label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.25rem 0.75rem 0.25rem 0;
  font-size: 0.95rem;
}

.sources-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 2rem;
}
.source-pill {
  border-radius: 16px;
  padding: 0.9rem 1rem;
  animation: rise 0.6s ease both;
}
.source-pill strong { display: block; font-size: 1.05rem; }
.source-pill span { color: var(--muted); font-size: 0.85rem; }

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.results-head h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 1.8rem;
}
.results-head p { margin: 0; color: var(--muted); }

.result-grid { display: grid; gap: 0.85rem; }
.result-item {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.85rem;
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0.75rem;
  animation: rise 0.45s ease both;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
a.result-link {
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
a.result-link:hover {
  border-color: rgba(15, 118, 110, 0.35);
  transform: translateY(-1px);
}
a.result-link.is-active {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}
.thumb {
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-2);
  width: 120px;
  height: 96px;
  flex-shrink: 0;
}
.thumb img {
  width: 120px !important;
  height: 96px !important;
  max-width: 120px !important;
  object-fit: cover;
  display: block;
}
.thumb-empty {
  background:
    linear-gradient(135deg, rgba(20,184,166,0.16), rgba(37,99,235,0.12)),
    var(--paper-2);
}
.result-body h3 {
  margin: 0.35rem 0 0.3rem;
  font-size: 1.05rem;
  line-height: 1.25;
  font-family: var(--font-display);
  text-decoration: none;
}
.result-body p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-body time { display: block; margin-top: 0.45rem; color: var(--muted); font-size: 0.78rem; }
.meta { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(15, 118, 110, 0.12);
  color: var(--signal-deep);
}
.badge-muted {
  background: rgba(7, 17, 31, 0.06);
  color: var(--muted);
}

.page-auth .shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 140px);
}
.auth-card {
  width: min(420px, 100%);
  border-radius: calc(var(--radius) + 6px);
  padding: 2rem 1.5rem;
  animation: rise 0.5s ease both;
}
.auth-form { display: grid; gap: 0.9rem; }
.auth-form label span,
.form-grid label > span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.86rem;
  font-weight: 600;
}

.flash {
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin: 0 0 1rem;
  border: 1px solid var(--line);
  background: rgba(247, 251, 255, 0.92);
}
.flash-error { border-color: rgba(180,35,24,0.35); color: #8a1a12; background: rgba(180,35,24,0.08); }
.flash-ok { border-color: rgba(15,118,110,0.35); color: var(--signal-deep); background: rgba(20,184,166,0.1); }
.flash-warn { border-color: rgba(180,120,20,0.35); color: #7a5a10; background: rgba(200,160,40,0.12); }

.admin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.admin-head h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin-bottom: 0.2rem; }
.admin-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.admin-nav a {
  text-decoration: none;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(247, 251, 255, 0.75);
  font-weight: 500;
}
.admin-nav a.active {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
}

.table-wrap {
  border-radius: var(--radius);
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
th, td {
  text-align: left;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.95rem;
}
th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(213, 224, 239, 0.7);
}
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.admin-card {
  border-radius: var(--radius);
  padding: 1.25rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}
.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.help {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}
.empty { color: var(--muted); padding: 1rem 0; }

.admin-head-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-list {
  display: grid;
  gap: 0.75rem;
}
.list-card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 1rem;
}
.list-card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.desktop-only { display: block; }
.mobile-only { display: none; }

.site-foot {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  padding-bottom: env(safe-area-inset-bottom);
}

.hero-compact h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 0.5rem; }
.hero-compact .search-panel { margin-top: 0.5rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr);
  gap: 1rem;
  align-items: start;
  margin-top: 1rem;
}
body.page-search:not(.has-open) .workspace {
  grid-template-columns: 1fr;
}
body.page-search:not(.has-open) .workspace-detail {
  display: none;
}
.workspace-list {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  min-height: 0;
  padding: 0;
}
.workspace-detail {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: calc(var(--radius) + 2px);
  min-height: 420px;
  padding: 0;
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.page-num {
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid var(--line);
  font-weight: 600;
}
.page-num.is-active {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
}

.detail-panel { padding: 1.1rem 1.15rem 1.5rem; }
.detail-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.55rem;
}
.detail-panel h2 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.4vw, 1.75rem);
  line-height: 1.2;
  margin: 0.35rem 0 0.4rem;
}
.detail-time { color: var(--muted); font-size: 0.82rem; display: block; margin-bottom: 0.85rem; }
.detail-empty {
  display: grid;
  place-content: center;
  text-align: center;
  min-height: 420px;
  padding: 1.5rem;
  color: var(--ink-soft);
}
.detail-empty .muted { color: var(--muted); }
.inline-ref { color: inherit; text-decoration: underline; text-decoration-style: dotted; }

.page-search.has-open .workspace-list { /* keep */ }

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .workspace-detail {
    position: relative;
    top: 0;
    max-height: none;
  }
  body.has-open .workspace-list { display: none; }
  body:not(.has-open) .workspace-detail { display: none; }
  .result-item { grid-template-columns: 96px 1fr; }
  .thumb { width: 96px; height: 80px; }
  .thumb img {
    width: 96px !important;
    height: 80px !important;
    max-width: 96px !important;
  }
}
.article-view {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem 1.25rem 2rem;
  animation: rise 0.45s ease both;
}
.article-view h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  margin: 0.6rem 0 1rem;
}
.article-view .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.article-view time { color: var(--muted); font-size: 0.85rem; }
.article-hero, .article-gallery figure {
  margin: 0 0 1rem;
  border-radius: 14px;
  overflow: hidden;
  background: var(--paper-2);
}
.article-hero img, .article-gallery img {
  width: 100%;
  height: auto;
  display: block;
}
.article-gallery {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.article-video {
  margin: 0 0 1rem;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
.article-video video { width: 100%; max-height: 70vh; display: block; }
.article-body {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-soft);
}
.article-body p { margin: 0 0 1rem; }
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 0.75rem 0;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .topnav {
    display: none;
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: calc(100% + 0.4rem);
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.75rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(247, 251, 255, 0.97);
    box-shadow: var(--shadow);
  }
  .topbar { position: sticky; }
  body.nav-open .topnav { display: flex; }
  .topnav a,
  .topnav .btn,
  .topnav .user-chip {
    width: 100%;
    justify-content: center;
    text-align: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 1.25rem, 1100px); padding-top: 1.15rem; }
  h1 { font-size: clamp(1.85rem, 8vw, 2.6rem); }
  .lede { font-size: 0.98rem; margin-bottom: 1.1rem; }
  .search-panel { padding: 0.85rem; border-radius: 18px; }
  .search-row { grid-template-columns: 1fr; }
  .search-row .btn { width: 100%; }
  .filters { grid-template-columns: 1fr; gap: 0.65rem; }
  .filters fieldset { padding: 0.75rem; }
  .filters label {
    display: flex;
    width: 100%;
    padding: 0.55rem 0.35rem;
    border-bottom: 1px solid rgba(7, 17, 31, 0.06);
    margin: 0;
    min-height: 44px;
  }
  .filters label:last-child { border-bottom: 0; }
  .sources-strip { grid-template-columns: 1fr 1fr; gap: 0.55rem; }
  .source-pill { padding: 0.75rem; }
  .result-item { grid-template-columns: 1fr; gap: 0.75rem; }
  .thumb, .thumb img { min-height: 160px; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-head { align-items: stretch; }
  .admin-head-actions { width: 100%; }
  .admin-head-actions .btn { flex: 1; }
  .admin-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }
  .admin-nav a {
    text-align: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .desktop-only { display: none !important; }
  .mobile-only { display: grid; }
  table { min-width: 0; }
  .site-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
  .page-auth .shell { min-height: calc(100vh - 120px); align-content: center; }
  .auth-card { padding: 1.5rem 1.15rem; }
}

@media (max-width: 420px) {
  .sources-strip { grid-template-columns: 1fr; }
  .admin-nav { grid-template-columns: 1fr; }
}
