/*
 * iPlace design system — pure CSS, shadcn-inspired tokens.
 * No frameworks: design tokens as CSS variables + component classes.
 *
 * Dark mode: <html data-theme="dark"> toggled by theme_controller (Stimulus),
 * defaults to prefers-color-scheme when no explicit choice is stored.
 */

/* Design tokens (light) ------------------------------------------------- */
:root {
  --background: #ffffff;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --card-foreground: #0a0a0a;
  --popover: #ffffff;
  --popover-foreground: #0a0a0a;
  --primary: #171717;
  --primary-foreground: #fafafa;
  --secondary: #f5f5f5;
  --secondary-foreground: #171717;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --accent: #f5f5f5;
  --accent-foreground: #171717;
  --destructive: #dc2626;
  --destructive-foreground: #fafafa;
  --border: #e5e5e5;
  --input: #e5e5e5;
  --ring: #a3a3a3;
  --success: #16a34a;
  --warning: #d97706;

  --radius: 0.625rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-lg: calc(var(--radius) + 4px);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Pretendard",
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --header-topbar-h: 2.5rem;
  --header-nav-h: 4rem;
  --container-max: 76rem;
}

/* Design tokens (dark) -------------------------------------------------- */
[data-theme="dark"] {
  --background: #0a0a0a;
  --foreground: #fafafa;
  --card: #171717;
  --card-foreground: #fafafa;
  --popover: #171717;
  --popover-foreground: #fafafa;
  --primary: #fafafa;
  --primary-foreground: #171717;
  --secondary: #262626;
  --secondary-foreground: #fafafa;
  --muted: #262626;
  --muted-foreground: #a3a3a3;
  --accent: #262626;
  --accent-foreground: #fafafa;
  --destructive: #ef4444;
  --destructive-foreground: #fafafa;
  --border: #2e2e2e;
  --input: #2e2e2e;
  --ring: #525252;
  --success: #22c55e;
  --warning: #f59e0b;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4);
  --shadow-lg:
    0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
}

/* System preference fallback (no explicit choice stored) --------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --background: #0a0a0a;
    --foreground: #fafafa;
    --card: #171717;
    --card-foreground: #fafafa;
    --popover: #171717;
    --popover-foreground: #fafafa;
    --primary: #fafafa;
    --primary-foreground: #171717;
    --secondary: #262626;
    --secondary-foreground: #fafafa;
    --muted: #262626;
    --muted-foreground: #a3a3a3;
    --accent: #262626;
    --accent-foreground: #fafafa;
    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    --border: #2e2e2e;
    --input: #2e2e2e;
    --ring: #525252;
  }
}

/* Lexxy (Action Text 본문/에디터) 색상 ---------------------------------- */
/* lexxy.css의 :root 변수를 반드시 확실히 덮어써야 다크 모드에서 본문이 보인다
   ( lexxy 스타일이 app.css 뒤에 로드되므로 선택자 특이도를 높인다 ) */
html[data-theme="dark"] {
  --lexxy-color-ink: #fafafa;
  --lexxy-color-ink-medium: #a3a3a3;
  --lexxy-color-ink-light: #737373;
  --lexxy-color-ink-lighter: #404040;
  --lexxy-color-ink-lightest: #262626;
  --lexxy-color-ink-inverted: #0a0a0a;
  --lexxy-color-canvas: #171717;
  --lexxy-color-text: #fafafa;
  --lexxy-color-text-subtle: #a3a3a3;
  --lexxy-color-link: #8ab4ff;
  --lexxy-color-accent-dark: #8ab4ff;
  --lexxy-color-accent-medium: #aecbfa;
  --lexxy-color-accent-light: #1e3a5f;
  --lexxy-color-accent-lightest: #17263c;
  --lexxy-color-selected: #26344f;
  --lexxy-color-selected-hover: #2f4266;
  --lexxy-color-code-bg: #0f0f0f;
  --lexxy-color-code-token-att: #ff7b72;
  --lexxy-color-code-token-comment: #8b949e;
  --lexxy-color-code-token-function: #d2a8ff;
  --lexxy-color-code-token-operator: #ff7b72;
  --lexxy-color-code-token-property: #79c0ff;
  --lexxy-color-code-token-punctuation: #a3a3a3;
  --lexxy-color-code-token-selector: #7ee787;
  --lexxy-color-code-token-variable: #ffa657;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --lexxy-color-ink: #fafafa;
    --lexxy-color-ink-medium: #a3a3a3;
    --lexxy-color-ink-light: #737373;
    --lexxy-color-ink-lighter: #404040;
    --lexxy-color-ink-lightest: #262626;
    --lexxy-color-ink-inverted: #0a0a0a;
    --lexxy-color-canvas: #171717;
    --lexxy-color-text: #fafafa;
    --lexxy-color-text-subtle: #a3a3a3;
    --lexxy-color-link: #8ab4ff;
    --lexxy-color-accent-dark: #8ab4ff;
    --lexxy-color-accent-light: #1e3a5f;
    --lexxy-color-accent-lightest: #17263c;
    --lexxy-color-selected: #26344f;
    --lexxy-color-code-bg: #0f0f0f;
    --lexxy-color-code-token-att: #ff7b72;
    --lexxy-color-code-token-comment: #8b949e;
    --lexxy-color-code-token-function: #d2a8ff;
    --lexxy-color-code-token-operator: #ff7b72;
    --lexxy-color-code-token-property: #79c0ff;
    --lexxy-color-code-token-punctuation: #a3a3a3;
    --lexxy-color-code-token-selector: #7ee787;
    --lexxy-color-code-token-variable: #ffa657;
  }
}

