@layer reset, tokens, base, layout, components, utilities;

/* =========================
   User badge + nickname (level emoji)
   - show before every displayed nickname
   ========================= */
.user-badge-nick{
  display:inline-flex;
  align-items:center;
  gap:6px;
  vertical-align:middle;
}

/* NOTE:
   .level-emoji-wrap / .level-emoji-img are used in multiple places
   (header, tables, lists). Define global defaults first.
*/
.level-emoji-wrap{
  width:20px;
  height:20px;
  border-radius:6px;
  display:inline-block;
  overflow:visible;
  position:relative;
  vertical-align:middle;
}

.level-emoji-img{
  width:100%;
  height:100%;
  display:block;
  border-radius:6px;
}

/* layout helper: nickname line */
.user-badge-nick .level-emoji-wrap{
  width:20px;
  height:20px;
}

.user-badge-nick .user-nick-text{
  line-height:1;
}

/* sparkle/glow animation (CSS only) */
.level-emoji-wrap.sparkle{
  filter: drop-shadow(0 0 6px rgba(255,200,80,.55))
          drop-shadow(0 0 14px rgba(255,120,40,.35));
  animation: _lvGlowPulse 2.2s ease-in-out infinite;
}

.level-emoji-wrap.sparkle::before,
.level-emoji-wrap.sparkle::after{
  content:"";
  position:absolute;
  inset:-20%;
  pointer-events:none;
}

.level-emoji-wrap.sparkle::before{
  background: linear-gradient(
    120deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,.45) 18%,
    rgba(255,255,255,0) 36%
  );
  transform: translateX(-120%) rotate(8deg);
  mix-blend-mode: screen;
  animation: _lvShineSweep 2.6s ease-in-out infinite;
}

.level-emoji-wrap.sparkle::after{
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.95) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 25%, rgba(255,255,255,.85) 0 1.5px, transparent 3px),
    radial-gradient(circle at 60% 75%, rgba(255,240,190,.9) 0 2px, transparent 3.5px),
    radial-gradient(circle at 30% 80%, rgba(255,210,120,.8) 0 1.8px, transparent 3.2px);
  opacity:0;
  mix-blend-mode: screen;
  animation: _lvSparkleTwinkle 1.6s ease-in-out infinite;
}

@keyframes _lvGlowPulse{
  0%,100%{ filter: drop-shadow(0 0 6px rgba(255,200,80,.45))
                   drop-shadow(0 0 14px rgba(255,120,40,.25));
           transform: scale(1); }
  50%    { filter: drop-shadow(0 0 10px rgba(255,220,120,.75))
                   drop-shadow(0 0 22px rgba(255,120,40,.45));
           transform: scale(1.02); }
}

@keyframes _lvShineSweep{
  0%   { transform: translateX(-140%) rotate(8deg); opacity: 0; }
  20%  { opacity: 1; }
  50%  { transform: translateX(140%) rotate(8deg); opacity: 0; }
  100% { transform: translateX(140%) rotate(8deg); opacity: 0; }
}

@keyframes _lvSparkleTwinkle{
  0%,100% { opacity: 0; transform: scale(1); }
  35%     { opacity: .9; transform: scale(1.02); }
  60%     { opacity: .2; transform: scale(1.01); }
}


/* role-specific tuning: admin/official should match the same badge world but feel 'authoritative' */
.level-emoji-wrap.role-admin{
  filter: drop-shadow(0 0 10px rgba(255,225,150,.90))
          drop-shadow(0 0 26px rgba(255,150,40,.55));
  animation-duration: 3.5s; /* slower */
}
.level-emoji-wrap.role-admin::before{ animation-duration: 4.2s; }
.level-emoji-wrap.role-admin::after{ display:none; }

.level-emoji-wrap.role-official{
  filter: drop-shadow(0 0 8px rgba(255,220,150,.70))
          drop-shadow(0 0 18px rgba(255,140,40,.35));
  animation-duration: 4.0s;
}
.level-emoji-wrap.role-official::before{ animation-duration: 4.8s; }
.level-emoji-wrap.role-official::after{ display:none; }

