*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  background: #f5f5f5;
  color: #1a1a2e;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body:has(#app) {
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ── Search Panel ─────────────────────────────────── */

#search-panel {
  width: 30%;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  z-index: 1;
}

header {
  padding: 20px 24px 16px;
  background: #1a1a2e;
  border-bottom: none;
}

#back-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 48px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  transition: opacity 0.15s;
}

#back-link-row:hover {
  opacity: 0.7;
}

#header-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

#header-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#search-box {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: flex-end;
}

#question {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  resize: none;
  overflow-y: auto;
  min-height: 40px;
  max-height: 840px;
  field-sizing: content;
}

#question:focus {
  border-color: rgba(255, 255, 255, 0.6);
}

#question::placeholder {
  color: #999;
}

#ask-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 20px;
  height: 40px;
  flex: 0 0 auto;
  background: #fff;
  color: #1a1a2e;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

#ask-btn:hover {
  background: rgba(255, 255, 255, 0.85);
}

#ask-btn:active {
  background: rgba(255, 255, 255, 0.7);
}

#ask-btn:disabled {
  background: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.5);
  cursor: not-allowed;
}

/* ── Results Area ─────────────────────────────────── */

#results {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

#empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 16px;
  color: #8a93a2;
}

#empty-icon {
  width: 48px;
  height: 48px;
  background: #eee;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #999;
  margin-bottom: 14px;
}

#empty-state p {
  font-size: 14px;
  line-height: 1.6;
  max-width: 260px;
}

/* Loading */
#loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 32px 0;
  color: #8a93a2;
  font-size: 14px;
}

#loading-text {
  line-height: 1.55;
  transition: opacity 0.2s;
}

.box-loader {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.box-loader span {
  display: block;
  width: 8px;
  height: 8px;
  background: #1a1a2e;
  animation: box-bounce 0.9s ease-in-out infinite;
}

.box-loader span:nth-child(2) {
  animation-delay: 0.15s;
}

.box-loader span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes box-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Answer */
#answer-section {
  background: #f3f4f8;
  border: 1px solid #d8dbe6;
  border-radius: 2px;
  padding: 18px 20px;
  border-left: 3px solid #1a1a2e;
  box-shadow: 0 1px 3px rgba(26, 26, 46, 0.06);
}

/* Feedback thumbs */
.feedback-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 18px;
  line-height: 1;
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  line-height: 1;
  transition: opacity 0.15s, transform 0.1s;
}

.feedback-btn svg {
  display: block;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

#feedback-up {
  color: #8ac8a0;
}

#feedback-down {
  color: #d69a9a;
}

.feedback-btn:hover {
  opacity: 0.7;
}

.feedback-btn:active {
  transform: scale(0.9);
}

/* Feedback modal */
#feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
}

#feedback-modal {
  background: #fff;
  padding: 32px;
  width: 100%;
  max-width: 460px;
  position: relative;
  border-radius: 2px;
  box-shadow: 0 10px 32px rgba(26, 26, 46, 0.2);
}

#feedback-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

#feedback-close:hover {
  color: #1a1a2e;
}

#feedback-modal h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

#feedback-modal p {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
  margin-bottom: 18px;
}

#feedback-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.feedback-reason {
  padding: 7px 14px;
  background: #fff;
  border: 1.5px solid #1a1a2e;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #1a1a2e;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.feedback-reason:hover {
  background: #1a1a2e;
  color: #fff;
}

.feedback-reason.selected {
  background: #1a1a2e;
  color: #fff;
}

#feedback-comment {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #d8dbe6;
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  outline: none;
  resize: vertical;
  min-height: 72px;
  margin-bottom: 16px;
  transition: border-color 0.15s;
}

#feedback-comment:focus {
  border-color: #1a1a2e;
}

#feedback-comment::placeholder {
  color: #999;
}

#feedback-submit {
  width: 100%;
  height: 40px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

#feedback-submit:hover {
  background: #2d2d44;
}

