*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #fff;
  color: #111;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
}

:root{
  --dot: #b5b5b5;
  --dot-active: #111;
  --dot-hover: #111;
  --line: #e7e7e7;
  --panel-bg: rgba(255,255,255,0.92);
  --serif: 'EB Garamond', 'Noto Serif KR', Georgia, serif;

  /* ===== Layout variables (edit in JS via CSS vars) ===== */
  --topbar-top: 26px;
  --topbar-left: 26px;
  --topbar-right: 26px;
  --topbar-top-mobile: 16px;
  --topbar-left-mobile: 16px;
  --topbar-right-mobile: 16px;
  --topbar-top-xxs: 12px;
  --topbar-left-xxs: 12px;
  --topbar-right-xxs: 12px;

  --brand-size: 18px;
  --nav-size: 15px;
  --brand-size-mobile: 16px;
  --nav-size-mobile: 14px;
  --brand-size-xxs: 15px;
  --nav-size-xxs: 13px;

  --categories-bottom: 26px;
  --categories-bottom-mobile: 16px;

  --detail-padding-top: 100px;
  --detail-padding-x: 40px;
  --detail-padding-bottom: 80px;
  --detail-padding-top-mobile: 60px;
  --detail-padding-x-mobile: 20px;
  --detail-padding-bottom-mobile: 40px;
  --detail-padding-top-xxs: 48px;
  --detail-padding-x-xxs: 16px;
  --detail-padding-bottom-xxs: 32px;

  /* Position tweak for Korean part only */
  --brand-korean-nudge: -0.08em;
  --brand-korean-offset: 0.15em;
}

#landing {
  position: relative;
  width: 100vw;
  height: 100vh;
}

/* Background thumbnail: behind dots, centered on white, with opacity (scattered mode hover) */
.hover-bg-image {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.hover-bg-image.visible {
  opacity: 1;
}
.hover-bg-image .hover-bg-img {
  max-width: 72%;
  max-height: 72%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0.5;
}
#landing canvas {
  position: relative;
  z-index: 2;
}

.topbar{
  position: absolute;
  top: var(--topbar-top);
  left: var(--topbar-left);
  right: var(--topbar-right);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  z-index: 50;
  pointer-events: none;
}

.topbar a, .topbar button { pointer-events: all; }

.brand{
  font-family: 'Noto Serif KR', 'EB Garamond', Georgia, serif;
  font-size: var(--brand-size);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: inherit;
}
/* Adjust 정의재 position only: nudge up/down (vertical-align) or spacing (margin-left) */
.brand-korean {
  display: inline-block;
  vertical-align: var(--brand-korean-nudge);
  margin-left: var(--brand-korean-offset);
}

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

.nav a{
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--nav-size);
  text-decoration: none;
  color: #333;
}
.nav a:hover{ text-decoration: underline; }

.nav button{
  border: 1px solid #ddd;
  background: #fff;
  color: #222;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.nav button:hover{ border-color: #111; }

canvas{ width: 100%; height: 100%; display:block; }

.landing-categories {
  position: absolute;
  bottom: var(--categories-bottom);
  z-index: 50;
  pointer-events: all;
}
.landing-categories-left { left: var(--topbar-left); text-align: left; }
.landing-categories-right { right: var(--topbar-right); text-align: right; }

#categories-left a,
#categories-fun a {
  display: block;
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: #6b6b6b;
  line-height: 1.7;
  text-decoration: none;
  transition: color 0.2s;
}
#categories-left a:hover,
#categories-left a.active,
#categories-fun a:hover,
#categories-fun a.active {
  color: #111;
  text-decoration: underline;
}
#categories-left a.hovered,
#categories-fun a.hovered {
  color: #111;
  text-decoration: underline;
}

.tooltip{
  position: fixed;
  z-index: 60;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  background: #111;
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s ease;
  min-width: 120px;
  box-sizing: border-box;
}
.tooltip .tooltip-title {
  font-weight: 500;
  letter-spacing: 0.02em;
}
.tooltip.visible{ opacity: 1; }