/* === Ver.0037 Public Visual Polish (tokens-based, no hardcoded colors) === */
@layer components {
  /* Surfaces / cards */
  .surface {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
  }

  .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
    will-change: transform;
  }
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in oklab, var(--line) 70%, var(--text));
  }

  /* Typography hierarchy */
  .h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem); letter-spacing: -0.02em; font-weight: 700; }
  .h2 { font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.75rem); letter-spacing: -0.015em; font-weight: 700; }
  .h3 { font-size: 1.125rem; font-weight: 650; letter-spacing: -0.01em; }
  .muted { color: var(--muted); }

  /* Chips / badges */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 88%, black);
    font-size: var(--fs-sm);
    line-height: 1.2;
  }

  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .6rem .9rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    font-weight: 600;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  .btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: color-mix(in oklab, var(--line) 70%, var(--text)); }
  .btn:active { transform: translateY(0px); box-shadow: var(--shadow-xs); }

  .btn-primary {
    background: color-mix(in oklab, var(--text) 14%, var(--surface));
    border-color: color-mix(in oklab, var(--text) 25%, var(--line));
  }


/* Board bars (tabs/toolbars) — unified component */
.boardbar{
  display:flex;
  flex-direction: column;
  align-items:stretch;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--bar-border);
  border-radius: var(--radius-xl);
  background: var(--bar-bg);
  box-shadow: var(--shadow-xs);
}
/* Backward compatible single-row mode */
.boardbar.boardbar--tabs{
  flex-direction: row;
  align-items:center;
  flex-wrap: wrap;
}
.boardbar__row{
  display:flex;
  align-items:center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.boardbar__left{
  display:flex;
  align-items:center;
  gap: var(--space-2);
  min-width: 0;
}
.boardbar__right{
  margin-left:auto;
  display:flex;
  align-items:center;
  gap: var(--space-2);
}

/* compact search/sort tools inside boardbar */
.boardbar__tools{
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: wrap;
}
.boardbar__tools .input,
.boardbar__tools .select{
  width: auto;
}
.boardbar__views{display:flex; gap:8px; align-items:center;}
.boardbar__title{
  font-weight: 900;
  letter-spacing: -0.01em;
}

/* Sort pills (instead of select) */
.sort-pills{
  display:flex;
  align-items:center;
  gap: 4px;
  flex-wrap: wrap;
}
.pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: .32rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration:none;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.pill:hover{
  background: var(--surface-2);
  border-color: color-mix(in oklab, var(--line) 70%, var(--text));
}
.pill.is-active{
  background: var(--accent-weak);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--line));
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

/* keyword highlight */
mark.hl{
  background: color-mix(in oklab, var(--accent) 20%, var(--surface));
  color: inherit;
  border-radius: 6px;
  padding: 0 .18em;
}
.boardbar__tabs{
  display:flex;
  gap: 8px;
  align-items:center;
  flex-wrap: wrap;
}
/* When using legacy .boardbar__tabs container in single-row mode */
.boardbar.boardbar--tabs .boardbar__tabs{
  margin-left:auto;
}
.boardbar__tab{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: .45rem;
  padding: .55rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
  font-size: var(--fs-md);
  letter-spacing: -0.01em;
  text-decoration:none;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.boardbar__tab:hover{
  background: var(--surface-2);
  border-color: color-mix(in oklab, var(--line) 70%, var(--text));
  text-decoration:none;
}
.boardbar__tab.is-active,
.boardbar__tab[aria-selected="true"]{
  background: var(--accent-weak);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--line));
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

/* Buttons — unified variants */
.btn-secondary{
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost{
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text);
}
.btn-ghost:hover{
  background: var(--surface-2);
  border-color: transparent;
  box-shadow: none;
}
.btn-danger{
  background: var(--danger-weak);
  border-color: color-mix(in oklab, var(--danger) 30%, var(--line));
  color: var(--danger);
}
.btn-icon{
  width: 40px;
  padding: 0;
}

  /* Toolbars / sections */
  .toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: color-mix(in oklab, var(--surface) 92%, black);
  }

  .section {
    padding: var(--space-4);
    border-radius: var(--radius-2xl);
    background: color-mix(in oklab, var(--surface) 94%, black);
    border: 1px solid var(--line);
  }

  /* Media */
  .thumb {
    aspect-ratio: var(--thumb-ar, 230 / 280);
    width: 100%;
    object-fit: cover;
    display: block;
    background: color-mix(in oklab, var(--surface) 85%, black);
  }
}