@media (max-width: 768px) {
  #feedback-modal {
    margin: 16px;
    padding: 24px;
  }
}

#answer-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #1a1a2e;
  margin-bottom: 8px;
}

#answer-text {
  font-size: 15px;
  line-height: 1.7;
  color: #333;
  white-space: pre-wrap;
}

.answer-rich {
  white-space: normal;
}

.answer-rich .answer-para {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.75;
  color: #2d3748;
}

.answer-rich .answer-para:last-child {
  margin-bottom: 0;
}

.answer-rich strong {
  font-weight: 600;
  color: #1a1a2e;
}

.answer-rich .answer-list {
  margin: 0 0 12px;
  padding-left: 22px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.65;
  color: #2d3748;
}

.answer-rich .answer-list:last-child {
  margin-bottom: 0;
}

.answer-rich .answer-list li {
  margin-bottom: 6px;
}

.answer-rich .answer-list li:last-child {
  margin-bottom: 0;
}

.answer-rich ul.answer-list {
  list-style: disc outside;
}

.answer-rich ol.answer-list {
  list-style: decimal outside;
}

.answer-citation {
  display: inline-block;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: #3b4ca3;
  background: #eef1fb;
  border: 1px solid #d4dafa;
  border-radius: 3px;
  padding: 0 6px;
  margin: 0 1px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.6;
  vertical-align: baseline;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button.answer-citation {
  font-family: inherit;
}

.answer-citation:hover {
  background: #dfe5fb;
  border-color: #1a1a2e;
  color: #1a1a2e;
}

.answer-citation-missing {
  color: #8a93a2;
  background: #f3f4f6;
  border-color: #e5e7eb;
  cursor: default;
}

.answer-citation-missing:hover {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #8a93a2;
}

/* Sources */
#sources {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

#sources-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #8a93a2;
  margin-bottom: 10px;
}

#source-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 2px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}

.source-chip:hover {
  border-color: #1a1a2e;
  background: #f8f9ff;
}

.source-chip.active {
  border-color: #1a1a2e;
  background: #f8f9ff;
}

.source-chip-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.source-chip-body {
  flex: 1 1 0;
  min-width: 0;
  display: block;
  overflow: hidden;
}

.source-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}

.source-chip-page {
  font-size: 12px;
  color: #8a93a2;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}

.source-chip-snippet {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Viewer Panel ─────────────────────────────────── */

#viewer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #eee;
  overflow: hidden;
}

#viewer-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8a93a2;
  gap: 12px;
}

#placeholder-icon {
  font-size: 48px;
  opacity: 0.4;
}

#viewer-placeholder p {
  font-size: 14px;
}

#pdf-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  gap: 16px;
  flex-shrink: 0;
}

#viewer-filename {
  font-size: 13px;
  font-weight: 500;
  color: #4a5568;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

#viewer-page-count {
  font-size: 12px;
  color: #8a93a2;
  white-space: nowrap;
  flex-shrink: 0;
}

#canvas-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 24px 24px 48px;
  background: #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ── Zakon text viewer ──────────────────────────────── */

#text-viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

#viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#viewer-full-btn,
#viewer-link {
  font-size: 12px;
  color: #1a1a2e;
  text-decoration: none;
  white-space: nowrap;
  padding: 4px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 2px;
  background: #fff;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

#viewer-full-btn:hover,
#viewer-link:hover {
  border-color: #1a1a2e;
  background: #f8f9ff;
}

#viewer-full-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

#text-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px 56px 72px;
  background: #fff;
  font-size: 15px;
  line-height: 1.7;
  color: #1a1a2e;
  font-family: 'Inter', sans-serif;
}

.zakon-page #search-panel {
  width: 42%;
}

.zakon-page #text-content {
  align-self: stretch;
  width: auto;
  max-width: none;
  box-sizing: border-box;
}

.zakon-page #text-content > * {
  max-width: 750px;
  margin-left: auto;
  margin-right: auto;
}

#text-content > *:first-child {
  margin-top: 0;
}