/* Base ----------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  /* sticky footer: 내용이 짧아도 footer 는 화면 하단 */
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

main {
  flex: 1 0 auto;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}
/* 1차 점검: hover 시 밑줄 대신 색상 변화로 피드백 (행 전체 링크의 밑줄 이슈 해소) */
a:hover {
  text-decoration: none;
}
.post-row:hover .post-title,
.post-nav a:hover .value,
.card-hover:hover h3,
.comment-body a:hover {
  color: var(--primary);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.25;
  margin: 0 0 0.75em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}
h2 {
  font-size: clamp(1.375rem, 3vw, 1.875rem);
}
h3 {
  font-size: 1.25rem;
}

p {
  margin: 0 0 1em;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Layout ---------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.stack > * + * {
  margin-top: 1rem;
}
.stack-sm > * + * {
  margin-top: 0.5rem;
}

.grid {
  display: grid;
  gap: 1.5rem;
}
.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.flex {
  display: flex;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.flex-center {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.flex-wrap {
  flex-wrap: wrap;
}

/* 목록 검색폼: 테이블과의 여백 확보 */
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.list-toolbar form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.list-toolbar input[type="text"] {
  width: 18rem;
  max-width: 100%;
}

.muted {
  color: var(--muted-foreground);
}
.small {
  font-size: 0.875rem;
}
.text-sm {
  font-size: 0.875rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Components ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  text-decoration: none;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--primary) 88%, black);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: color-mix(in srgb, var(--secondary) 85%, var(--foreground));
}

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}
.btn-ghost:hover {
  background: var(--accent);
}

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8125rem;
}
.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}
.btn-block {
  width: 100%;
}

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}
.card-hover:hover {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
}
.card {
  transition:
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}
.card-hover:hover {
  transform: translateY(-2px);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
}
.badge-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: transparent;
}
.badge-outline {
  background: transparent;
}
.badge-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: transparent;
}
.badge-success {
  background: var(--success);
  color: #fff;
  border-color: transparent;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.field label {
  font-size: 0.875rem;
  font-weight: 500;
}
.field-hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  margin: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.5rem 0.75rem;
  color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  width: 100%;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
textarea {
  min-height: 8rem;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 25%, transparent);
}
input[type="file"] {
  font-size: 0.875rem;
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
table.table th,
table.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.table th {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  background: var(--muted);
}
table.table tr:last-child td {
  border-bottom: none;
}
table.table tbody tr:hover {
  background: var(--accent);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9375rem;
}
.alert-error {
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
  border-color: var(--destructive);
  color: var(--destructive);
}
.alert-success {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border-color: var(--success);
  color: var(--success);
}
.alert-info {
  background: color-mix(in srgb, var(--ring) 15%, transparent);
  border-color: var(--ring);
}
.alert-list {
  margin: 0;
  padding-left: 1.1rem;
}

/* Toast (2차 점검): flash 메시지를 별도 레이어로 띄우고 자동 닫힘 -------- */
.toast-layer {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.9375rem;
  animation: toast-in 0.25s ease;
}
.toast-success {
  border-left-color: var(--success);
}
.toast-error {
  border-left-color: var(--destructive);
}
.toast-message {
  flex: 1;
  line-height: 1.45;
  overflow-wrap: break-word;
}
.toast-close {
  flex: none;
  background: none;
  border: 0;
  padding: 0 0.125rem;
  font: inherit;
  font-size: 1.125rem;
  line-height: 1;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
}
.toast-close:hover {
  opacity: 1;
}
.toast.is-hiding {
  opacity: 0;
  transform: translateY(-0.375rem);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Pagination (pagy series_nav) ------------------------------------------- */
.pagy.series-nav,
.pagination {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  flex-wrap: wrap;
}
.pagy.series-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--background);
  color: var(--foreground);
  text-decoration: none;
}
.pagy.series-nav a:hover {
  background: var(--accent);
}
.pagy.series-nav a[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}
.pagy.series-nav a[aria-current="page"] {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--background);
}
.pagination a:hover {
  background: var(--accent);
  text-decoration: none;
}
.pagination .active span {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}
.pagination .disabled span {
  opacity: 0.4;
}

