:root {
  --bg: #11100e;
  --panel: #1d1a17;
  --panel-2: #28231f;
  --text: #f5efe7;
  --muted: #b7aa9d;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #e2b36a;
  --accent-dark: #7a4c14;
  --bubble: #f3c978;
  --bubble-text: #1d1306;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top left, #33271c 0, var(--bg) 34rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 4.7rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
}

h2 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.55rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.screen {
  width: 100%;
}

.hidden {
  display: none !important;
}

.scanner-screen {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 150px);
}

.scanner-card {
  width: min(720px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  box-shadow: var(--shadow);
  padding: 16px;
}

.camera-wrap {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  border-radius: 22px;
  background: #050505;
  border: 1px solid var(--line);
}

video,
#artworkImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
}

.camera-placeholder strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1.1rem;
}

.scan-frame {
  position: absolute;
  inset: 9% 12%;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 18px;
  pointer-events: none;
}

.scan-frame span {
  position: absolute;
  width: 34px;
  height: 34px;
  border-color: var(--accent);
  border-style: solid;
}

.scan-frame span:nth-child(1) { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 14px 0 0 0; }
.scan-frame span:nth-child(2) { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-radius: 0 14px 0 0; }
.scan-frame span:nth-child(3) { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-radius: 0 0 0 14px; }
.scan-frame span:nth-child(4) { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 14px 0; }

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.upload-button {
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
}

.primary-button {
  color: #1d1306;
  background: var(--accent);
}

.secondary-button,
.ghost-button,
.upload-button {
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border-color: var(--line);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.upload-button input {
  display: none;
}

.text-button {
  display: inline-flex;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 8px 4px 2px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.scan-status {
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
}

.scan-status.success {
  color: #f7ead1;
  background: rgba(226, 179, 106, 0.18);
}

.scan-status.error {
  color: #ffd8d8;
  background: rgba(255, 86, 86, 0.14);
}

.artwork-info {
  margin: 4px 0 18px;
}

.artwork-info p:last-child {
  max-width: 720px;
  color: var(--muted);
}

.category-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 16, 14, 0.82);
  backdrop-filter: blur(18px);
}

.category-tab {
  flex: 1;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  padding: 13px 10px;
  font-weight: 900;
}

.category-tab.active {
  color: #1d1306;
  background: var(--accent);
}

.viewer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: start;
  gap: 18px;
}

.painting-stage {
  position: relative;
  overflow: hidden;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080706;
  box-shadow: var(--shadow);
}

#artworkImage {
  height: auto;
  object-fit: contain;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  color: var(--bubble-text);
  background: var(--bubble);
  box-shadow: 0 12px 30px rgba(0,0,0,0.34), 0 0 0 9px rgba(226,179,106,0.18);
  font-weight: 950;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot.active {
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: 0 16px 44px rgba(0,0,0,0.42), 0 0 0 13px rgba(226,179,106,0.25);
  outline: none;
}

.hotspot::after {
  content: attr(data-title);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 220px;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(17, 16, 14, 0.92);
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
  font-size: 0.82rem;
  line-height: 1.2;
  font-weight: 800;
  transition: opacity 160ms ease;
}

.hotspot:hover::after,
.hotspot:focus-visible::after {
  opacity: 1;
}

.story-panel {
  position: sticky;
  top: 76px;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.035));
  box-shadow: var(--shadow);
  padding: 22px;
}

.story-panel p {
  color: var(--muted);
  line-height: 1.55;
}

#storyText {
  color: var(--text);
  font-size: 1.05rem;
}

.source-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}

.coordinate-readout {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(0,0,0,0.72);
  font-size: 0.82rem;
  font-weight: 800;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .story-panel {
    position: relative;
    top: auto;
  }

  .category-tabs {
    border-radius: 22px;
  }

  .category-tab {
    padding: 12px 8px;
  }
}

@media (max-width: 520px) {
  .topbar {
    flex-direction: column;
  }

  .scanner-actions > * {
    width: 100%;
  }

  .hotspot {
    width: 36px;
    height: 36px;
  }
}

.debug-log {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 14px;
  color: #d9d0c5;
  background: rgba(0,0,0,0.34);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  line-height: 1.35;
}

.debug-log:empty {
  display: none;
}