.law-article {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 28px 0 2px;
  letter-spacing: 0.01em;
  scroll-margin-top: 16px;
}

.law-article-active {
  background: #fff4c8;
  padding: 4px 10px;
  margin-left: -10px;
  border-left: 3px solid #e6b800;
  border-radius: 2px;
}

.law-subtitle {
  font-size: 14px;
  font-style: italic;
  color: #6b7280;
  margin: 0 0 18px;
}

.law-paragraph {
  margin: 12px 0;
  padding-left: 34px;
  position: relative;
  color: #1a1a2e;
}

.law-paragraph-label {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 600;
  color: #1a1a2e;
  min-width: 28px;
}

.law-item {
  margin: 6px 0 6px 56px;
  padding-left: 22px;
  position: relative;
  color: #2d3748;
}

.law-item::before {
  content: "—";
  position: absolute;
  left: 0;
  top: 0;
  color: #8a93a2;
}

.law-numbered {
  margin: 6px 0 6px 56px;
  padding-left: 28px;
  position: relative;
  color: #2d3748;
}

.law-numbered-label {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 500;
  color: #4a5568;
}

.law-plain {
  margin: 10px 0;
}

/* Each rendered PDF page */
.pdf-page {
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  border: 1px solid #d0d0d0;
  background: #fff;
}

.pdf-page canvas {
  display: block;
}

/* Highlight overlay — absolutely positioned over the page canvas */
.pdf-highlight {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Loading placeholder before canvas renders */
.pdf-page-loading {
  width: 595px;
  height: 842px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b0b8c4;
  font-size: 13px;
}

/* ── Home / Landing Page ─────────────────────────── */

body:has(#home) {
  background: #f9f9f9;
}

#bg-grid {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#home {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  padding-bottom: 10vh;
}

#home-content {
  width: 100%;
  max-width: 860px;
}

#home-footer {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
}

#home-footer a {
  color: #888;
  font-size: 13px;
  text-decoration: none;
}

#home-footer a:hover {
  color: #1a1a2e;
}

#hero {
  text-align: center;
  margin-bottom: 54px;
}

#hero-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
}

#hero-logo h1 {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.5px;
}

#hero p {
  font-size: 15px;
  color: #666;
  line-height: 1.5;
}

#search-card {
  background: #fff;
  padding: 48px 40px;
  border-radius: 0;
  position: relative;
}

/* Technical drawing corner marks */
#search-card::before,
#search-card::after,
#search-card-corners::before,
#search-card-corners::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

#search-card::before {
  top: -6px; left: -6px;
  border-top: 1px solid #1a1a2e;
  border-left: 1px solid #1a1a2e;
}
#search-card::after {
  top: -6px; right: -6px;
  border-top: 1px solid #1a1a2e;
  border-right: 1px solid #1a1a2e;
}
#search-card-corners::before {
  bottom: -6px; left: -6px;
  border-bottom: 1px solid #1a1a2e;
  border-left: 1px solid #1a1a2e;
}
#search-card-corners::after {
  bottom: -6px; right: -6px;
  border-bottom: 1px solid #1a1a2e;
  border-right: 1px solid #1a1a2e;
}

#search-card-corners {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#category-section {
  margin-bottom: 20px;
}

#category-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  margin-bottom: 10px;
  transition: color 0.3s;
}

#category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-card {
  padding: 7px 14px;
  background: #fff;
  border: 1.5px solid #1a1a2e;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #1a1a2e;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.category-card:hover {
  background: #1a1a2e;
  color: #fff;
}

.category-card.selected {
  background: #1a1a2e;
  color: #fff;
}

#browse-section {
  margin-bottom: 20px;
}

#browse-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  margin-bottom: 10px;
  transition: color 0.3s;
}

#obcine-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.obcina-card {
  padding: 7px 14px;
  background: #fff;
  border: 1.5px solid #1a1a2e;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #1a1a2e;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.obcina-card:hover {
  background: #1a1a2e;
  color: #fff;
}