/* Auth pages ------------------------------------------------------------ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 2rem 1rem;
}
.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-title {
  margin-bottom: 0.25rem;
}
.auth-subtitle {
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
}
.auth-links {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.auth-sep {
  opacity: 0.5;
}

/* Site header ----------------------------------------------------------- */
.site-header {
  position: relative;
  z-index: 50;
}

.site-topbar {
  background: var(--foreground);
  color: var(--background);
  font-size: 0.8125rem;
  height: var(--header-topbar-h);
  /* 언어 드롭다운이 아래로 펼쳐질 수 있도록 잘라내지 않는다 */
  overflow: visible;
  transition:
    height 0.25s ease,
    opacity 0.25s ease;
}
.site-topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.site-topbar a {
  color: inherit;
  opacity: 0.85;
}
.site-topbar a:hover {
  opacity: 1;
}
/* 테마 토글 등 topbar 버튼: hover 시에도 글자색은 유지하고 배경만 흐리게 */
.site-topbar .btn {
  color: inherit;
}
.site-topbar .btn:hover {
  background: rgb(127 127 127 / 0.35);
  color: inherit;
}

/* Topbar 언어 선택 드롭다운 (SVG 국기 포함) */
.locale-switcher {
  position: relative;
}
.locale-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: inherit;
  font: inherit;
  font-weight: 500;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
}
.locale-trigger:hover {
  background-color: rgb(127 127 127 / 0.35);
}
.locale-flag {
  display: block;
  width: 1.35rem;
  height: 0.9rem;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgb(127 127 127 / 0.4);
}
.locale-caret {
  width: 0;
  height: 0;
  border-left: 0.25rem solid transparent;
  border-right: 0.25rem solid transparent;
  border-top: 0.28rem solid currentColor;
}
.locale-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 8.5rem;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--popover);
  color: var(--popover-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 130;
}
.locale-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.locale-option:hover {
  background: var(--accent);
  opacity: 1;
}
.locale-option.is-active {
  font-weight: 600;
}

.site-header.is-condensed .site-topbar {
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.site-nav {
  background: var(--background);
  border-bottom: 1px solid var(--border);
  height: var(--header-nav-h);
}
.site-header.is-condensed .site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  box-shadow: var(--shadow);
  animation: nav-drop 0.2s ease;
}
@keyframes nav-drop {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 1.5rem;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.site-logo img {
  height: 2rem;
  width: auto;
}

.site-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-menu > li {
  position: relative;
}
.site-menu a {
  display: block;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--foreground);
}
.site-menu a:hover,
.site-menu a[aria-current="page"] {
  background: var(--accent);
  text-decoration: none;
}

.site-menu .submenu {
  position: absolute;
  /* 1차 점검: 부메뉴와의 간격을 없애 마우스 이동 중 닫히지 않게 함 */
  top: 100%;
  left: 0;
  min-width: 11rem;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.375rem;
  list-style: none;
  margin: 0;
  display: none;
  z-index: 60;
}
/* 데스크톱: hover/focus 로 서브메뉴 노출 (모바일 드로어에서는 클릭 아코디언만 사용) */
@media (min-width: 60.0625rem) {
  .site-menu li:hover > .submenu,
  .site-menu li:focus-within > .submenu {
    display: block;
  }
}
.site-menu .submenu a {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 400;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  color: var(--foreground);
}

