:root {
  --bg: #0b0b0e;
  --panel: #131318;
  --panel-2: #1a1a21;
  --border: rgba(212, 175, 55, 0.25);
  --border-strong: rgba(212, 175, 55, 0.5);
  --gold: #d4af37;
  --gold-light: #f1d77a;
  --text: #f3efe4;
  --muted: #9e978b;
  --danger: #e05d5d;
  --success: #4ebd82;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Noto Sans TC", sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 11, 14, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-badge {
  font-family: "Cinzel", serif;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--gold-light);
  font-size: 1.05rem;
}

.publish-meta {
  font-size: 0.84rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-tabs {
  max-width: 1280px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 500;
  transition: 0.2s ease;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--gold);
}

.tab-btn.active {
  background: rgba(212, 175, 55, 0.16);
  border-color: var(--gold-light);
  color: var(--gold-light);
}

.admin-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 72px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}

.split-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

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

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.list-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold-light);
}

.entity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entity-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: 0.18s ease;
}

.entity-item:hover {
  border-color: var(--gold);
}

.entity-item.active {
  border-color: var(--gold-light);
  background: rgba(212, 175, 55, 0.12);
}

.entity-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.badge-on {
  color: var(--success);
  border-color: rgba(78, 189, 130, 0.45);
}

.badge-off {
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-full {
  grid-column: 1 / -1;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.85rem;
  color: var(--gold-light);
  font-weight: 500;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: #0d0d11;
  color: var(--text);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold-light);
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.65;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.upload-row input[type="text"] {
  flex: 1;
}

.preview-16-9 {
  margin-top: 8px;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: #09090c;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.preview-16-9 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-logo {
  margin-top: 8px;
  padding: 12px;
  max-width: 320px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #09090c;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-logo img {
  max-height: 64px;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.lang-subtabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.lang-pill {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
}

.lang-pill.active {
  border-color: var(--gold-light);
  color: var(--gold-light);
  background: rgba(212, 175, 55, 0.14);
}

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.18s ease;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #111;
  font-weight: 600;
}

.btn-gold:hover {
  filter: brightness(1.06);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--gold-light);
}

.btn-outline:hover {
  background: rgba(212, 175, 55, 0.12);
}

.btn-danger {
  background: rgba(224, 93, 93, 0.14);
  border-color: rgba(224, 93, 93, 0.45);
  color: #ff9c9c;
}

.btn-danger:hover {
  background: rgba(224, 93, 93, 0.25);
}

.actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.loading-box {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  background: #1b1b22;
  border: 1px solid var(--gold-light);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  font-size: 0.9rem;
}

.toast.hidden {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  color: var(--gold-light);
  font-weight: 500;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.preview-modal.hidden {
  display: none;
}

.preview-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
}

.preview-modal-dialog {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-height: 95vh;
}

.preview-modal-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.phone-frame {
  width: 390px;
  max-width: calc(100vw - 48px);
  height: 760px;
  max-height: calc(90vh - 70px);
  border: 3px solid var(--border-strong);
  border-radius: 28px;
  overflow: hidden;
  background: #08080a;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}

.phone-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