@layer utilities {
  .grid-cards {
    display: grid;
    gap: var(--space-4);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  .stack { display: grid; gap: var(--space-3); }
  .row { display:flex; align-items:center; gap: var(--space-2); flex-wrap: wrap; }
  .spacer { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .btn { transition: none !important; transform: none !important; }
}

/* === Ver.0040 Utility Cleanup (non-breaking) === */
@layer utilities {
  /* Semantic aliases (optional to use going forward) */
  .u-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-2xl); box-shadow: var(--shadow-xs); overflow: hidden; }
  .u-toolbar { padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-xl); background: color-mix(in oklab, var(--surface) 92%, black); }
  .u-actions { display:flex; gap: var(--space-2); flex-wrap: wrap; justify-content:flex-end; align-items:center; }
  .u-chip { display:inline-flex; align-items:center; gap:.35rem; padding:.25rem .6rem; border-radius:999px; border:1px solid var(--line); background: color-mix(in oklab, var(--surface) 88%, black); font-size: var(--fs-sm); line-height: 1.2; }
}

/* === TOKENS (Ver.0046) === */
@layer tokens {
  :root{
    /* Base */
    --bg: #f6f7fb;            /* page background (soft) */
    --surface: #ffffff;       /* cards / panels */
    --surface-2: #f1f3f8;     /* hover / subtle bar tint */

    /* Typography */
    --text: #111827;
    --muted: #4b5563;

    /* Lines / borders */
    --line: #e6eaf2;

    /* Accent (single, soft) */
    --accent: #4f6ff6;
    --accent-weak: color-mix(in oklab, var(--accent) 12%, transparent);

    /* Status */
    --danger: #e25555;
    --danger-weak: color-mix(in oklab, var(--danger) 14%, transparent);

    /* Bars (header/footer/boardbar) */
    /* Slight tint so the user can clearly see the bar areas. */
    --bar-bg: var(--surface-2);
    --bar-border: var(--line);

    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-2xl: 22px;

    --shadow-xs: 0 1px 0 rgba(17,24,39,.04);
    --shadow-sm: 0 6px 18px rgba(17,24,39,.08);
    --shadow-lg: 0 18px 60px rgba(17,24,39,.12);

    --fs-sm: 12px;
    --fs-md: 14px;
    --fs-lg: 16px;

    --space-1: 6px;
    --space-2: 10px;
    --space-3: 14px;
    --space-4: 18px;
    --space-5: 24px;

    --container: 1300px;
  }
}



/* === SECTION ACCENTS (Ver.0054) ===
   Use data-accent on <body> or a wrapper to switch only the accent color.
   UI components (buttons/boardbar) stay identical; only highlight color changes.
*/
[data-accent="jav"]{
  --accent: #4f6ff6;
  --accent-weak: color-mix(in oklab, var(--accent) 12%, transparent);
}
[data-accent="vr"]{
  --accent: #22a06b;
  --accent-weak: color-mix(in oklab, var(--accent) 12%, transparent);
}
[data-accent="community"]{
  --accent: #7c5cff;
  --accent-weak: color-mix(in oklab, var(--accent) 12%, transparent);
}
[data-accent="tools"]{
  --accent: #f08c2e;
  --accent-weak: color-mix(in oklab, var(--accent) 12%, transparent);
}


/* Fallback: if color-mix/oklab are unsupported, keep solid colors */
@supports not (color: color-mix(in oklab, white 50%, black)){
  :root{
    --accent-weak: rgba(79,111,246,.12);
    --danger-weak: rgba(226,85,85,.14);
    --bar-bg: #f1f3f8;
    --bar-border: #e6eaf2;
  }
}

