:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9deea;
  --primary: #0f8b8d;
  --primary-dark: #0a686a;
  --accent: #f2b84b;
  --danger: #b42318;
  --soft: #eef9f8;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 280px),
    var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

button,
input,
select {
  font: inherit;
}

button,
.ghost-link {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  text-decoration: none;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover,
.ghost-link:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

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

.wide {
  width: 100%;
}

.hidden {
  display: none !important;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 200px;
  height: 46px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.brand strong {
  display: block;
  font-size: clamp(18px, 4vw, 26px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.panel h2,
.dashboard-top h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

.panel h2,
.dashboard-top h2 {
  font-size: 22px;
}

.eyebrow {
  display: block;
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px clamp(12px, 3vw, 28px) 34px;
  flex: 1;
}

.workspace,
.admin-grid {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(14px, 3vw, 20px);
}

.panel-header,
.dashboard-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.icon-button {
  min-width: 44px;
  padding: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.reset-button {
  width: auto;
  padding-inline: 14px;
}

.canvas-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f7;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  touch-action: none;
}

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

.controls-stack,
.form-stack {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input,
.field select,
#eventSelect {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

#eventSelect {
  max-width: 190px;
}

.upload-box {
  display: grid;
  gap: 5px;
  place-items: center;
  min-height: 126px;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  cursor: pointer;
  padding: 18px;
  text-align: center;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-box strong {
  color: var(--ink);
}

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

.frame-card {
  display: grid;
  gap: 8px;
  height: auto;
  padding: 8px;
  text-align: left;
}

.frame-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  object-fit: contain;
  background: #f1f5f9;
}

.frame-card span {
  display: block;
  min-height: 36px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.frame-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.16);
}

.status-text {
  min-height: 22px;
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.canvas-hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-panel {
  max-width: 440px;
  margin: 0 auto;
}

.dashboard {
  display: grid;
  gap: 16px;
}

.settings-panel {
  box-shadow: none;
}

.settings-grid {
  display: grid;
  gap: 14px;
}

.frame-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f5f9;
}

.admin-list {
  display: grid;
  gap: 12px;
}

.admin-item {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.admin-item img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  border-radius: 6px;
  background: #f1f5f9;
}

.admin-item strong,
.admin-item span,
.admin-item small {
  display: block;
  overflow-wrap: anywhere;
}

.admin-item span,
.admin-item small {
  color: var(--muted);
}

.row-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.edit-dialog {
  width: min(440px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.44);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px 16px 28px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.site-footer a {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (min-width: 760px) {
  .workspace {
    grid-template-columns: minmax(360px, 1.05fr) minmax(360px, 0.95fr);
    align-items: start;
  }

  .preview-panel {
    position: sticky;
    top: 94px;
  }

  .frame-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-grid {
    grid-template-columns: 360px 1fr;
    align-items: start;
  }

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

  .admin-item {
    grid-template-columns: 82px 1fr auto;
  }

  .admin-item img {
    width: 82px;
    height: 82px;
  }

  .row-actions {
    grid-column: auto;
    grid-template-columns: auto;
    min-width: 132px;
  }
}

@media (min-width: 1080px) {
  .frame-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .site-header {
    align-items: flex-start;
  }

  .brand img {
    width: 40px;
    height: 40px;
  }

  .ghost-link {
    padding-inline: 12px;
  }

  .panel-header {
    display: grid;
  }

  #eventSelect {
    max-width: none;
  }

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