.overlay{
  position: absolute;
  inset: 0;
  z-index: 70;
  background: rgba(255,255,255,0.84);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.overlay.visible{
  opacity: 1;
  pointer-events: all;
}

.panel{
  position: absolute;
  left: 26px;
  bottom: 24px;
  width: min(520px, calc(100vw - 52px));
  max-height: calc(100vh - 120px);
  overflow: auto;
  background: var(--panel-bg);
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.08);
}

.panel h2{
  margin: 0 0 6px 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
}

.meta{
  font-size: 12px;
  color: #777;
  font-style: italic;
  margin-bottom: 10px;
}

.materials{
  font-size: 12px;
  color: #777;
  font-style: italic;
  margin-bottom: 12px;
}

.desc{
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
  color: #444;
  margin-bottom: 14px;
}

.actions{
  display:flex;
  gap:10px;
  flex-wrap: wrap;
  align-items: center;
}
.actions a{
  font-size: 12px;
  color: #111;
  text-decoration: underline;
}
.actions button{
  margin-left: auto;
  border: none;
  background: #111;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}
.actions button:hover{ background:#333; }

/* ---------- Project detail overlay (same as axis.html) ---------- */
.hidden { display: none !important; }

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #fff;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s 0.35s;
  pointer-events: none;
}
.detail-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transition: opacity 0.35s ease, visibility 0s 0s;
}

.detail-overlay .back-btn {
  position: fixed;
  top: 40px;
  left: 40px;
  z-index: 110;
  background: none;
  border: none;
  font-family: var(--serif);
  font-size: 15px;
  cursor: pointer;
  color: #666;
}
.detail-overlay .back-btn:hover { color: #111; }

.detail-overlay .reset-btn{
  left: 140px;
  color: #666;
}
.detail-overlay .reset-btn:hover{ color: #111; }

.detail-overlay .edit-btn{
  left: 260px;
  padding: 0;
}

.detail-content {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--detail-padding-top) var(--detail-padding-x) var(--detail-padding-bottom);
}
.info-content #info-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 24px;
}
.info-content #info-bio {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  color: #333;
}
.info-content #info-contact {
  margin-top: 32px;
  font-size: 15px;
  line-height: 1.8;
  color: #333;
}
.info-content #info-contact a { text-decoration: underline; }
.detail-content h1 {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  margin-bottom: 8px;
}
.detail-meta {
  font-size: 13px;
  color: #999;
  font-style: italic;
  margin-bottom: 32px;
}
.detail-materials,
.detail-files {
  font-size: 13px;
  color: #999;
  font-style: italic;
  margin-bottom: 10px;
}
.detail-files a { text-decoration: underline; }

.detail-link-thumb-wrap{
  font-style: normal;
  margin: 8px 0 4px;
}
.detail-link-thumb{
  width: 100%;
  max-width: 320px;
  height: auto;
  border-radius: 3px;
  display: block;
}

.detail-link-card{
  display: inline-block;
  font-style: normal;
  text-decoration: none;
  color: inherit;
  margin: 8px 0 12px;
}
.detail-link-card .detail-link-thumb{
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
}
.detail-link-label{
  margin-top: 8px;
  font-size: 12px;
  color: #777;
  text-decoration: underline;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  white-space: nowrap;
}

.detail-audio{
  font-style: normal;
  margin: 10px 0;
}
.detail-audio-label{
  font-size: 12px;
  color: #777;
  font-style: italic;
  margin-bottom: 6px;
}
.detail-audio audio{
  width: 100%;
  display: block;
}
#detail-description {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.7;
  margin-bottom: 40px;
  color: #666;
}
#detail-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 40px;
}
#detail-gallery img {
  width: 100%;
  display: block;
  border-radius: 2px;
  cursor: pointer;
}

.detail-image-wrap{
  position: relative;
  justify-self: start; /* allow width changes to affect grid sizing */
}
.detail-resize-handle{
  display: none;
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: #111;
  cursor: nwse-resize;
  z-index: 2;
}