.obcina-card.selected {
  border-color: #1a1a2e;
  background: #1a1a2e;
  color: #fff;
}

#hero-search {
  display: flex;
  gap: 8px;
}

#hero-question {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid #1a1a2e;
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

#hero-question:focus {
  border-color: #1a1a2e;
}

#hero-question::placeholder {
  color: #999;
}

#hero-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 24px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

#hero-btn:hover {
  background: #2d2d44;
}

/* ── Back link ───────────────────────────────────── */

#back-link {
  display: inline-flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  transition: color 0.15s;
}

#back-link:hover {
  color: #fff;
}

#back-link svg {
  flex-shrink: 0;
}

/* ── Add občina button ───────────────────────────── */

.obcina-add {
  font-size: 18px;
  font-weight: 400;
  min-width: 36px;
  border-style: dashed !important;
}

/* ── Request Modal ───────────────────────────────── */

#request-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#request-modal {
  background: #fff;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  position: relative;
}

#request-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}

#request-close:hover {
  color: #1a1a2e;
}

#request-modal h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 8px;
}

#request-modal p {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
  margin-bottom: 20px;
}

#request-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#request-form input {
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid #1a1a2e;
  border-radius: 2px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  outline: none;
}

#request-form input::placeholder {
  color: #999;
}

#request-submit {
  height: 40px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 2px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

#request-submit:hover {
  background: #2d2d44;
}

#request-success {
  font-size: 14px;
  color: #1a1a2e;
  padding: 16px 0;
  text-align: center;
}

/* ── Mobile dropdown (hidden on desktop) ─────────── */

#obcine-dropdown-wrap {
  display: none;
}

/* ── Utility ─────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ── Mobile ──────────────────────────────────────── */

@media (max-width: 768px) {

  /* ── Search page mobile ── */

  body:has(#app) {
    height: auto;
    overflow: auto;
  }

  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  #search-panel {
    width: 100%;
    min-width: 0;
    border-right: none;
  }

  #back-link-row {
    margin-bottom: 24px;
  }

  #search-box {
    flex-direction: column;
  }

  #question {
    width: 100%;
  }

  #ask-btn {
    justify-content: center;
  }

  #viewer-panel {
    min-height: 70vh;
  }

  #viewer-placeholder {
    min-height: 200px;
    padding: 32px 16px;
  }

  #canvas-container {
    padding: 16px 8px 32px;
  }

  .pdf-page-loading {
    width: 100%;
    height: 400px;
  }

  /* ── Home page mobile ── */

  body:has(#home) {
    background: #fff;
  }

  #bg-grid {
    display: none;
  }

  #home {
    padding: 24px 16px;
    padding-bottom: 48px;
    align-items: flex-start;
    min-height: auto;
  }

  #home-content {
    max-width: 100%;
  }

  #search-card {
    background: transparent;
    padding: 0;
  }

  /* Hide corner marks on mobile */
  #search-card::before,
  #search-card::after,
  #search-card-corners::before,
  #search-card-corners::after {
    display: none;
  }

  #hero {
    text-align: left;
    margin-bottom: 32px;
  }

  #hero-logo {
    justify-content: flex-start;
  }

  /* Hide grid, show dropdown on mobile */
  #obcine-grid {
    display: none;
  }

  #obcine-dropdown-wrap {
    display: block;
    position: relative;
  }

  #dropdown-trigger {
    width: 100%;
    height: 44px;
    padding: 0 40px 0 14px;
    border: 1.5px solid #1a1a2e;
    border-radius: 2px;
    font-size: 14px;
    font-family: inherit;
    color: #999;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    transition: border-color 0.15s;
  }

  #dropdown-trigger.has-value {
    color: #1a1a2e;
    font-weight: 500;
  }

  #dropdown-trigger svg {
    position: absolute;
    right: 14px;
    flex-shrink: 0;
  }

  #dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #1a1a2e;
    border-radius: 2px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
  }

  .dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font-size: 14px;
    font-family: inherit;
    color: #1a1a2e;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
  }

  .dropdown-item:not(:last-child) {
    border-bottom: 1px solid #eee;
  }

  .dropdown-item:active {
    background: #1a1a2e;
    color: #fff;
  }

  #hero-search {
    flex-direction: column;
    gap: 8px;
  }

  #hero-question {
    width: 100%;
    flex: none;
    height: 44px;
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
  }

  #hero-btn {
    width: 100%;
    justify-content: center;
    flex: none;
  }

  /* Request modal mobile */
  #request-modal {
    margin: 16px;
    padding: 24px;
  }
}