/* 드로어 배경 (모바일에서만 노출) */
.nav-backdrop {
  display: none;
}
.site-menu-head {
  display: none;
}

@media (max-width: 60rem) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.375rem 0.625rem;
  }

  /* 1차 점검: 우측에서 열리는 드로어 메뉴 */
  .site-menu {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(20rem, 85vw);
    height: 100dvh;
    flex-direction: column;
    align-items: stretch;
    gap: 0.125rem;
    background: var(--popover);
    border-left: 1px solid var(--border);
    padding: 0.75rem;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    z-index: 80;
    transform: translateX(100%);
    visibility: hidden;
    transition:
      transform 0.25s ease,
      visibility 0s linear 0.25s;
  }
  .site-menu.is-open {
    transform: translateX(0);
    visibility: visible;
    transition:
      transform 0.25s ease,
      visibility 0s;
  }
  .site-menu > li > a {
    padding: 0.75rem 0.875rem;
    font-size: 1rem;
  }

  /* 드로어 상단: 홈 링크 + 닫기 버튼 (우측 상단) */
  .site-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
  }
  .site-menu-home {
    display: inline-flex;
    align-items: center;
  }
  .site-menu-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.75rem;
    line-height: 1;
    color: var(--foreground);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .site-menu-close:hover {
    background: var(--accent);
  }

  /* 서브메뉴: 닫힌 상태가 기본 (아코디언) */
  .site-menu .submenu {
    position: static;
    display: none;
    min-width: 0;
    border: none;
    box-shadow: none;
    background: var(--muted);
    margin-top: 0.25rem;
    padding: 0.25rem;
  }
  .site-menu li.is-open > .submenu {
    display: block;
  }
  .site-menu .submenu a {
    padding: 0.625rem 0.75rem;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 70;
  }
  .site-header.is-menu-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Hero ------------------------------------------------------------------ */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  color: #fff;
  background-color: #111;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgb(0 0 0 / 0.45) 0%,
    rgb(0 0 0 / 0.55) 100%
  );
}
.hero-inner {
  position: relative;
  width: 100%;
  padding-block: 6rem;
}
.hero-title {
  font-size: clamp(2.25rem, 6vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  text-shadow: 0 2px 16px rgb(0 0 0 / 0.35);
}
.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.375rem);
  opacity: 0.92;
  max-width: 40rem;
  margin-bottom: 2rem;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.35);
}
.hero-cta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.hero .btn-primary {
  background: #fff;
  color: #111;
}
.hero .btn-primary:hover {
  background: #e5e5e5;
}
.hero .btn-outline {
  border-color: rgb(255 255 255 / 0.6);
  color: #fff;
}
.hero .btn-outline:hover {
  background: rgb(255 255 255 / 0.12);
}

.hero-eyebrow {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  border: 1px solid rgb(255 255 255 / 0.45);
  border-radius: 9999px;
  background: rgb(255 255 255 / 0.12);
  backdrop-filter: blur(4px);
}

.hero-scroll {
  position: absolute;
  left: 1.25rem;
  bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.hero-scroll-line {
  display: inline-block;
  width: 2.5rem;
  height: 1px;
  background: rgb(255 255 255 / 0.8);
  animation: scroll-pulse 1.8s ease-in-out infinite;
}
@keyframes scroll-pulse {
  0%,
  100% {
    transform: scaleX(0.5);
    opacity: 0.5;
  }
  50% {
    transform: scaleX(1);
    opacity: 1;
  }
}

/* Sections -------------------------------------------------------------- */
.section {
  padding-block: 4rem;
}
.section-alt {
  background: var(--muted);
}
.section-title {
  margin-bottom: 0.5rem;
}
/* 섹션 타이틀 아래 강조 라인 */
.section-title::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  border-radius: 9999px;
  background: var(--primary);
  margin-top: 0.625rem;
}
.section-lead {
  color: var(--muted-foreground);
  max-width: 42rem;
  margin-bottom: 2rem;
}

/* 강점 카드 (홈) */
.feature-card {
  position: relative;
  overflow: hidden;
  padding-top: 2rem;
}
.feature-card h3 {
  margin-bottom: 0.5rem;
}
.feature-num {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: color-mix(in srgb, var(--foreground) 12%, transparent);
  line-height: 1;
}

