@font-face {
  font-family: 'Jost';
  src: url('Jost-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
}

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

body {
  background-color: #ffffff; 
  font-family: 'Jost', sans-serif; 
  overflow: hidden; 
  user-select: none;
}

body > canvas {
  position: fixed; 
  top: 0;
  left: 0;
  z-index: 1;
  display: block;
}

/* ⭐ 플래시 효과 부드러운 페이드아웃 적용 */
#flash-effect {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background-color: white;
  z-index: 20000;
  opacity: 0;
  pointer-events: none;
}

/* ⭐ 연결 과부하 텍스트 - 작게 유지 */
#overload-text {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  font-family: 'Jost', sans-serif;
  font-size: 36px; 
  font-weight: 900;
  color: #f03e3e;
  text-align: center;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-shadow: 0px 4px 15px rgba(240, 62, 62, 0.4);
}
#overload-text.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.node-group {
  position: absolute;
  cursor: grab;
  z-index: 2;
  width: 160px; 
  height: 160px;
  will-change: transform;
}
.node-group:active { cursor: grabbing; }

.black-marker {
  position: absolute;
  width: 12px; height: 12px;
  background-color: #1a1a1a;
  top: 0; left: 0;
  margin-top: -6px; margin-left: -6px;
  z-index: 1;
  transition: background-color 0.2s ease;
}

.node-labels {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%); 
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%;
  z-index: 2; 
  pointer-events: none;
}

.label-main { 
  font-size: 18px; font-weight: 700; letter-spacing: -0.5px; 
  color: #1a1a1a; transition: color 0.2s ease; 
}
.label-sub { 
  font-size: 8px; font-weight: 400; letter-spacing: 1px; 
  color: #666; text-transform: uppercase; transition: color 0.2s ease; 
}

.node-group:hover .black-marker {
  background-color: #f03e3e !important;
}
.node-group:hover .label-main,
.node-group:hover .label-sub {
  color: #8b0000 !important;
}

.top-controls {
  position: fixed;
  top: 40px; right: 50px;
  z-index: 990;
  display: flex;
  align-items: center;
  gap: 16px;
}

.text-link-btn {
  font-size: 20px; 
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #1a1a1a;
  cursor: pointer;
  transition: color 0.2s, border-bottom 0.2s;
  border-bottom: 2px solid transparent;
  padding-bottom: 2px;
}
.text-link-btn:hover {
  color: #f03e3e;
  border-bottom: 2px solid #f03e3e;
}

.text-link-btn.reset-symbol-btn {
  font-size: 26px; 
  line-height: 1;
  font-weight: 900;
  color: #2b2b2b;
  transform: translateY(-2px);
}
.text-link-btn.reset-symbol-btn:hover {
  color: #f03e3e;
  border-bottom: 2px solid transparent;
}

.divider {
  font-size: 20px;
  font-weight: 400;
  color: #888;
}

.control-panel {
  position: fixed; bottom: 40px; left: 50%;
  transform: translateX(-50%); display: flex;
  background-color: #f4f4f5; border: 1px solid #1a1a1a;
  box-shadow: 4px 4px 0px rgba(0,0,0,0.15); z-index: 990; 
}

