/* ==========================================================================
   오라클마크 (OracleMark) — 판각 공방(Studio) · 천원지방 패철(Luopan) · 비장함 · 모바일 탭바
   ========================================================================== */

.studio {
  padding-block: 32px 16px;
}

.studio-grid {
  display: grid;
  gap: 24px;
  align-items: start;
}

@media (min-width: 1000px) {
  .studio-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(350px, 0.85fr);
  }
  .studio-right {
    position: sticky;
    top: 82px;
  }
}

.studio-left {
  display: grid;
  gap: 22px;
}

.card-h {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.form {
  gap: 0;
}

.form .row:last-of-type {
  margin-bottom: 8px;
}

/* ── 천원지방(天圓地方) 패철 나침반 판 (Square Earth Plate + Round Heaven Wheel) ── */
.wheel-card {
  position: relative;
}

.luopan-plate {
  position: relative;
  width: min(100%, 540px);
  margin: 12px auto 6px;
  padding: clamp(10px, 2.5vw, 18px);
  background: var(--surface-inset);
  border: 2px solid var(--border-strong);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px var(--border-fine);
}

/* 네 귀퉁이 사방 팔괘 각인 (乾·艮·坤·巽) */
.corner-trig {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  pointer-events: none;
  user-select: none;
  color: var(--accent);
  opacity: 0.72;
  z-index: 1;
}

.corner-trig b {
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  font-weight: 400;
}

.corner-trig small {
  font-family: var(--serif);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.ct-nw { top: 8px; left: 10px; }
.ct-ne { top: 8px; right: 10px; }
.ct-sw { bottom: 8px; left: 10px; }
.ct-se { bottom: 8px; right: 10px; }

.wheel {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
  z-index: 2;
}

.wheel-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.wheel-svg text {
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.w-plate {
  stroke: var(--border-strong);
  stroke-width: 2;
}

.w-outer-ring {
  stroke: var(--accent);
  stroke-opacity: 0.55;
  stroke-width: 1.2;
}

.w-tick {
  stroke: var(--accent);
  stroke-opacity: 0.28;
  stroke-width: 1;
}

.w-tick-major {
  stroke-opacity: 0.58;
  stroke-width: 1.4;
}

.w-tick-cardinal {
  stroke: var(--seal-ink);
  stroke-opacity: 0.9;
  stroke-width: 2.2;
}

.w-spin {
  stroke: var(--accent);
  stroke-opacity: 0.5;
  stroke-width: 1.5;
  stroke-dasharray: 3 7;
  transform-origin: 260px 260px;
  animation: wspin 120s linear infinite;
}

@keyframes wspin {
  to {
    transform: rotate(360deg);
  }
}

.w-guide {
  stroke: var(--border-strong);
  stroke-width: 1.2;
}

/* 바깥 고리: 12지지 (띠) */
.zod path {
  fill: var(--surface);
  stroke: var(--border-fine);
  stroke-width: 1;
}

.z-han {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 900;
  fill: var(--text);
}

.z-emo {
  font-family: var(--serif);
  font-size: 9.5px;
  font-weight: 700;
  fill: var(--muted);
}

.zod.me path {
  fill: color-mix(in srgb, var(--accent) 20%, var(--surface));
  stroke: var(--accent);
  stroke-width: 1.4;
}

.zod.me .z-han {
  fill: var(--accent);
}

.zod.year path {
  fill: var(--seal-ink);
  stroke: var(--accent);
  stroke-width: 1.8;
}

.zod.year .z-han,
.zod.year .z-emo {
  fill: var(--seal-text);
}

/* 인터랙티브 고리 공통 (문화권 5 · 소원 8) */
.sec {
  cursor: pointer;
  outline: none;
}

.sec path {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1;
  transition: fill 0.2s, stroke 0.2s, transform 0.2s;
  transform-origin: 260px 260px;
}

.sec:hover path {
  fill: var(--surface-raised);
  stroke: var(--accent);
}

.sec:focus-visible path {
  stroke: var(--accent);
  stroke-width: 2.5;
}

/* 중간 고리: 5대 문화권 */
.s-name {
  font-family: var(--serif);
  font-size: 15.5px;
  font-weight: 900;
  fill: var(--text);
}

.s-sub {
  font-family: var(--serif);
  font-size: 9.8px;
  fill: var(--muted);
}

.sec-c path {
  fill: color-mix(in srgb, var(--c) 12%, var(--surface));
}

.sec-c.on path {
  fill: var(--seal-ink);
  stroke: var(--accent);
  stroke-width: 2.2;
  transform: scale(1.02);
}

.sec-c.on .s-name {
  fill: var(--seal-text);
}

.sec-c.on .s-sub {
  fill: rgba(255, 245, 230, 0.88);
}

/* 안쪽 고리: 8대 소원 분야 (한자 인장 + 한글) */
.f-ico {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 900;
  fill: var(--accent);
}

.f-name {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 700;
  fill: var(--text);
}

.sec-f.on path {
  fill: var(--accent);
  stroke: var(--seal-ink);
  stroke-width: 2.2;
  transform: scale(1.025);
}

.sec-f.on .f-ico {
  fill: #1a1008;
}

.sec-f.on .f-name {
  fill: #1a1008;
  font-weight: 900;
}

/* 중앙 천심(天心) 코어 */
.w-star-lines {
  stroke: var(--accent);
  stroke-opacity: 0.16;
  stroke-width: 1;
}

.w-core-ring {
  stroke: var(--accent);
  stroke-width: 2.2;
}

.w-core-inner-ring {
  stroke: var(--seal-ink);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.c-tag {
  font-family: var(--serif);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  fill: var(--muted);
}

.c-phrase {
  font-weight: 900;
  fill: var(--accent);
}

.c-read {
  font-family: var(--serif);
  font-size: 12px;
  fill: var(--text);
  font-weight: 700;
}

.c-field {
  font-family: var(--serif);
  font-size: 11.5px;
  font-weight: 700;
  fill: var(--seal-ink);
}

.wheel-status {
  text-align: center;
  font-family: var(--serif);
  font-size: 0.9rem;
  color: var(--muted);
  margin: 12px 0 6px;
  padding: 8px 12px;
  background: var(--surface-inset);
  border: 1px solid var(--border-fine);
  min-height: 1.5em;
}

.wheel-status b {
  color: var(--accent);
}

.wheel-hint b {
  color: var(--text);
  font-family: var(--serif);
}

.daily {
  justify-content: center;
  margin: 4px 0 6px;
}

/* 모바일 나침반 화면 우상단 미니 인출본 */
.mini-preview {
  display: none;
  position: absolute;
  right: 16px;
  top: 44px;
  width: 72px;
  aspect-ratio: 3 / 5;
  border-radius: 0;
  overflow: hidden;
  border: 2px solid var(--accent);
  padding: 0;
  background: #120c07;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink-shadow);
  z-index: 4;
}

.mini-preview svg {
  display: block;
  width: 100%;
  height: 100%;
}

.mini-preview::after {
  content: '실견 열람';
  position: absolute;
  inset: auto 0 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 9.5px;
  background: var(--seal-ink);
  color: var(--seal-text);
  padding: 2px 0;
  text-align: center;
}

/* ── 부적 인출 검수대 (Viewer) ── */
.viewer {
  display: grid;
  gap: 14px;
}

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.viewer-head h3 {
  font-size: 1.12rem;
  margin: 0;
  font-family: var(--serif);
  font-weight: 900;
  letter-spacing: 0.03em;
}

.badge {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 0;
  border: 1px solid var(--seal-ink);
  background: var(--surface-inset);
  color: var(--accent);
  white-space: nowrap;
}

.badge[hidden] {
  display: none;
}

.viewer .talisman-mount {
  width: min(100%, 410px);
  margin: 0 auto;
}

.save-panel {
  display: grid;
  gap: 10px;
}

.save-panel .preset-label {
  margin: 0;
}

.save-panel .btn-row .btn {
  flex: 1 1 140px;
}

.sub-row .btn {
  flex: 1 1 120px;
  font-size: 0.86rem;
  padding: 9px 14px;
}

.save-panel .hint {
  margin: 0;
}

.read-grid {
  display: grid;
  gap: 20px;
}

@media (min-width: 900px) {
  .read-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── 비장함 (보관함 · Specimen Vault) ── */
.vault {
  padding-block: 34px 14px;
}

.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 14px;
}

@media (min-width: 640px) {
  .vault-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
  }

  .vault-item {
    width: 176px;
    flex: 0 0 176px;
  }
}

.vault-item {
  position: relative;
  border-radius: 0;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  padding: 10px;
  display: grid;
  gap: 8px;
  box-shadow: 4px 4px 0 var(--ink-shadow);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.vault-item:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.vault-item .v-open {
  padding: 0;
  border: 1px solid var(--accent);
  background: none;
  cursor: pointer;
  border-radius: 0;
  overflow: hidden;
  aspect-ratio: 3 / 5;
}

.vault-item .v-open svg {
  display: block;
  width: 100%;
  height: 100%;
}

.vault-item small {
  font-family: var(--serif);
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.vault-item .v-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 0;
  border: 1px solid var(--seal-text);
  background: var(--seal-ink);
  color: var(--seal-text);
  cursor: pointer;
  font-weight: 900;
  font-size: 13px;
  line-height: 1;
}

.vault-empty {
  text-align: center;
  font-family: var(--serif);
  color: var(--muted);
  padding: 36px 20px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-inset);
}

.vault-empty[hidden] {
  display: none;
}

/* ── 토스트 (전각 통지패) ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--surface);
  border: 2px solid var(--accent);
  outline: 2px solid var(--seal-ink);
  color: var(--text);
  font-family: var(--serif);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 0;
  font-size: 0.9rem;
  box-shadow: 5px 5px 0 var(--ink-shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 60;
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── 햄버거 버튼 및 모바일 드로어 ── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: var(--surface-inset);
  border: 1px solid var(--border-strong);
  padding: 8px;
  cursor: pointer;
  z-index: 51;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  transition: transform 0.25s, opacity 0.25s;
}

.hamburger[aria-expanded='true'] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger[aria-expanded='true'] span:nth-child(2) {
  opacity: 0;
}

.hamburger[aria-expanded='true'] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-drawer {
  display: none;
}

/* ── 모바일 하단 탭바 4개 (필수 유지 항목) ── */
.tabbar {
  display: none;
}

@media (max-width: 899px) {
  body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .tabbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--header-bg);
    border-top: 2px solid var(--border-strong);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 0 var(--ink-shadow);
  }

  .tabbar button {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 3px;
    border: 0;
    background: none;
    color: var(--muted);
    font-family: var(--serif);
    font-size: 0.74rem;
    padding: 6px 0;
    cursor: pointer;
  }

  .tabbar svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: square;
    stroke-linejoin: miter;
  }

  .tabbar button[aria-selected='true'] {
    color: var(--accent);
    font-weight: 900;
    background: var(--surface-inset);
    outline: 1px solid var(--border-fine);
  }

  .tab-badge {
    position: absolute;
    top: 2px;
    left: calc(50% + 6px);
    min-width: 18px;
    height: 18px;
    border-radius: 0;
    background: var(--seal-ink);
    color: var(--seal-text);
    border: 1px solid var(--seal-text);
    font-family: var(--mono);
    font-size: 10px;
    display: grid;
    place-items: center;
    padding: 0 4px;
  }

  .tab-badge[hidden] {
    display: none;
  }

  .toast {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }

  /* 모바일 4탭 뷰 전환 제어 */
  body:not([data-view='compass']) .view-compass,
  body:not([data-view='viewer']) .view-viewer,
  body:not([data-view='vault']) .view-vault,
  body:not([data-view='more']) .view-more {
    display: none !important;
  }

  .hamburger {
    display: flex;
  }

  .nav-drawer {
    display: block;
  }

  .nav-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.68);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  .nav-drawer-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 78vw;
    max-width: 310px;
    background: var(--surface);
    border-left: 2px solid var(--border-strong);
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
    display: flex;
    flex-direction: column;
  }

  .nav-drawer[aria-hidden='false'] .nav-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .nav-drawer[aria-hidden='false'] .nav-drawer-panel {
    transform: translateX(0);
  }

  .nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 2px solid var(--border-strong);
    background: var(--surface-inset);
  }

  .drawer-close {
    background: none;
    border: 1px solid var(--border-fine);
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 9px;
  }

  .drawer-edition-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-fine);
    background: var(--surface-inset);
    display: grid;
    gap: 8px;
  }

  .drawer-edition-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--muted);
    letter-spacing: 0.1em;
  }

  .drawer-edition-box .edition-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .drawer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 18px;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border-fine);
  }

  .drawer-link:hover {
    background: var(--surface-raised);
  }

  .d-num {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    background: var(--seal-ink);
    color: var(--seal-text);
    font-size: 0.74rem;
  }

  .drawer-link-out {
    color: var(--accent);
    margin-top: auto;
    border-top: 1px solid var(--border-strong);
  }

  .studio {
    padding-top: 10px;
  }

  body[data-view='compass'] .studio-grid,
  body[data-view='viewer'] .studio-grid {
    gap: 0;
  }

  .hero {
    padding-block: 14px 4px;
    gap: 10px;
  }

  .hero-fan-frame,
  .hero-actions {
    display: none;
  }

  .hero-folio {
    grid-template-columns: 34px 1fr;
  }

  .hero h1 {
    font-size: clamp(1.55rem, 6.8vw, 2.05rem);
    margin-bottom: 0.3em;
  }

  .hero .lead {
    font-size: 0.9rem;
    margin-bottom: 0;
  }

  .mini-preview {
    display: block;
  }

  .wheel-card .card-h {
    padding-right: 84px;
  }

  .wheel-hint {
    padding-right: 84px;
    min-height: 4.8em;
  }

  .viewer .talisman-mount {
    width: min(100%, 330px);
  }
}

@media (max-width: 380px) {
  .s-sub {
    display: none;
  }
}
