:root {
  --ink: #0f1c1b;
  --ink-soft: rgba(15, 28, 27, 0.65);
  --muted: rgba(15, 28, 27, 0.52);
  --surface: #ffffff;
  --surface-warm: #fdfbf7;
  --line: rgba(15, 28, 27, 0.09);
  --brand: #3d6b69;
  --brand-hover: #325856;
  --accent: #c9872e;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 8px 32px rgba(15, 28, 27, 0.06);
  --shadow-hover: 0 12px 40px rgba(15, 28, 27, 0.09);
  --font: 'Outfit', system-ui, sans-serif;
  --font-display: 'Source Serif 4', Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  background-color: #e8e6e1;
  background-image:
    radial-gradient(ellipse 90% 50% at 50% -20%, rgba(61, 107, 105, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(201, 135, 46, 0.06), transparent),
    linear-gradient(180deg, #f0ede8 0%, #e8e6e1 100%);
}

.view {
  min-height: 100vh;
}

.view.hidden {
  display: none !important;
}

/* ——— Login ——— */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.02em;
  margin-bottom: 0.35rem;
}

.login-tagline {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.65rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.muted {
  color: var(--ink-soft);
  margin: 0 0 1.25rem;
  line-height: 1.55;
  font-size: 0.95rem;
}

.muted.small {
  font-size: 0.85rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

#login-form label,
.grid-form label {
  display: block;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 1rem;
  color: var(--ink-soft);
}

#login-form input,
.grid-form input:not([type='checkbox']),
.grid-form select {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.7rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
  background: var(--surface-warm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#login-form input:focus,
.grid-form input:focus,
.grid-form select:focus {
  outline: none;
  border-color: rgba(61, 107, 105, 0.45);
  box-shadow: 0 0 0 3px rgba(61, 107, 105, 0.12);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.checks {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}

.checks label {
  font-weight: 500;
  margin-bottom: 0.55rem;
  color: var(--ink-soft);
}

.checks input {
  margin-right: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.68rem 1.25rem;
  border-radius: 11px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.99);
}

.btn.primary {
  background: var(--brand);
  color: #fff;
  width: 100%;
  margin-top: 0.35rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.06) inset, 0 6px 20px rgba(61, 107, 105, 0.25);
}

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

.btn.secondary {
  background: var(--ink);
  color: #f7f4ee;
}

.btn.secondary:hover {
  background: #1a2e2c;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.ghost:hover {
  background: rgba(15, 28, 27, 0.04);
}

.file-btn {
  cursor: pointer;
}

.error {
  color: #a82a22;
  font-size: 0.88rem;
  margin-top: 0.85rem;
}

.error.hidden,
.msg.hidden,
.hidden {
  display: none !important;
}

/* ——— App shell ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(253, 252, 250, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.95rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar-brand-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.28rem;
  color: var(--brand);
  letter-spacing: -0.02em;
}

.topbar-sub {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

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

/* ——— Dashboard: sidebar + main ——— */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}

.dashboard-aside {
  position: sticky;
  top: 4.5rem;
  padding: 1.25rem 1.1rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .dashboard-aside {
    position: static;
  }
}

.aside-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.aside-lead {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 1.1rem;
}

.aside-lead strong {
  color: var(--ink);
  font-weight: 600;
}

.loc-nav {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.loc-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-warm);
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.loc-nav-btn:hover {
  border-color: rgba(61, 107, 105, 0.35);
  background: #fff;
}

.loc-nav-btn.is-active {
  border-color: var(--brand);
  background: rgba(61, 107, 105, 0.08);
  box-shadow: 0 0 0 1px rgba(61, 107, 105, 0.15);
}

.loc-nav-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.loc-nav-badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.panel-local-head .panel-kicker {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
  margin: 0 0 0.35rem;
}

.panel-local-head h2 {
  font-size: clamp(1.35rem, 3vw, 1.65rem);
  margin: 0 0 0.35rem;
}

.local-meta {
  margin-bottom: 1rem !important;
}

.panel-subtitle {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }
}

.global-settings-wrap {
  border: none;
  margin: 0;
  padding: 0;
}

.global-settings-summary {
  list-style: none;
  cursor: pointer;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: background 0.15s ease;
}

.global-settings-summary::-webkit-details-marker {
  display: none;
}

.global-settings-wrap[open] .global-settings-summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: transparent;
  margin-bottom: 0;
}

.global-settings-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
}