/* CTA 밴드 */
.cta-band {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    color-mix(in srgb, var(--primary) 78%, var(--accent)) 100%
  );
  color: var(--primary-foreground);
  padding-block: 3.5rem;
  margin-top: 2rem;
}
.cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}
.cta-band h2 {
  font-size: clamp(1.375rem, 3vw, 1.875rem);
  margin-bottom: 0.375rem;
}
.cta-band p {
  margin: 0;
  opacity: 0.85;
}
.cta-band p.muted {
  color: inherit;
}
.cta-band .btn-primary {
  background: var(--background);
  color: var(--foreground);
}
.cta-band .btn-primary:hover {
  background: color-mix(in srgb, var(--background) 88%, var(--foreground));
}

/* Footer ---------------------------------------------------------------- */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-block: 3rem 2rem;
  margin-top: 4rem;
  font-size: 0.9375rem;
}
.site-footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.site-footer h4 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
}
.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.site-footer li {
  margin-bottom: 0.5rem;
}
.site-footer-bottom {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Board / post styles --------------------------------------------------- */
.board-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}
.post-list li {
  border-bottom: 1px solid var(--border);
}
.post-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 1rem;
  align-items: center;
  padding: 0.875rem 0.5rem;
}
.post-row:hover {
  background: var(--accent);
}
.post-row .post-title {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  font-weight: 500;
}
.post-row .post-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-comment-count {
  flex: none;
  color: var(--destructive);
  font-size: 0.8125rem;
  font-weight: 600;
}
.post-row .post-meta {
  color: var(--muted-foreground);
  font-size: 0.8125rem;
  white-space: nowrap;
}
.post-row.is-pinned .post-title::before {
  content: "공지";
  display: inline-block;
  background: var(--destructive);
  color: var(--destructive-foreground);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.0625rem 0.375rem;
  border-radius: 3px;
  margin-right: 0.5rem;
  vertical-align: middle;
}
@media (max-width: 48rem) {
  .post-row {
    grid-template-columns: 1fr auto;
  }
  .post-row .hide-sm {
    display: none;
  }
}

/* 앨범형(album) 게시판: 본문 첫 이미지를 카드로 보여주는 그리드 ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}
.post-card:hover {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
  transform: translateY(-2px);
}
.post-card-media {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--muted);
  overflow: hidden;
}
.post-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.875rem 1rem 1rem;
}
.post-card-title {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}
.post-card-title .badge {
  flex: none;
}
.post-card-title-text {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.post-card:hover .post-card-title-text {
  color: var(--primary);
}
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  color: var(--muted-foreground);
  font-size: 0.8125rem;
}

.post-view header {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.post-view h1 {
  font-size: clamp(1.375rem, 3vw, 1.875rem);
  margin-bottom: 0.5rem;
}
.post-view .post-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}
.post-body {
  line-height: 1.75;
  overflow-wrap: break-word;
}
/* 마크다운 렌더 본문: 단독 이미지는 원본(가운데정렬) 배치를 유지한다
   (sql migration 후 rich→markdown 전환 시 style 속성이 마크다운에 담기지 않으므로 CSS로 보존) */
.post-body--md p > img:only-child {
  display: block;
  margin: 0 auto;
}
.post-body--md p > a:only-child:has(> img:only-child) {
  display: block;
  text-align: center;
}
/* 리치 본문: 원본 보기 링크로 감싼 단독 이미지도 가운데 정렬을 유지한다
   (lexxy 는 a:has(img) 를 inline-block 으로 만들어 auto 마진이 먹지 않는다) */
.post-body p > a:only-child:has(> img:only-child) {
  display: block;
}
.post-body p > a:only-child:has(> img:only-child) > img {
  margin-inline: auto;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
}
.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  max-width: 45%;
}
.post-nav .label {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.post-nav .value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* 회원 아바타 (이름 앞 표시) --------------------------------------------- */
.user-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.user-label-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  display: inline-block;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 9999px;
  object-fit: cover;
  flex-shrink: 0;
  vertical-align: middle;
}
/* 아바타가 없는 회원: 이름 첫 글자 원형 대체 */
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-foreground);
  border: 1px solid var(--border);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
}

