:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --surface-muted: #eef2f8;
  --line: #dbe2ee;
  --line-strong: #c8d2e3;
  --text: #1b2431;
  --text-muted: #637289;
  --primary: #2f6fed;
  --primary-soft: #eaf1ff;
  --success: #1f9d64;
  --danger: #d94a5d;
  --warning: #d18718;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 16px 36px rgba(23, 34, 55, 0.08);
}

html {
  font-size: 15px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Segoe UI", "Malgun Gothic", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  padding: 0.2rem 0.45rem;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--primary);
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.app-brand,
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sidebar-section-label,
.topbar-kicker,
.landing-eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-nav {
  display: grid;
  gap: 0.55rem;
}

.app-nav-link {
  padding: 0.85rem 0.95rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
  transition: 0.18s ease;
}

.app-nav-link:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.app-nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.sidebar-footer-label {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.sidebar-footer-value {
  margin: 0.35rem 0 1rem;
  font-weight: 700;
}

.app-main,
.auth-shell {
  padding: 1.8rem 2rem;
}

.simple-auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-content-narrow {
  width: min(420px, 100%);
}

.app-topbar,
.auth-topbar,
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.app-topbar,
.auth-topbar {
  margin-bottom: 1.5rem;
}

.topbar-title,
.page-header h1,
.landing-card h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.topbar-caption,
.page-header p,
.landing-card p,
.feature-item span,
.signin-note,
.signin-footer,
.text-muted {
  color: var(--text-muted) !important;
}

.app-content,
.auth-content {
  min-width: 0;
}

.status-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.alert {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.alert-success {
  border-color: #c5ead9;
  color: #1b6d48;
  background: #edf9f3;
}

.alert-danger {
  border-color: #f2c9cf;
  color: #9d3040;
  background: #fff3f5;
}

.landing-grid,
.auth-login-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.9fr);
  gap: 1.25rem;
}

.landing-card,
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card {
  width: 100%;
}

.landing-card,
.card-body,
.signin-panel {
  padding: 1.35rem;
}

.auth-card-header {
  margin-bottom: 1.25rem;
}

.auth-card-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.8rem;
  font-weight: 800;
}

.auth-card-header p {
  margin: 0;
  color: var(--text-muted);
}

.feature-list {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.2rem;
}