.global-settings-hint {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.global-settings-inner {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: -1px;
  border-top: 1px solid var(--line);
}

.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.6rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.highlight-local {
  border-color: rgba(61, 107, 105, 0.22);
  background: linear-gradient(135deg, #ffffff 0%, #f9faf8 100%);
}

.block-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: var(--ink);
}

.block-label select {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: inherit;
  background: var(--surface-warm);
}

.screen-url-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  background: var(--surface-warm);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.screen-url-box code {
  flex: 1;
  min-width: 200px;
  font-size: 0.78rem;
  word-break: break-all;
  color: var(--brand);
  font-family: ui-monospace, 'Cascadia Code', monospace;
}

.institute-card {
  border-left: 4px solid var(--brand);
  background: linear-gradient(90deg, rgba(61, 107, 105, 0.05), transparent 55%);
}

.institute-card h2 {
  color: var(--ink);
}

.institute-lead {
  font-size: 1rem;
  line-height: 1.55;
  margin: 0 0 1rem;
  color: var(--ink);
}

.institute-body {
  font-size: 0.92rem;
  line-height: 1.62;
  margin: 0 0 1rem;
  color: var(--ink-soft);
}

.institute-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1px solid rgba(61, 107, 105, 0.3);
  padding-bottom: 2px;
}

.institute-link:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.loc-summary {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.loc-summary li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.95rem;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-warm);
  font-size: 0.88rem;
}

.loc-summary .slug {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.inline-form input,
.inline-form select {
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  font: inherit;
  background: #fff;
}

.inline-form input[name='slug'] {
  min-width: 180px;
  flex: 1;
}

.inline-form input[name='name'] {
  min-width: 160px;
  flex: 2;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

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

.media-item {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-warm);
}

.media-thumb {
  width: 100px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: #111;
}

.media-thumb.video {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.media-meta {
  min-width: 0;
}

.media-meta strong {
  display: block;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-meta span {
  font-size: 0.78rem;
  color: var(--muted);
}

.media-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.media-actions .row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.btn-tiny {
  padding: 0.38rem 0.58rem;
  font-size: 0.74rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
}

.btn-tiny.danger {
  color: #a82a22;
  border-color: rgba(168, 42, 34, 0.28);
}

.form-actions {
  margin-top: 0.5rem;
}

.logo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 0.5rem 0 1rem;
}

.preview-frame-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(15, 28, 27, 0.12);
  aspect-ratio: 16 / 9;
  background: #0a0f0e;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.preview-frame-wrap iframe {
  width: 200%;
  height: 200%;
  border: 0;
  transform: scale(0.5);
  transform-origin: 0 0;
}

.msg {
  margin-top: 0.75rem;
  font-size: 0.88rem;
}

.msg.ok {
  color: #0d6b4a;
}

.msg.err {
  color: #a82a22;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.9rem 1.25rem;
  background: var(--ink);
  color: #f7f4ee;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  z-index: 100;
  font-weight: 600;
  font-size: 0.9rem;
  animation: toastIn 0.35s ease;
}

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

kbd {
  font-family: ui-monospace, monospace;
  font-size: 0.82em;
  padding: 0.12rem 0.45rem;
  border-radius: 5px;
  background: var(--surface-warm);
  border: 1px solid var(--line);
}

@media (max-width: 720px) {
  .media-item {
    grid-template-columns: 1fr;
  }

  .media-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .row-2 {
    grid-template-columns: 1fr;
  }
}