.control-section {
  padding: 14px 20px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-right: 1px solid #1a1a1a;
}
.control-section:last-child { border-right: none; }
.status-section { min-width: 240px; background-color: #ededf0; }

.control-section .label {
  font-size: 9px; font-weight: 700; color: #666;
  letter-spacing: 1px; margin-bottom: 6px; text-transform: uppercase;
}
#status-text { font-size: 11px; font-weight: bold; color: #1a1a1a; letter-spacing: 0.5px; margin-bottom: 6px; }

.button-group { display: flex; align-items: center; height: 32px; }
.button-group button {
  background-color: #444; color: #fff; border: none;
  font-weight: 700; font-size: 16px; cursor: pointer;
  width: 44px; height: 100%; transition: background-color 0.2s;
}
.button-group button:hover { background-color: #f03e3e; }
.button-group button:disabled { background-color: #e0e0e0; color: #a0a0a0; cursor: not-allowed; }

.count-display {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 100%; font-weight: 700; font-size: 14px;
  background-color: #fff; border-top: 1px solid #1a1a1a; border-bottom: 1px solid #1a1a1a;
}

#archive-modal {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: rgba(244, 244, 245, 0.98); 
  z-index: 10000;
  display: flex; flex-direction: column; backdrop-filter: blur(8px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#archive-modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 25px 50px; border-bottom: 2px solid #555;
}

/* ⭐ 타이틀 폰트 웨이트 900(Extrabold) 유지 */
.modal-header h2 { 
  font-family: 'Jost', sans-serif;
  font-size: 36px; 
  font-weight: 900; 
  letter-spacing: 2px; 
  color: #1a1a1a; 
} 

#btn-close-archive, #btn-close-spec, #btn-close-weave {
  background: none; border: none; cursor: pointer; color: #000000 !important; 
}

.archive-grid-container { flex: 1; padding: 40px 50px; overflow-y: auto; }

.archive-masonry {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); 
  grid-auto-rows: 6px; gap: 15px; align-content: flex-start;
}

#empty-msg { font-size: 14px; color: #888; font-weight: bold; grid-column: 1 / -1; text-align: center; margin-top: 50px; }

.archive-item {
  position: relative; background-color: #bdbdc1; cursor: pointer;
  border: 1px solid #333; box-shadow: 3px 3px 0px rgba(0,0,0,0.5);
  overflow: hidden; transition: transform 0.2s ease;
}
.archive-item:hover { transform: translateY(-3px); border-color: #666; }

.archive-item.m-small  { grid-column: span 1; grid-row: span 10; } 
.archive-item.m-medium { grid-column: span 2; grid-row: span 14; } 
.archive-item.m-wide   { grid-column: span 3; grid-row: span 12; } 
.archive-item.m-tall   { grid-column: span 2; grid-row: span 20; } 
.archive-item.m-big    { grid-column: span 3; grid-row: span 20; } 

.card-inner { width: 100%; height: 100%; }
.card-front { position: relative; width: 100%; height: 100%; }
.card-front img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }

.card-ratio-badge {
  position: absolute; bottom: 4px; left: 4px; background-color: #333;
  color: #fff; font-family: 'Jost', monospace; font-size: 10px; padding: 2px 5px;
}

.btn-delete-archive {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px;
  background-color: #fff; border: 1px solid #1a1a1a; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10;
}
.btn-delete-archive svg { width: 9px; height: 9px; fill: #1a1a1a; }
.btn-delete-archive:hover { background-color: #f03e3e; }
.btn-delete-archive:hover svg { fill: #fff; }

#spec-modal {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: rgba(244, 244, 245, 0.98); z-index: 10005;
  display: flex; flex-direction: column; backdrop-filter: blur(10px);
}
#spec-modal.hidden { display: none !important; }

#btn-close-spec { color: #1a1a1a !important; }
#spec-modal .modal-header h2 { color: #1a1a1a !important; }
#spec-modal .modal-header { border-bottom: 2px solid #1a1a1a; }

.spec-content { flex: 1; padding: 40px 50px; overflow-y: auto; display: flex; flex-direction: column; gap: 40px; }

.spec-interactive-bar {
  display: flex; flex-direction: column; gap: 15px;
  background-color: #fff; border: 1px solid #1a1a1a; padding: 20px 25px;
  box-shadow: 4px 4px 0px #1a1a1a;
}
.spec-guide-text {
  font-family: 'Jost', monospace; font-size: 12px; font-weight: bold; color: #666; letter-spacing: 0.5px;
}

.spec-badges-container {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  padding: 100px 0; 
}

.spec-badge-wrapper {
  position: relative; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

.spec-badge-wrapper .type-badge {
  display: block; width: 100%; text-align: center; font-family: 'Jost', monospace; font-size: 16px; font-weight: bold;
  padding: 12px 10px; border: 1px solid #1a1a1a; color: #fff; z-index: 10;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.15);
}
.spec-badge-wrapper:hover .type-badge { transform: translateY(0px) scale(1.02); box-shadow: 4px 4px 0px rgba(0,0,0,0.2); }

.spec-badge-wrapper[data-spec-type="straight"] .type-badge { background-color: #ffffff; color: #1a1a1a; }
.spec-badge-wrapper[data-spec-type="curve"] .type-badge    { background-color: #b3b3b3; color: #1a1a1a; } 
.spec-badge-wrapper[data-spec-type="wave"] .type-badge     { background-color: #4d4d4d; color: #fff; }
.spec-badge-wrapper[data-spec-type="erratic"] .type-badge  { background-color: #000000; color: #fff; }

.spec-desc-tooltip {
  position: absolute; 
  top: calc(100% + 12px); 
  left: 50%; transform: translateX(-50%) translateY(8px); 
  width: 240px; 
  background-color: rgba(235, 236, 240, 0.85); 
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  padding: 14px 16px; 
  box-shadow: 0px 8px 20px rgba(0, 0, 0, 0.08);
  z-index: 2000; opacity: 0; pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.spec-badge-wrapper:hover .spec-desc-tooltip { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.spec-desc-tooltip p { font-size: 13px; color: #24262d; line-height: 1.6; text-align: left; }

.spec-line-tooltip {
  position: absolute; 
  bottom: calc(100% + 12px); 
  left: 50%; transform: translateX(-50%) translateY(-8px); 
  width: 240px; height: 67px;
  background-color: rgba(235, 236, 240, 0.85); 
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  padding: 0; margin: 0;
  box-shadow: 0px -8px 20px rgba(0, 0, 0, 0.08);
  z-index: 2000; opacity: 0; pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.spec-badge-wrapper:hover .spec-line-tooltip { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }

.tooltip-preview-box {
  width: 238px; height: 65px; 
  background-color: rgba(255, 255, 255, 0.5); 
  border: none; margin: 0; padding: 0;
  display: block; overflow: hidden;
}
.tooltip-preview-box canvas {
  position: static !important;
  display: block !important; margin: 0 !important; padding: 0 !important; z-index: auto !important;
}

.spec-live-status { display: flex; flex-direction: column; gap: 15px; border-top: 2px dashed #1a1a1a; padding-top: 30px; }
.live-status-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.live-status-header h3 { font-size: 18px; letter-spacing: 0.5px; color: #1a1a1a; }

.action-text-btn {
  background: none; border: none; font-family: 'Jost', monospace; font-size: 14px;
  font-weight: bold; color: #f03e3e; cursor: pointer; border-bottom: 1px solid transparent;
  padding-bottom: 2px; transition: border-color 0.2s;
}
.action-text-btn:hover { border-color: #f03e3e; }

.live-list { display: flex; flex-direction: column; gap: 10px; }
.live-item {
  background-color: #ededf0; border: 1px solid #ccc; padding: 12px 20px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'Jost', monospace; font-size: 14px; color: #333;
}
.no-live { font-family: 'Jost', monospace; font-size: 14px; color: #888; text-align: center; padding: 20px; }

#lightbox-popup {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: #000; z-index: 11000;
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
#lightbox-popup.hidden { display: none !important; }

.lightbox-content {
  position: relative; background-color: #111; width: 92%; max-width: 1150px;
  height: 82vh; border: 2px solid #333; box-shadow: 10px 10px 0px rgba(0,0,0,0.3);
  display: flex; flex-direction: column;
}

#btn-close-lightbox {
  position: absolute; top: -18px; right: -18px; width: 36px; height: 36px;
  background-color: #f03e3e; color: #fff; border: 2px solid #000; border-radius: 50%;
  font-size: 16px; font-weight: bold; cursor: pointer; z-index: 100;
}

.lightbox-body { display: flex; width: 100%; height: 100%; }
.lightbox-view {
  flex: 7; background-color: #000; 
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-right: 1px solid #333; position: relative;
}

img:not([src]) { visibility: hidden !important; opacity: 0 !important; }

.lightbox-layer {
  position: absolute; width: 92%; height: 92%; object-fit: contain; 
  transition: filter 0.25s ease, opacity 0.2s ease; image-rendering: -webkit-optimize-contrast;
}
#lightbox-img-isolated { z-index: 5; mix-blend-mode: screen; pointer-events: none; }

.lightbox-info { flex: 3; padding: 35px 25px; display: flex; flex-direction: column; background-color: #000; color: #fff; }
.lightbox-info h3 { font-size: 18px; font-weight: 800; color: #fff; margin-bottom: 25px; border-bottom: 2px solid #333; padding-bottom: 10px; }
.popup-meta-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; font-family: 'Jost', monospace; font-size: 14px; color: #bbb;}
.popup-meta-row strong { color: #888; font-size: 12px; }
.popup-meta-row span { color: #f03e3e; font-weight: bold; font-size: 16px; }
.popup-meta-desc { font-size: 13px; color: #666; line-height: 1.5; border-top: 1px dashed #333; padding-top: 12px; margin-bottom: 20px; }

.popup-filter-wrapper {
  margin-top: auto; border-top: 2px solid #333; padding-top: 20px; display: flex; flex-direction: column; gap: 10px;
}
.popup-filter-label { font-size: 12px; font-weight: 800; letter-spacing: 0.5px; color: #666; }
.popup-filter-buttons { display: flex; flex-wrap: wrap; gap: 6px; background-color: #111; border: 1px solid #333; padding: 4px; }
.pop-filter-btn {
  flex: 1; min-width: 70px; background: none; border: none; font-family: 'Jost', monospace; font-size: 12px; font-weight: bold;
  padding: 6px 4px; cursor: pointer; color: #aaa; text-align: center; transition: background-color 0.15s, color 0.15s;
}
.pop-filter-btn:hover { background-color: rgba(255,255,255,0.1); color: #fff; }
.pop-filter-btn.active { background-color: #f03e3e; color: #fff; }

#weave-modal {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: #ffffff; 
  z-index: 12000; display: flex; flex-direction: column;
}
#weave-modal.hidden { display: none !important; }

#btn-close-weave { color: #1a1a1a !important; }
#weave-modal .modal-header h2 { color: #1a1a1a !important; }
#weave-modal .modal-header { border-bottom: 2px solid #1a1a1a; }

.weave-layout { display: flex; flex-direction: column; flex: 1; height: calc(100vh - 80px); }

#weave-board {
  flex: 1; background-color: #ffffff; 
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; cursor: grab;
}
#weave-board:active { cursor: grabbing; }

#weave-canvas-layer { position: absolute; width: 100%; height: 100%; transform-origin: 0 0; transition: transform 0.05s linear; }

#weave-tray {
  height: 250px; background-color: #f4f4f5; 
  display: flex; align-items: center; gap: 20px; padding: 0 40px; overflow-x: auto; border-top: 2px solid #1a1a1a;
}

.weave-placeholder {
  color: #555; font-family: 'Jost', monospace; font-size: 16px; font-weight: bold; letter-spacing: 1px;
  pointer-events: none; text-align: center; line-height: 1.6; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}
.weave-tray-empty {
  color: #666; font-family: 'Jost', monospace; font-size: 14px; font-style: italic; width: 100%; text-align: center; margin: 0; pointer-events: none;
}

/* ⭐ 플렉스 수축 해제 유지 (아카이브 리스트 숨김 오류 픽스) */
.weave-tray-item {
  height: 200px; cursor: grab; background-color: transparent; border: none;
  flex-shrink: 0;
  filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.25)); object-fit: contain;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.weave-tray-item:hover { transform: translateY(-6px); filter: drop-shadow(0px 6px 10px rgba(0,0,0,0.3)); }
.weave-tray-item:active { cursor: grabbing; }

.weave-board-item-wrapper {
  position: absolute;
  width: 180px; height: max-content;
  transform: translate(-50%, -50%) scale(var(--item-scale, 1)) rotate(var(--item-rotate, 0deg)); 
  transform-origin: 50% 50%;
  transition: left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), top 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.15s ease, filter 0.2s ease;
  filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.15));
}
.weave-board-item-wrapper:hover { filter: drop-shadow(2px 4px 10px rgba(240, 62, 62, 0.4)); z-index: 10; }

.weave-board-item-img {
  width: 100%; height: auto; display: block;
  cursor: grab; mix-blend-mode: normal; pointer-events: auto;
}
.weave-board-item-img:active { cursor: grabbing; }

/* ⭐ 얇은 SVG 회전 핸들 유지 */
.weave-rotate-handle {
  position: absolute;
  top: 10px; right: 10px; 
  width: 32px; height: 32px;
  background-color: transparent;
  border: none;
  color: #f03e3e; 
  font-size: 28px; 
  font-weight: 100; 
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  opacity: 0; pointer-events: none; 
  transition: opacity 0.2s, color 0.2s, transform 0.2s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
  z-index: 20;
}

.weave-board-item-wrapper:hover .weave-rotate-handle {
  opacity: 1; pointer-events: auto;
}

.weave-rotate-handle:hover {
  transform: scale(1.1); 
}

.weave-rotate-handle:active { cursor: grabbing; color: #8b0000; }