/* Accent weak fallbacks per section (no color-mix/oklab) */
[data-accent="jav"]{ --accent:#4f6ff6; --accent-weak: rgba(79,111,246,.12); }
[data-accent="vr"]{ --accent:#22a06b; --accent-weak: rgba(34,160,107,.12); }
[data-accent="community"]{ --accent:#7c5cff; --accent-weak: rgba(124,92,255,.12); }
[data-accent="tools"]{ --accent:#f08c2e; --accent-weak: rgba(240,140,46,.12); }

/* === BASE (Ver.0046) === */
@layer base {
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body{
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
    font-size: var(--fs-lg);
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
  }
  a{ color: inherit; text-decoration: none; }
  a:hover{ text-decoration: underline; }
  img{ max-width: 100%; height: auto; display:block; }
}

/* === LAYOUT: Header / Nav (Ver.0046) === */
@layer layout {
  .site-header{
    border-bottom: 1px solid var(--bar-border);
    background: var(--bar-bg);
    box-shadow: var(--shadow-xs);
}
  .site-header-top-inner,
  .site-nav-inner{
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-3) var(--space-4);
    display:flex;
    align-items:center;
    gap: var(--space-3);
  }

  /* === Page container (Ver.0019)
     Home/Actors/Works(JAV/VR) pages should visually match work_detail width.
     - public_layout.html uses: .g-page > .container
     - base.html pages often render: section.site_body / div.g-page
  */
  .container{
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-3) var(--space-4);
  }

  /* base.html pages (actors/works etc.) */
  .public-wrapper > .g-page,
  .public-wrapper > .site_body,
  .public-wrapper > section.site_body{
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--space-3) var(--space-4);
  }

  .site-logo{
    font-weight: 900;
    letter-spacing: -0.03em;
    font-size: 22px;
    display:inline-flex;
    align-items:baseline;
    gap: 2px;
  }
  .site-logo span{ color: color-mix(in oklab, var(--text) 55%, var(--muted)); font-weight: 800; }

  .site-search{
    /* Search should not dominate header width; keep it compact but responsive */
    flex: 0 1 clamp(220px, 28vw, 420px);
    display:flex;
    align-items:center;
    gap: var(--space-2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 8px 6px 12px;
    box-shadow: var(--shadow-xs);
    min-width: 240px;
  }
  .site-search-input{
    flex: 1 1 auto;
    border: 0;
    outline: none;
    font-size: var(--fs-md);
    background: transparent;
  }
  .site-search-btn{
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 90%, black);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
  }
  .site-search-btn:hover{
    border-color: color-mix(in oklab, var(--line) 70%, var(--text));
  }
  .site-search-btn-text{ font-size: 13px; }

  /* Push account links to the far right edge of the header */
  .site-user{ margin-left: auto; display:flex; align-items:center; gap: var(--space-2); white-space: nowrap; }
  /* prevent badge images (in header) from looking half-clipped */
  .site-user-meta{ display:inline-flex; align-items:center; gap:6px; line-height:1.1; }
  .site-user-name{ font-weight: 700; color: color-mix(in oklab, var(--text) 75%, var(--muted)); }
  
  /* Account area (top-right) */
  .accountbar{ position: relative; display:inline-flex; align-items:center; gap: 10px; }

  /* Logged-in (links only) */
  .accountbar--links{ gap: 8px; }

  .account-link{
    display:inline-flex;
    align-items:center;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    font-weight: 800;
    font-size: 13px;
    color: var(--text-2);
  }
  .account-link:hover{ text-decoration:none; background: var(--surface-2); color: var(--text); }

  /* Plain text account links (requested) */
  .accountbar--links{ gap: 12px; }
  .account-link--plain{
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font-weight: 800;
    font-size: 13px;
    color: var(--text-2);
  }
  .account-link--plain:hover{
    background: transparent;
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
  .account-link--btn{
    appearance:none;
    -webkit-appearance:none;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  .site-nav{
    border-top: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 98%, black);
  }
  .site-nav-inner{ padding-top: 10px; padding-bottom: 10px; }
  .site-nav-item{
    display:inline-flex;
    align-items:center;
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
  }
  .site-nav-item.is-active{
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    text-decoration:none;
  }
  .site-nav-group{ position: relative; }
  .site-nav-dropdown{
    position:absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: 10px;
    display:none;
    z-index: 50;
  }
  /* hover gap bridge: prevent dropdown from closing when moving mouse */
  .site-nav-dropdown::before{
    content:"";
    position:absolute;
    left:0; right:0;
    top:-10px;
    height:10px;
  }
  .site-nav-group:hover .site-nav-dropdown{ display:block; }
  .site-nav-dropdown a{
    display:flex;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
  }
  .site-nav-dropdown a:hover{
    background: color-mix(in oklab, var(--surface) 92%, black);
    text-decoration:none;
  }

  /* Community dropdown: 2-level, side-by-side */
  .site-nav-dropdown--community{
    display:none; /* keep default hidden; shown by hover rule */
    min-width: 380px;
    padding: 10px;
    gap: 10px;
    align-items: stretch;
    flex-direction: row;
  }
  .site-nav-group:hover .site-nav-dropdown--community{ display:flex; }

  /* Works dropdown: makers under JAV/VR */
  .site-nav-dropdown--works{
    display:none; /* keep default hidden; shown by hover rule */
    min-width: 220px;
    max-width: 280px;
    padding: 10px;
    gap: 8px;
    align-items: stretch;
    flex-direction: column;
  }
  .site-nav-group:hover .site-nav-dropdown--works{ display:flex; }

  .nav-dd-scroll{
    max-height: 300px;
    overflow: auto;
    padding-right: 4px;
  }
  .nav-dd-item--more{
    margin-top: 6px;
    background: color-mix(in oklab, var(--surface) 96%, black);
    border: 1px dashed var(--line);
  }
  .nav-dd-col{
    display:flex;
    flex-direction: column;
    gap: 6px;
  }
  .nav-dd-col--primary{ min-width: 150px; }
  .nav-dd-col--sub{
    min-width: 190px;
    border-left: 1px solid var(--line);
    padding-left: 10px;
  }
  .nav-dd-item{
    display:flex;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 14px;
  }
  .nav-dd-item--root{
    background: color-mix(in oklab, var(--surface) 94%, black);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-xs);
  }
  .nav-dd-item:hover{
    background: color-mix(in oklab, var(--surface) 92%, black);
    text-decoration:none;
  }

  .nav-dd-section-title{
    padding: 6px 10px 2px;
    font-size: 12px;
    font-weight: 900;
    opacity: .7;
    letter-spacing: .02em;
  }

  @media (max-width: 860px){
    .site-header-top-inner{ flex-wrap: wrap; }
    .site-search{ order: 3; width: 100%; min-width: 0; }
    .site-user{ margin-left: auto; }
  }

  /* === Nav + Footer bar tone (Ver.0046) === */
  .site-nav{
    border-top: 1px solid var(--bar-border);
    background: var(--bar-bg);
  }

  .site-footer{
    margin-top: 44px;
    border-top: 1px solid var(--bar-border);
    background: var(--bar-bg);
  }
  .site-footer-inner{
    max-width: var(--container);
    margin: 0 auto;
    padding: 20px var(--space-4);
    color: var(--muted);
    font-size: var(--fs-md);
  }

}

/* === COMPONENTS: .btn / .input / .card (Ver.0048) === */
@layer components {
  .card{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
  }
  .card:hover{
    border-color: color-mix(in oklab, var(--line) 70%, var(--text));
  }

  .input{
    width: 100%;
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 96%, black);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: var(--fs-md);
    outline: none;
  }
  .input:focus{
    border-color: color-mix(in oklab, var(--text) 35%, var(--line));
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--text) 10%, transparent);
  }

  .btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap: 8px;
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 90%, black);
    color: var(--text);
    border-radius: 999px;
    padding: 9px 14px;
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    text-decoration: none;
  }
  .btn:hover{
    text-decoration:none;
    border-color: color-mix(in oklab, var(--line) 70%, var(--text));
  }
  .btn:active{ transform: translateY(1px); }

  .btn-primary{
    background: color-mix(in oklab, var(--accent) 12%, var(--surface));
    border-color: color-mix(in oklab, var(--accent) 25%, var(--line));
  }
  .btn-danger{
    background: var(--danger-weak);
    border-color: color-mix(in oklab, var(--danger) 30%, var(--line));
  }

  /* compact controls for toolbars */
  .input-sm{
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 999px;
  }

  .select{
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 96%, black);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: var(--fs-md);
    outline: none;
  }
  .select:focus{
    border-color: color-mix(in oklab, var(--text) 35%, var(--line));
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--text) 10%, transparent);
  }
  .select-sm{
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 999px;
  }
}