/* ── Sources link on home ──────────────────────────── */

#sources-link-row {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
}

#sources-link-row a {
  color: #666;
  text-decoration: none;
  border-bottom: 1px solid #ccc;
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

#sources-link-row a:hover {
  color: #1a1a2e;
  border-bottom-color: #1a1a2e;
}

/* ── Sources page ──────────────────────────────────── */

body.sources-page {
  background: #f5f5f5;
}

#sources-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

#sources-header {
  margin-bottom: 48px;
}

#sources-back {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #1a1a2e;
  margin-bottom: 36px;
}

#sources-back span {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

#sources-back:hover span {
  text-decoration: underline;
}

#sources-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

#sources-header p {
  font-size: 14px;
  line-height: 1.6;
  color: #666;
  max-width: 640px;
}

#sources-loading {
  font-size: 13px;
  color: #999;
}

.sources-category {
  margin-bottom: 40px;
  border-top: 1px solid #1a1a2e;
  padding-top: 16px;
}

.sources-category-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.sources-category h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.2px;
}

.sources-count {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
}

.sources-description {
  font-size: 13px;
  line-height: 1.5;
  color: #888;
  margin-bottom: 16px;
}

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

.sources-list li {
  padding: 8px 0;
  border-bottom: 1px solid #e8e8e8;
  font-size: 14px;
  line-height: 1.5;
}

.sources-list li:last-child {
  border-bottom: none;
}

.sources-list a {
  color: #1a1a2e;
  text-decoration: none;
  display: block;
  transition: color 0.15s;
}

.sources-list a:hover {
  color: #4a4a6e;
  text-decoration: underline;
}

.sources-list span {
  color: #666;
}

#sources-footer {
  margin-top: 48px;
  text-align: center;
  font-size: 13px;
}

#sources-footer a {
  color: #888;
  text-decoration: none;
}

#sources-footer a:hover {
  color: #1a1a2e;
}

@media (max-width: 640px) {
  #sources-wrap {
    padding: 24px 16px 64px;
  }
  #sources-header {
    margin-bottom: 32px;
  }
  #sources-header h1 {
    font-size: 24px;
  }
}

/* ── Landing Skin ───────────────────────────────────
   Warmer Arhipedia landing-page styling shared by
   sources/admin and older search pages that use this file. */

:root {
  --navy: #111922;
  --navy2: #2D4162;
  --cream: #EAE4D8;
  --sand: #C4A882;
  --white: #F9F7F4;
  --vivid: #1A6E7A;
  --text: #1C2B3A;
  --muted: #6B7A8D;
  --line-warm: #EDE8E0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background:
    radial-gradient(circle at 50% 35%, rgba(234,228,216,0.32) 0%, transparent 34%),
    radial-gradient(circle at 50% 38%, rgba(196,168,130,0.12) 0%, transparent 58%),
    var(--white);
  color: var(--text);
}

#search-panel {
  background: rgba(255,255,255,0.9);
  border-right-color: var(--line-warm);
}

header {
  background: var(--navy);
}

#header-title,
#back-link-row { color: #fff; }

#header-sub,
#empty-state,
#loading,
#sources-label,
#viewer-page-count,
#sources-footer a { color: var(--muted); }

#question,
#hero-question,
#dropdown-trigger,
#request-form input {
  border-color: rgba(28,43,58,0.16);
  border-radius: 999px;
  color: var(--navy);
}

