:root {
  color-scheme: dark;
  --bg: #070a10;
  --bg-soft: #0c111b;
  --panel: rgba(17, 24, 39, 0.78);
  --panel-strong: rgba(20, 29, 43, 0.92);
  --field: rgba(255, 255, 255, 0.055);
  --field-strong: rgba(255, 255, 255, 0.085);
  --line: rgba(215, 185, 138, 0.18);
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #f7f3ec;
  --muted: #9c9184;
  --muted-2: #756d65;
  --accent: #d7b98a;
  --accent-strong: #a16648;
  --danger: #ff7777;
  --danger-bg: rgba(255, 119, 119, 0.13);
  --ok: #d7b98a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(215, 185, 138, 0.16), transparent 34rem),
    radial-gradient(circle at 92% 12%, rgba(161, 102, 72, 0.12), transparent 28rem),
    linear-gradient(180deg, #070a10 0%, #080b12 46%, #05070b 100%);
  color: var(--text);
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition:
    transform 0.14s ease,
    opacity 0.14s ease,
    background 0.14s ease,
    border-color 0.14s ease;
}

button:active {
  transform: scale(0.98);
  opacity: 0.92;
}

.hidden {
  display: none !important;
}

#admin-panel {
  min-height: 100vh;
  padding-bottom: calc(28px + var(--safe-bottom));
}

.app {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 16px;
}

/* Login */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}

.login-brand {
  width: min(100%, 360px);
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-bottom: 16px;
}

.login-brand__mark,
.admin-topbar__mark {
  display: block;
  width: 50px;
  height: 50px;
  border: 1px solid rgba(215, 185, 138, 0.38);
  border-radius: 15px;
  object-fit: cover;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

.login-brand__name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.login-brand__subtitle {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-input,
.text-input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  outline: none;
  padding: 13px 14px;
  font-size: 15px;
  line-height: 1.35;
}

.login-input {
  width: min(100%, 360px);
}

.login-input::placeholder,
.text-input::placeholder,
textarea::placeholder {
  color: rgba(247, 243, 236, 0.42);
}

.login-input:focus,
.text-input:focus,
select:focus,
textarea:focus,
.moment-fields input:focus {
  border-color: rgba(215, 185, 138, 0.55);
  background: var(--field-strong);
  box-shadow: 0 0 0 4px rgba(215, 185, 138, 0.08);
}

.login-btn,
.secondary-btn,
.delete-btn,
.action-bar__save,
.action-bar__reset {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  padding: 13px 18px;
  font-size: 16px;
  font-weight: 800;
}

.login-btn {
  width: min(100%, 360px);
  background: linear-gradient(135deg, #d9bc8d 0%, #a16648 100%);
  color: #140e0b;
}

.login-btn--secondary,
.secondary-btn {
  background: rgba(255, 255, 255, 0.075) !important;
  color: var(--accent);
  border: 1px solid var(--line);
}

.login-error {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 14px;
}

/* Header and tabs */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-left, 0px)) 12px;
  background: rgba(7, 10, 16, 0.78);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.admin-topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.admin-topbar__mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  flex: 0 0 auto;
}

.admin-topbar__title,
.admin-topbar__subtitle {
  display: block;
}