/* === COMPONENTS: Auth Modal (Ver.0048) === */
@layer components {
  .auth-modal{ position: fixed; inset: 0; display: none; z-index: 999; }
  .auth-modal.is-open{ display:block; }
  .auth-modal-backdrop{
    position:absolute; inset:0;
    background: rgba(0,0,0,.45);
  }
  .auth-modal-panel{
    position: relative;
    max-width: 420px;
    margin: 8vh auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    padding: 16px 16px 18px;
  }
    /* topbar uses global .boardbar */
  .auth-topbar{ margin-bottom: 14px; }
  .auth-modal-close{ width: 40px; height: 40px; }
  .auth-form{ display:grid; gap: 10px; }
  .auth-label{ font-size: 12px; color: var(--muted); font-weight: 800; }
  .auth-input{ composes: input; }
  /* no 'composes' in plain CSS; map by duplicating */
  .auth-input{
    width: 100%;
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--surface) 96%, black);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    font-size: var(--fs-md);
    outline: none;
  }
  .auth-input:focus{
    border-color: color-mix(in oklab, var(--text) 35%, var(--line));
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--text) 10%, transparent);
  }
  .auth-submit{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    border: 1px solid var(--line);
    background: color-mix(in oklab, var(--accent) 12%, var(--surface));
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 900;
    cursor: pointer;
  }
  .auth-pane{ display:none; }
  .auth-pane.is-active{ display:block; }
}