#question:focus,
#hero-question:focus,
#dropdown-trigger:focus,
#request-form input:focus {
  border-color: rgba(26,110,122,0.45);
}

#ask-btn,
#hero-btn,
#request-submit {
  background: var(--navy);
  color: var(--white);
  border-radius: 999px;
}

#ask-btn:hover,
#hero-btn:hover,
#request-submit:hover { background: var(--navy2); }

#answer-section {
  background: rgba(255,255,255,0.82);
  border-color: var(--line-warm);
  border-left-color: var(--vivid);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(28,43,58,0.08);
}

.answer-rich strong,
#answer-label,
.source-chip-name,
#sources-header h1,
.sources-category h2,
#sources-back,
#sources-back span,
#viewer-full-btn,
#viewer-link {
  color: var(--navy);
}

.answer-rich .answer-para,
.answer-rich .answer-list,
#answer-text,
.source-chip-snippet,
.law-paragraph,
.law-plain { color: var(--text); }

.answer-citation,
.source-chip:hover,
.source-chip.active {
  border-color: rgba(26,110,122,0.22);
  background: rgba(26,110,122,0.08);
  color: var(--vivid);
}

.source-chip,
#viewer-full-btn,
#viewer-link {
  border-color: var(--line-warm);
  border-radius: 14px;
  background: rgba(255,255,255,0.82);
}

#viewer-panel,
#canvas-container {
  background: var(--cream);
}

#viewer-toolbar,
#text-viewer,
#text-content {
  background: #fff;
}

body:has(#home),
body.sources-page {
  background:
    radial-gradient(circle at 50% 34%, rgba(234,228,216,0.34) 0%, transparent 34%),
    radial-gradient(circle at 50% 38%, rgba(196,168,130,0.12) 0%, transparent 58%),
    var(--white);
}

#sources-header {
  background: transparent;
  border-bottom: none;
  padding: 0;
}

#hero-logo h1,
#hero p,
#home-footer a,
#sources-header p,
.sources-description { color: var(--muted); }

#hero-logo h1,
#sources-header h1 {
  color: var(--navy);
}

#search-card {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(255,255,255,0.95);
  border-radius: 28px;
  box-shadow:
    0 8px 32px rgba(28,43,58,0.10),
    inset 0 1.5px 0 rgba(255,255,255,0.95);
  backdrop-filter: blur(28px) saturate(1.8);
  -webkit-backdrop-filter: blur(28px) saturate(1.8);
}

#search-card::before,
#search-card::after,
#search-card-corners::before,
#search-card-corners::after {
  display: none;
}

.category-card,
.obcina-card {
  border-color: rgba(107,122,141,0.25);
  border-radius: 999px;
  color: var(--muted);
}

.category-card:hover,
.category-card.selected,
.obcina-card:hover,
.obcina-card.selected {
  border-color: var(--vivid);
  background: rgba(26,110,122,0.08);
  color: var(--vivid);
}

#sources-wrap {
  max-width: 960px;
}

#sources-back {
  gap: 10px;
}

#sources-back svg rect { fill: var(--navy); }

.sources-category {
  background: rgba(255,255,255,0.78);
  border: 1px solid var(--line-warm);
  border-top: 2px solid rgba(26,110,122,0.22);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: 0 8px 28px rgba(28,43,58,0.06);
}

.sources-count {
  color: var(--vivid);
}

.sources-list li {
  border-bottom-color: var(--line-warm);
}

.sources-list a {
  color: var(--navy);
}

.sources-list a:hover,
#sources-footer a:hover,
#home-footer a:hover {
  color: var(--vivid);
}

#request-modal,
#feedback-modal {
  border-radius: 18px;
  box-shadow: 0 18px 48px rgba(28,43,58,0.18);
}

@media (max-width: 768px) {
  body:has(#home) {
    background:
      radial-gradient(circle at 50% 24%, rgba(234,228,216,0.28) 0%, transparent 40%),
      var(--white);
  }
  #search-card {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}