.admin-topbar__title {
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.admin-topbar__subtitle {
  margin-top: 1px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.admin-topbar__logout {
  width: auto;
  min-height: 40px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid rgba(255, 119, 119, 0.22);
  border-radius: 999px;
  background: var(--danger-bg);
  color: #ff9a9a;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.tabs-nav {
  position: sticky;
  top: calc(67px + env(safe-area-inset-top, 0px));
  z-index: 90;
  width: min(calc(100% - 32px), 980px);
  display: flex;
  gap: 6px;
  margin: 14px auto 2px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(18px);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1 0 0;
  min-width: 128px;
  margin: 0;
  padding: 11px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.tab-btn[data-tab="tab-contenido"],
.tab-btn[data-tab="tab-diseno"] {
  display: none;
}

.tab-btn.active {
  background: linear-gradient(135deg, #d9bc8d 0%, #9d6247 100%);
  color: #17100d;
  box-shadow: 0 10px 24px rgba(161, 102, 72, 0.22);
}

.tabs-wrapper {
  width: 100%;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Cards and controls */
.group {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.035)),
    var(--panel);
  box-shadow: var(--shadow);
}

.group-title {
  padding: 0 2px 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 13px 2px;
  border-top: 1px solid var(--line-soft);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.22;
}

.group-title + .row,
.row:first-of-type {
  border-top: 0;
}

.row span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.clickable {
  cursor: pointer;
}

.text-input {
  display: block;
  margin-top: 10px;
}

textarea.text-input {
  min-height: 96px;
  resize: vertical;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

select:disabled,
input:read-only {
  color: rgba(247, 243, 236, 0.62);
  opacity: 1;
}

input[type="date"] {
  color-scheme: dark;
}

.secondary-btn,
.delete-btn {
  margin-top: 14px;
}

.delete-btn {
  background: var(--danger-bg);
  color: #ffb1b1;
  border: 1px solid rgba(255, 119, 119, 0.22);
}

.action-bar {
  width: min(100%, 980px);
  display: grid;
  gap: 10px;
  margin: 18px auto 0;
  padding: 0 0 12px;
}

.action-bar__save {
  background: linear-gradient(135deg, #d9bc8d 0%, #9d6247 100%);
  color: #17100d;
  box-shadow: 0 18px 36px rgba(161, 102, 72, 0.24);
}

.action-bar__reset {
  background: var(--danger-bg);
  color: #ffb1b1;
  border: 1px solid rgba(255, 119, 119, 0.22);
}

/* iOS switch */
.switch {
  position: relative;
  width: 50px;
  height: 30px;
  flex: 0 0 auto;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.22s ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 1px;
  top: 1px;
  border-radius: 50%;
  background: #fffaf2;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.22s ease;
}

input:checked + .slider {
  background: linear-gradient(135deg, #d9bc8d 0%, #9d6247 100%);
}

input:checked + .slider::before {
  transform: translateX(20px);
}

/* Moment cards */
.moments-list {
  display: grid;
  gap: 12px;
}

.moment-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.045);
}

.moment-cover {
  position: relative;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(215, 185, 138, 0.35);
  border-radius: 18px;
  background: rgba(215, 185, 138, 0.08);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.moment-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.moment-fields {
  min-width: 0;
}

.moment-fields input[type="text"],
.moment-fields input[type="time"] {
  width: 100%;
  min-height: 42px;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: var(--field);
  color: var(--text);
  outline: none;
  font-size: 15px;
}

.moment-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.moment-delete {
  grid-column: 2;
  justify-self: start;
  width: auto;
  min-height: 34px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--danger-bg);
  color: #ffb1b1;
  font-size: 13px;
  font-weight: 800;
}

/* Legacy color tools / logs kept styled */
.row input[type="color"] {
  width: 46px;
  height: 34px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.row input[type="text"] {
  max-width: 220px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  padding: 9px 10px;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-preview {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.color-hex {
  width: 82px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  text-align: right;
}

.color-popover {
  position: fixed;
  z-index: 9999;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  animation: popIn 0.15s ease;
}

.color-hex-input {
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@keyframes popIn {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

#log-box {
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-line {
  display: block;
  padding: 1px 0;
  color: var(--muted);
}

.log-line.log-error {
  color: #ff9a9a;
}

.log-line.log-warn {
  color: #ffd28e;
}

.log-line.log-info {
  color: #bddfa6;
}

.log-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.log-actions button {
  width: 100%;
  margin: 0;
  background: rgba(255, 255, 255, 0.075) !important;
  color: var(--accent);
}

iframe {
  border-radius: 20px;
  background: var(--bg-soft);
}

@media (min-width: 720px) {
  .app {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }

  .group,
  .action-bar {
    margin: 0;
  }

  #feature-locks-panel,
  .moments-list,
  .action-bar {
    grid-column: span 2;
  }

  .action-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .app {
    padding: 12px;
  }

  .admin-topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .admin-topbar__title {
    font-size: 18px;
  }

  .admin-topbar__logout {
    padding: 9px 12px;
    font-size: 13px;
  }

  .tabs-nav {
    width: calc(100% - 24px);
    margin-top: 12px;
  }

  .tab-btn {
    min-width: 118px;
  }

  .group {
    padding: 13px;
    border-radius: 24px;
  }

  .row {
    font-size: 15px;
    min-height: 54px;
  }

  .text-input,
  select {
    font-size: 15px;
    min-height: 46px;
  }

  .moment-card {
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 10px;
  }

  .moment-cover {
    width: 78px;
    height: 78px;
    border-radius: 16px;
  }

  .moment-delete {
    grid-column: 1 / -1;
  }
}