/* === Ver.0049 Nav Active Style (remove pill/circle) === */
@layer layout {
  /* Make nav items plain text buttons (no pill) */
  .site-nav-item{
    border-radius: 10px; /* not circular */
    padding: 10px 8px;
    position: relative;
  }
  .site-nav-item.is-active{
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-decoration: none;
  }
  .site-nav-item.is-active::after{
    content:"";
    position:absolute;
    left: 8px;
    right: 8px;
    bottom: 4px;
    height: 2px;
    background: color-mix(in oklab, var(--text) 70%, var(--line));
    border-radius: 999px;
  }
}


/* Footer action bar (admin write/edit) */

.g-footerbar-spacer{height:72px}
@media (max-width:560px){.g-footerbar-spacer{height:84px}}
.g-footerbar{position:fixed;left:0;right:0;bottom:0;z-index:9999;background:var(--bar-bg,var(--surface,#fff));border-top:1px solid var(--bar-border,var(--line,#e5e7eb));padding:10px 0;margin-top:16px}

/* ===== P0 Scroll lock + footer overlap safety (Ver.0068) =====
   - 일부 페이지에서 html/body에 overflow:hidden, height:100vh 등이 걸려 스크롤이 멈추고
     하단 버튼/폼이 푸터 뒤로 숨는 문제가 발생할 수 있음.
   - blur 팝업(editor_popup) 같은 전용 페이지는 body에 .blur-page 클래스를 붙여 예외 처리.
*/
:root{--footerbar-h:96px;}

html:not(.blur-page), body:not(.blur-page){
  height:auto !important;
  min-height:100% !important;
  overflow-x:hidden !important;
  overflow-y:auto !important;
}

/* footerbar 유무와 관계없이, 고정 하단바가 있을 때 가려짐 방지용 기본 여백 */
body:not(.blur-page){padding-bottom:calc(var(--footerbar-h) + env(safe-area-inset-bottom)) !important;}
.g-footerbar{height:var(--footerbar-h); padding-bottom:env(safe-area-inset-bottom);}
.g-footerbar-spacer{height:calc(var(--footerbar-h) + env(safe-area-inset-bottom));}
.g-footerbar__inner{display:flex;gap:10px;justify-content:flex-end;align-items:center}
@media (max-width:560px){.g-footerbar__inner{justify-content:space-between}}

.g-footerbar__ver{font-size:12px;opacity:.6;margin-right:6px;white-space:nowrap}

/* FooterBar debug marker */
.g-footerbar__ver{font-size:11px;opacity:.55;margin-right:6px;white-space:nowrap}
.g-footerbar{z-index:9999}

/* FooterBar bottom text (admin-controlled, text-only) */
.g-footerbar__text{
  font-size:11px;
  line-height:1.4;
  opacity:.65;
  text-align:center;
  padding-top:4px;
  pointer-events:none;
  word-break:keep-all;
}



/* ===== FooterBar/Scroll Safety (Ver.0069) ===== */
:root{ --footerbar-h: 96px; }

/* 항상 스크롤 가능 */
html, body{
  height: auto !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

/* 푸터바가 fixed이므로 하단 콘텐츠가 가려지지 않게 기본 여백 확보 */
body{
  padding-bottom: calc(var(--footerbar-h) + env(safe-area-inset-bottom)) !important;
}

/* 블러 편집기(팝업)는 예외: 자체 스크롤/캔버스 제어 */
html.blur-page, body.blur-page{
  overflow: hidden !important;
  padding-bottom: 0 !important;
}



/* ==============================
   P0 FIX: Small viewport scroll recovery + FooterBar visibility (Ver.0070)
   - When viewport is narrow, some pages were locked by 100vh/fixed wrappers and overflow hidden,
     making the bottom footer buttons unreachable.
   - This block forces document scrolling back to body/html and prevents footer clipping.
   ============================== */

@media (max-width: 900px) {
  html, body {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  /* Neutralize common full-page lock wrappers on small viewports */
  .wrap,
  .page,
  .layout,
  .container,
  main,
  #app,
  #root {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    position: static !important;
  }
}

/* FooterBar must never be clipped */
.g-footerbar{
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 9999 !important;
}

/* Ensure content is not hidden behind the fixed FooterBar */
:root{ --footerbar-h: 96px; }
body{
  padding-bottom: calc(var(--footerbar-h) + env(safe-area-inset-bottom)) !important;
}



/* ===== Role badge glow tuning ===== */
/* ADMIN: strongest */
.level-emoji-wrap.role-admin{
  filter: drop-shadow(0 0 12px rgba(255,230,160,.95))
          drop-shadow(0 0 30px rgba(255,160,60,.60));
  animation-duration: 3.2s;
}
/* STAFF: strong */
.level-emoji-wrap.role-staff{
  filter: drop-shadow(0 0 10px rgba(180,230,255,.85))
          drop-shadow(0 0 24px rgba(90,180,255,.45));
  animation-duration: 3.6s;
}
/* MOD: medium */
.level-emoji-wrap.role-mod,
.level-emoji-wrap.role-moderator{
  filter: drop-shadow(0 0 9px rgba(210,255,210,.75))
          drop-shadow(0 0 20px rgba(120,255,160,.35));
  animation-duration: 4.0s;
}
/* OFFICIAL: gold-ish */
.level-emoji-wrap.role-official,
.level-emoji-wrap.role-verified{
  filter: drop-shadow(0 0 10px rgba(255,235,175,.70))
          drop-shadow(0 0 22px rgba(255,200,90,.35));
  animation-duration: 3.8s;
}
/* USER: level-based glow scaling (lr1..lr6)
   - lr1: very subtle
   - lr6: very strong (near top level)
*/
.level-emoji-wrap.role-user.lr1{
  filter: drop-shadow(0 0 4px rgba(255,200,80,.30))
          drop-shadow(0 0 10px rgba(255,120,40,.18));
  animation-duration: 2.8s;
}
.level-emoji-wrap.role-user.lr1::before{ animation-duration: 3.2s; }
.level-emoji-wrap.role-user.lr1::after{ animation-duration: 1.9s; }

.level-emoji-wrap.role-user.lr2{
  filter: drop-shadow(0 0 5px rgba(255,210,95,.38))
          drop-shadow(0 0 12px rgba(255,130,45,.22));
  animation-duration: 2.6s;
}
.level-emoji-wrap.role-user.lr2::before{ animation-duration: 3.0s; }
.level-emoji-wrap.role-user.lr2::after{ animation-duration: 1.8s; }

.level-emoji-wrap.role-user.lr3{
  filter: drop-shadow(0 0 6px rgba(255,220,115,.48))
          drop-shadow(0 0 14px rgba(255,140,55,.28));
  animation-duration: 2.4s;
}
.level-emoji-wrap.role-user.lr3::before{ animation-duration: 2.8s; }
.level-emoji-wrap.role-user.lr3::after{ animation-duration: 1.7s; }

.level-emoji-wrap.role-user.lr4{
  filter: drop-shadow(0 0 7px rgba(255,230,135,.60))
          drop-shadow(0 0 16px rgba(255,150,60,.34));
  animation-duration: 2.3s;
}
.level-emoji-wrap.role-user.lr4::before{ animation-duration: 2.7s; }
.level-emoji-wrap.role-user.lr4::after{ animation-duration: 1.65s; }

.level-emoji-wrap.role-user.lr5{
  filter: drop-shadow(0 0 8px rgba(255,240,160,.72))
          drop-shadow(0 0 20px rgba(255,160,65,.42));
  animation-duration: 2.2s;
}
.level-emoji-wrap.role-user.lr5::before{ animation-duration: 2.6s; }
.level-emoji-wrap.role-user.lr5::after{ animation-duration: 1.6s; }

.level-emoji-wrap.role-user.lr6{
  filter: drop-shadow(0 0 10px rgba(255,250,190,.85))
          drop-shadow(0 0 26px rgba(255,170,70,.52));
  animation-duration: 2.1s;
}
.level-emoji-wrap.role-user.lr6::before{ animation-duration: 2.5s; }
.level-emoji-wrap.role-user.lr6::after{ animation-duration: 1.55s; }