.feature-item {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.feature-item strong {
  display: block;
  margin-bottom: 0.25rem;
}

.page-header {
  margin-bottom: 1.2rem;
}

.card {
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  font-weight: 700;
}

.table {
  margin-bottom: 0;
  color: var(--text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--line);
}

.table > :not(caption) > * > * {
  padding: 0.95rem 1rem;
  vertical-align: middle;
}

.table thead th {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-label,
.form-check-label {
  font-weight: 600;
}

.form-control,
.form-select {
  min-height: 46px;
  border-color: var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.form-control:focus,
.form-select:focus {
  border-color: #95b5ff;
  box-shadow: 0 0 0 0.2rem rgba(47, 111, 237, 0.12);
}

.form-check-input {
  border-color: var(--line-strong);
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
}

.btn {
  border-radius: 12px;
  padding: 0.72rem 1.1rem;
  font-weight: 700;
}

.btn-sm {
  border-radius: 10px;
  padding: 0.48rem 0.8rem;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
}

.event-template-assignment-list {
  display: grid;
  gap: 1rem;
}

.event-template-assignment-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.event-template-assignment-preview {
  max-height: 180px;
  width: auto;
  object-fit: contain;
}

.preset-image-library-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
}

.preset-image-library-preview-image {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.preset-image-library-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 180px;
  color: var(--text-muted);
  background: var(--surface-soft);
}

.event-template-picker-row {
  display: grid;
  grid-template-columns: minmax(280px, 440px);
  gap: 1rem;
}

.event-template-panel-stack {
  display: grid;
}

.event-template-panel {
  display: none;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.event-template-panel.is-active {
  display: block;
}

.event-template-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.event-template-facts {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.event-template-fact {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.event-template-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 1rem;
  align-items: start;
}

.event-template-preview-stage .preset-slot-box,
.event-template-preview-stage .preset-slot-box:hover {
  cursor: default;
  background: rgba(47, 111, 237, 0.14);
}

.event-template-image-settings {
  display: grid;
  gap: 1rem;
}

.event-template-image-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.event-template-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  background: var(--surface-soft);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: #2459c4;
  background: #2459c4;
}

.btn-outline-primary {
  border-color: #b7cdfc;
  color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #9fbdfa;
}

.btn-outline-secondary {
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-outline-secondary:hover {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-outline-danger {
  border-color: #efb8c0;
  color: var(--danger);
}

.btn-outline-danger:hover {
  background: #fff2f4;
  color: var(--danger);
  border-color: #e89aa6;
}

.badge {
  padding: 0.48rem 0.7rem;
  border-radius: 999px;
  font-weight: 700;
}

.field-validation-error,
.text-danger,
.validation-summary-errors {
  color: var(--danger) !important;
}

.section-stack {
  display: grid;
  gap: 1rem;
}

.form-section {
  display: grid;
  gap: 1rem;
}

.form-section-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.form-section-copy {
  margin: 0;
  color: var(--text-muted);
}

.asset-grid {
  display: grid;
  gap: 1rem;
}

.asset-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.asset-meta {
  display: grid;
  gap: 0.75rem;
}

.asset-label {
  font-size: 1rem;
  font-weight: 700;
}

.asset-copy {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.asset-file-name {
  display: inline-flex;
  width: fit-content;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.asset-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 158px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.asset-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 0.84rem;
  font-weight: 600;
}

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

.info-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.preset-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(420px, 1fr);
  gap: 1rem;
  align-items: start;
}

.preset-preview-panel,
.preset-slot-panel {
  min-width: 0;
}

.preset-preview-toolbar {
  margin-bottom: 0.85rem;
}

.preset-preview-shell {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.preset-preview-stage {
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  user-select: none;
  touch-action: none;
}

.preset-preview-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(47, 111, 237, 0.08), rgba(47, 111, 237, 0.02)),
    repeating-linear-gradient(
      45deg,
      rgba(47, 111, 237, 0.04) 0,
      rgba(47, 111, 237, 0.04) 14px,
      transparent 14px,
      transparent 28px
    );
}

.preset-preview-image {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.preset-preview-image.is-visible {
  display: block;
}

.preset-preview-image-back {
  z-index: 1;
}

.preset-preview-slots-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.preset-preview-image-front {
  z-index: 3;
  pointer-events: none;
}

.preset-slot-box {
  position: absolute;
  display: block;
  padding: 0;
  border: 2px solid rgba(47, 111, 237, 0.65);
  border-radius: 12px;
  background: rgba(47, 111, 237, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  cursor: grab;
}

.preset-slot-box:hover {
  background: rgba(47, 111, 237, 0.18);
}

.preset-slot-box.is-selected {
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px rgba(47, 111, 237, 0.15),
    inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  background: rgba(47, 111, 237, 0.2);
}

.preset-slot-label,
.preset-slot-photo-label {
  position: absolute;
  top: 8px;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(27, 36, 49, 0.78);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.preset-slot-label {
  left: 8px;
}

.preset-slot-photo-label {
  right: 8px;
}

.preset-slot-center-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(27, 36, 49, 0.82);
  font-size: clamp(1rem, 2vw, 2rem);
  font-weight: 800;
  pointer-events: none;
}

.preset-slot-resize-handle {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--primary);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 10px rgba(47, 111, 237, 0.28);
  cursor: nwse-resize;
}

.preset-slot-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

.preset-slot-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
}

.preset-slot-row-selected > * {
  background: var(--primary-soft) !important;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .sidebar-footer {
    width: 100%;
  }

  .landing-grid,
  .auth-login-grid,
  .info-grid,
  .asset-card,
  .preset-editor-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-main,
  .auth-shell {
    padding: 1rem;
  }

  .app-topbar,
  .auth-topbar,
  .page-header {
    flex-direction: column;
  }

  .topbar-title,
  .page-header h1,
  .landing-card h1 {
    font-size: 1.6rem;
  }
}