.content-edit-draggable{
  cursor: move;
  touch-action: none;
  outline: 1px dashed rgba(17,17,17,0.25);
  outline-offset: 6px;
}

body.content-edit-mode #detail-gallery img{
  cursor: move;
}

body.content-edit-mode .detail-image-wrap{
  touch-action: none;
}

body.content-edit-mode .detail-resize-handle{
  display: block;
}
#detail-video-container iframe,
#detail-video-container video {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: 2px;
}

#detail-video-container{
  position: relative;
}

/* In edit mode, prevent embedded controls/iframes from swallowing drag events. */
body.content-edit-mode #detail-video-container iframe,
body.content-edit-mode #detail-video-container video,
body.content-edit-mode #detail-video-container audio{
  pointer-events: none;
}
#detail-video-container audio{
  width: 100%;
  display: block;
  border-radius: 2px;
}
#detail-video-container video {
  max-height: 80vh;
  object-fit: contain;
  background: #000;
}
.video-fallback {
  font-size: 14px;
  color: #666;
  margin: 1em 0;
}
.video-fallback a { text-decoration: underline; }

/* ---------- Edit toolbar ---------- */
body.edit-mode #landing { padding-top: 44px; }

.edit-toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 500;
  font-size: 13px;
}
.toolbar-label { font-weight: 600; letter-spacing: 0.1em; font-size: 11px; }
.toolbar-section { display: flex; align-items: center; gap: 6px; }
.toolbar-actions { gap: 4px; }
.toolbar-separator {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
  margin: 0 8px;
}
.toolbar-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.toolbar-btn:hover { background: rgba(255,255,255,0.2); }
.btn-exit { background: white; color: #111; font-weight: 600; }
.btn-exit:hover { background: #eee; }

#edit-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 400;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: white;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4;
}
#edit-toggle { display: none !important; }
#edit-toggle:hover { opacity: 1; border-color: #111; color: #111; }
body.edit-mode #edit-toggle { display: none; }

/* ---------- Editor panel ---------- */
.editor-panel {
  position: fixed;
  top: 44px;
  right: 0;
  width: 360px;
  height: calc(100vh - 44px);
  background: white;
  border-left: 1px solid #e5e5e5;
  z-index: 450;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.editor-panel.visible { transform: translateX(0); }
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}
.editor-header h3 { font-size: 14px; font-weight: 600; }
.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.close-btn:hover { color: #111; }
.editor-body { padding: 20px; }
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #999;
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  user-select: text;
  pointer-events: auto;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: #2d5be3; }
.field-row { display: flex; gap: 12px; margin-bottom: 16px; }
.field-row .field { flex: 1; margin-bottom: 0; }

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  margin-top: 4px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ddd;
  border-radius: 22px;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: #2d5be3; }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

#image-upload-area {
  border: 2px dashed #ddd;
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  color: #999;
  font-size: 13px;
  position: relative;
}
#image-upload-area:hover { border-color: #2d5be3; background: #f8f9ff; }
#image-upload-area.drag-over { border-color: #2d5be3; background: #eef1ff; }
#image-upload-area input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
#image-preview-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.image-preview {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  background: #f5f5f5;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview .remove-image {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
}
.image-preview:hover .remove-image { opacity: 1; }
.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}
.btn-primary {
  flex: 1;
  padding: 10px 16px;
  background: #111;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #333; }
.btn-danger {
  padding: 10px 16px;
  background: none;
  color: #d94040;
  border: 1px solid #d94040;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.btn-danger:hover { background: #d94040; color: white; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal.visible { opacity: 1; pointer-events: all; }
.modal-content {
  background: white;
  border-radius: 8px;
  padding: 24px;
  width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-wide { width: 560px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.category-item input {
  border: none;
  font-size: 14px;
  padding: 4px 0;
  outline: none;
  flex: 1;
}
.category-item button {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
}
.category-item button:hover { color: #d94040; }
.category-add-row { display: flex; gap: 8px; margin-top: 16px; }
.category-add-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}
.category-add-row .btn-primary { flex: 0; }

/* ---------- Lightbox ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#lightbox.visible { opacity: 1; pointer-events: all; }
#lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  :root{
    --topbar-top: var(--topbar-top-mobile);
    --topbar-left: var(--topbar-left-mobile);
    --topbar-right: var(--topbar-right-mobile);
    --brand-size: var(--brand-size-mobile);
    --nav-size: var(--nav-size-mobile);
    --categories-bottom: var(--categories-bottom-mobile);
    --detail-padding-top: var(--detail-padding-top-mobile);
    --detail-padding-x: var(--detail-padding-x-mobile);
    --detail-padding-bottom: var(--detail-padding-bottom-mobile);
  }
  .topbar {
    top: var(--topbar-top);
    left: var(--topbar-left);
    right: var(--topbar-right);
  }
  .brand {
    font-size: var(--brand-size);
  }
  .nav a {
    font-size: var(--nav-size);
  }
  .landing-categories {
    bottom: var(--categories-bottom);
  }
  .landing-categories-left { left: var(--topbar-left); }
  .landing-categories-right { right: var(--topbar-right); }
  #categories-left a,
  #categories-fun a {
    font-size: 12px;
  }
  .detail-overlay .back-btn {
    left: 16px;
    font-size: 14px;
  }
  .detail-content {
    padding: var(--detail-padding-top) var(--detail-padding-x) var(--detail-padding-bottom);
    max-width: 100%;
  }
  .info-content #info-title {
    font-size: 24px;
  }
  .info-content #info-bio,
  #detail-description {
    font-size: 16px;
  }
  .detail-content h1 {
    font-size: 28px;
  }
  .edit-toolbar {
    padding: 0 12px;
    font-size: 12px;
  }
  .toolbar-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  .editor-panel {
    width: 100%;
    max-width: 100%;
  }
  .editor-body {
    padding: 16px;
  }
  .panel {
    margin: 16px;
    padding: 14px;
  }
  .panel h2 {
    font-size: 22px;
  }
  #edit-toggle {
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  :root{
    --topbar-top: var(--topbar-top-xxs);
    --topbar-left: var(--topbar-left-xxs);
    --topbar-right: var(--topbar-right-xxs);
    --brand-size: var(--brand-size-xxs);
    --nav-size: var(--nav-size-xxs);
    --detail-padding-top: var(--detail-padding-top-xxs);
    --detail-padding-x: var(--detail-padding-x-xxs);
    --detail-padding-bottom: var(--detail-padding-bottom-xxs);
  }
  .topbar {
    top: var(--topbar-top);
    left: var(--topbar-left);
    right: var(--topbar-right);
  }
  .brand {
    font-size: var(--brand-size);
  }
  .nav a {
    font-size: var(--nav-size);
  }
  .nav { gap: 8px; }
  .landing-categories-left { left: var(--topbar-left); }
  .landing-categories-right { right: var(--topbar-right); }
  #categories-left a,
  #categories-fun a {
    font-size: 11px;
  }
  .detail-content {
    padding: var(--detail-padding-top) var(--detail-padding-x) var(--detail-padding-bottom);
  }
  .detail-overlay .back-btn {
    left: 12px;
  }
  .info-content #info-title {
    font-size: 22px;
  }
  .info-content #info-bio,
  #detail-description {
    font-size: 15px;
    line-height: 1.65;
  }
  .detail-content h1 {
    font-size: 24px;
  }
  #detail-gallery {
    gap: 12px;
  }
  .edit-toolbar {
    padding: 0 10px;
  }
  .toolbar-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .editor-header,
  .editor-body {
    padding: 12px 16px;
  }
  .field input[type="text"],
  .field input[type="url"],
  .field textarea {
    font-size: 16px; /* avoids zoom on focus on iOS */
  }
}