/* Comments -------------------------------------------------------------- */
.comments {
  margin-top: 3rem;
}
.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.comment {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.comment.reply {
  margin-left: 1.5rem;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
}
.comment-meta {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-bottom: 0.375rem;
}
.comment-meta .author {
  font-weight: 600;
  color: var(--foreground);
  font-size: 0.875rem;
}
.comment-body {
  font-size: 0.9375rem;
  overflow-wrap: break-word;
}
.comment-actions {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* Pagination-adjacent utils --------------------------------------------- */
.pager {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
}
.pager .pagy.series-nav,
.pager .pagination {
  justify-content: center;
  margin-top: 0;
}

/* 좋아요 버튼 (heart 색상 변경) ----------------------------------------- */
.btn-like {
  background: transparent;
  color: var(--muted-foreground);
  border-color: var(--border);
}
.btn-like:hover {
  background: var(--accent);
  color: var(--foreground);
}
.btn-like .heart {
  font-size: 1rem;
  line-height: 1;
}
.btn-like .like-count {
  font-variant-numeric: tabular-nums;
}
.btn-like.is-liked {
  color: var(--destructive);
  border-color: color-mix(in srgb, var(--destructive) 45%, transparent);
  background: color-mix(in srgb, var(--destructive) 10%, transparent);
}

/* 글 보기/댓글 폼 ------------------------------------------------------ */
.post-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.comment-form {
  margin-top: 0.75rem;
}
.comment-form textarea {
  min-height: 4rem;
}

/* Top 바로가기 --------------------------------------------------------- */
.to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0s linear 0.2s;
  z-index: 90;
}
.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0s;
}
.to-top:hover {
  background: var(--accent);
}

/* 팝업: 화면 상단 고정, 상단 이미지 + 하단 본문 ------------------------- */
dialog.popup {
  position: fixed;
  top: 1.25rem;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  width: min(26rem, calc(100vw - 2rem));
  max-width: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.popup::backdrop {
  background: rgb(0 0 0 / 0.45);
}
.popup-media {
  display: block;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
}
.popup-media img {
  width: 100%;
  height: auto;
  display: block;
}
.popup-body {
  padding: 1.25rem 1.375rem 1.375rem;
}
.popup-body h3 {
  font-size: 1.0625rem;
  margin-bottom: 0.5rem;
}
.popup-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

/* Admin ----------------------------------------------------------------- */
.admin-layout {
  display: grid;
  grid-template-columns: 15rem 1fr;
  min-height: 100vh;
}
.admin-sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.admin-sidebar .brand {
  font-weight: 700;
  font-size: 1.125rem;
  margin-bottom: 1.5rem;
  display: block;
}
.admin-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.admin-nav a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  color: var(--foreground);
}
.admin-nav a:hover {
  background: var(--accent);
  text-decoration: none;
}
.admin-nav a[aria-current="page"] {
  background: var(--primary);
  color: var(--primary-foreground);
}
.admin-main {
  padding: 2rem;
  min-width: 0;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.admin-header h1 {
  font-size: 1.5rem;
  margin: 0;
}

.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.stat-card .label {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

@media (max-width: 60rem) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .admin-main {
    padding: 1.25rem;
  }
}

/* ── 메뉴 설정: 서브메뉴 행 ─────────────────────────── */
.menu-card .sub-menu-row {
  background: color-mix(in srgb, var(--muted) 55%, transparent);
}
.sub-menu-row .field label {
  font-size: 0.8125rem;
}

/* 메뉴 목록 테이블: 접힌 편집 행/서브메뉴 행 */
table.table tr[hidden] {
  display: none;
}
table.table tr.menu-sub-row td {
  background: color-mix(in srgb, var(--muted) 40%, transparent);
}
table.table tr.menu-editor > td {
  background: var(--muted);
  padding: 1.5rem;
}
.menu-sub-label {
  padding-left: 1.75rem;
  color: var(--muted-foreground);
}
.menu-actions {
  white-space: nowrap;
}
.menu-actions form {
  display: inline;
}

.nowrap {
  white-space: nowrap;
}

/* ── 통계: 일별 막대 그래프 + 게시판별 비율 ───────────── */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  padding-top: 1.25rem; /* 막대 위 수치가 잘리지 않도록 */
}
.chart-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.chart-track {
  height: 8rem;
  display: flex;
  align-items: flex-end;
}
.chart-bar {
  position: relative;
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
  opacity: 0.85;
}
.chart-col:hover .chart-bar {
  opacity: 1;
}
.chart-value {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-bottom: 0.125rem;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.chart-date {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  text-align: center;
  white-space: nowrap;
}
.stat-bar {
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--muted);
  overflow: hidden;
}
.stat-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}
