:root {
  --bg: #0a0e16;
  --bg-rail: #060911;
  --panel: #111826;
  --panel-soft: #161f30;
  --panel-hover: #1a2236;
  --text: #e7eef7;
  --muted: #8a9ab5;
  --muted-2: #6b7d99;
  --line: #1d2738;
  --line-strong: #2a384f;
  --up: #34d399;
  --down: #f87171;
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --accent-strong: #fbbf24;
  --info: #60a5fa;
  --danger: #ef4444;
  --bg-blur: rgba(17, 24, 38, 0.95);
  --center-max: 1280px;
  --sidebar-main: 248px;
  --sidebar-admin: 320px;
  --topnav-height: 56px;
  --radius: 8px;
  --radius-lg: 12px;
}

[data-theme="light"] {
  --bg: #faf6ee;
  --bg-rail: #f1ece0;
  --panel: #ffffff;
  --panel-soft: #f6f1e6;
  --panel-hover: #efe9d8;
  --text: #1f2433;
  --muted: #5a6577;
  --muted-2: #7a8597;
  --line: #e3dcc8;
  --line-strong: #c8c0a4;
  --up: #047857;
  --down: #b91c1c;
  --accent: #d97706;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --accent-strong: #ea580c;
  --info: #2563eb;
  --danger: #b91c1c;
  --bg-blur: rgba(250, 246, 238, 0.95);
}

body,
.topnav,
.sidebar,
.content,
.table-wrap,
.panel,
.admin-row,
.cat-row,
.text-input {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Pretendard", "Segoe UI", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  zoom: 1.25;
}

.market-body {
  min-height: 100vh;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

.page-frame {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
}

.main-stage {
  flex: 0 0 auto;
  width: min(var(--center-max), calc(100vw - 16px));
  max-width: var(--center-max);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  z-index: 1;
}

.edge-rail {
  flex: 1 1 0;
  min-width: 0;
  min-height: 100vh;
  background: linear-gradient(165deg, var(--bg-rail) 0%, #0a0e16 50%, #0c1220 100%);
}

/* ===== Top navigation ===== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topnav-height);
  padding: 0 22px;
  background: var(--bg-blur);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 16px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  background: url("./images/brand-mark.png") center / contain no-repeat;
  filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.35));
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
}

.topnav-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.topnav-link {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.topnav-link:hover {
  background: var(--panel-hover);
  color: var(--text);
}

.topnav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  cursor: default;
}

/* ===== Layout (sidebar + content) ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-main) 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px 12px;
}

.sidebar-section-label {
  margin: 4px 8px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* category chips */
.category-tabs {
  display: grid;
  gap: 2px;
}

.side-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.side-link:hover {
  background: var(--panel-hover);
}

.side-link.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.side-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.side-tab-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.side-tab-inner::after {
  content: "";
  width: 26px;
  flex-shrink: 0;
}

.tab-label {
  flex: 1;
  text-align: center;
}

.tab-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
}

.tab-label {
  flex: 1;
  line-height: 1.25;
  letter-spacing: -0.005em;
}

/* ===== Content ===== */
.content {
  padding: 22px 26px 40px;
  min-width: 0;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.content-title-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.content-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.content-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.content-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.last-updated {
  font-size: 12px;
  color: var(--muted-2);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.last-updated:empty {
  display: none;
}

.search-input {
  min-width: 200px;
  max-width: 360px;
  flex: 1 1 200px;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  transition: border 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
  color: var(--muted-2);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===== Table ===== */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}

thead th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
}

th.col-name {
  width: 50%;
}

th.col-price,
th.col-trend {
  text-align: right;
  width: 25%;
}

td.col-name,
.item-name-cell {
  text-align: left;
}

td:nth-child(2),
td:nth-child(3) {
  text-align: right;
}

.sort-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-btn:hover {
  color: var(--text);
}

.sort-btn.active {
  color: var(--text);
}

th.col-price .sort-btn,
th.col-trend .sort-btn {
  margin-left: auto;
}

th.col-name .sort-btn {
  /* left aligned */
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--panel-hover);
}

.item-name-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.item-name-block {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.item-cat-hint {
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.item-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 6px;
  background: var(--panel-soft);
  flex-shrink: 0;
}

.empty-row,
.empty-admin {
  color: var(--muted);
  text-align: center;
  padding: 32px 18px;
  font-size: 14px;
}

/* trend cell */
.recent3-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.sparkline {
  width: 72px;
  height: 22px;
  flex-shrink: 0;
}

.sparkline polyline {
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark-up {
  stroke: var(--up);
}

.spark-down {
  stroke: var(--down);
}

.sparkline-empty {
  color: var(--muted-2);
  font-size: 12px;
}

.change {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 56px;
  text-align: right;
}

.change.up {
  color: var(--up);
}

.change.down {
  color: var(--down);
}

td:nth-child(2) {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ===== Admin page ===== */
.admin-layout {
  grid-template-columns: var(--sidebar-admin) 1fr;
}

.admin-sidebar {
  padding: 18px 14px;
}

.admin-content {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.admin-content-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.admin-content-header .content-title-wrap {
  flex-wrap: wrap;
  align-items: flex-start;
}

.admin-content-header .content-count {
  font-size: 13px;
  font-weight: normal;
  color: var(--muted);
}

.admin-help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.admin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
}

.admin-panel h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.admin-rows {
  display: grid;
  gap: 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-form-items {
  grid-template-columns: 2fr 1fr auto;
}

.text-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 14px;
  transition: border 0.15s, box-shadow 0.15s;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.category-list {
  display: grid;
  gap: 6px;
}

.cat-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 8px;
}

.cat-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.cat-row-body {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 6px;
}

.cat-pick-btn {
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  padding: 4px 6px;
  font-weight: 600;
  font-size: 14px;
}

.cat-actions {
  display: inline-flex;
  gap: 4px;
}

.cat-move-btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--muted);
  border-radius: 6px;
  width: 26px;
  height: 24px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}

.cat-move-btn:hover:not(:disabled) {
  background: var(--panel-hover);
  color: var(--text);
}

.cat-move-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.tag-delete {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  font-size: 12px;
  padding: 3px 9px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tag-delete:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--danger);
  color: #fecaca;
}

.tag-delete:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Sprite picker */
.sprite-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sprite-picker--item {
  padding-top: 4px;
}

.sprite-picker-label {
  font-size: 11px;
  color: var(--muted-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sprite-picker-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 8px;
  padding: 3px 6px 3px 4px;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  line-height: 0;
}

.sprite-picker-toggle:hover {
  border-color: var(--accent);
  background: var(--panel-hover);
}

.sprite-picker-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.sprite-picker-toggle-img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 4px;
}

.sprite-picker .sprite-picker-toggle-img {
  width: 29px;
  height: 29px;
}

.sprite-picker--item .sprite-picker-toggle-img {
  width: 34px;
  height: 34px;
}

.sprite-picker-chev {
  font-size: 10px;
  line-height: 1;
  color: var(--muted-2);
  transition: transform 0.15s;
}

.sprite-picker-toggle[aria-expanded="true"] .sprite-picker-chev {
  transform: rotate(180deg);
  color: var(--accent);
}

.sprite-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: 280px;
  overflow-y: auto;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  animation: sprite-pop-in 0.12s ease-out;
}

@keyframes sprite-pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sprite-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sprite-pick-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.sprite-pick-btn {
  padding: 4px;
  margin: 0;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--panel);
  cursor: pointer;
  line-height: 0;
  transition: border-color 0.12s, transform 0.12s;
}

.sprite-pick-btn:hover {
  border-color: var(--line-strong);
}

.sprite-pick-btn.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.sprite-pick-btn img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 4px;
}

.sprite-pick-btn--inherit img {
  image-rendering: auto;
  opacity: 0.85;
}

.sprite-pick-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid var(--danger);
  color: #fecaca;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  z-index: 1;
  font-weight: 700;
}

.sprite-pick-del:hover {
  background: var(--danger);
  color: #fff;
}

.admin-sprite-wrap {
  padding-top: 4px;
}

.admin-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px;
  background: var(--panel-soft);
}

.admin-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-row h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-grid-item {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-span-2 {
  grid-column: 1 / -1;
}

.admin-grid label {
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 4px;
}

.admin-grid input,
.admin-grid select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 14px;
}

.admin-grid input:focus,
.admin-grid select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 8px;
}

.delete-item-btn {
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.12s;
}

.delete-item-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

.save-btn {
  margin-top: 0;
  border: none;
  background: var(--accent);
  color: #1a1208;
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: background 0.15s, transform 0.05s;
}

.save-btn:hover {
  background: var(--accent-strong);
}

.save-btn:active {
  transform: translateY(1px);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.secondary-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.secondary-btn:hover {
  background: var(--panel-hover);
}

.save-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--up);
  font-weight: 600;
  font-size: 13px;
}

/* ===== Login screen ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(800px 500px at 50% 20%, rgba(245, 158, 11, 0.08) 0%, transparent 70%),
    linear-gradient(180deg, #06090f 0%, #0a0e16 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 12px;
}

.login-mark {
  width: 96px;
  height: 96px;
  margin: 4px auto 6px;
  background: url("./images/brand-mark.png") center / contain no-repeat;
  filter: drop-shadow(0 6px 20px rgba(245, 158, 11, 0.35));
}

.login-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.login-subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.login-remember input {
  cursor: pointer;
}

.login-submit {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
}

.login-submit:disabled {
  opacity: 0.7;
  cursor: progress;
}

.login-message {
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  color: var(--down);
  font-weight: 500;
}

.login-back {
  display: inline-block;
  margin: 4px auto 0;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 4px;
}

.login-back:hover {
  color: var(--text);
  background: var(--panel-hover);
}

/* logout button styled like topnav-link */
.topnav-link--button {
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

.topnav-link--icon {
  width: 32px;
  padding: 0;
  justify-content: center;
  color: var(--muted);
}

.topnav-link--icon:hover {
  color: var(--accent);
}

.topnav-link--donate {
  gap: 5px;
  color: var(--accent-strong);
  border: 1px solid transparent;
  font-weight: 600;
}

.topnav-link--donate:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.donate-heart {
  display: block;
}

/* 우하단 플로팅 후원 버튼 */
.donate-floating {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #1a1208;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35), 0 0 0 1px rgba(245, 158, 11, 0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.donate-floating:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(245, 158, 11, 0.5), 0 0 0 1px rgba(245, 158, 11, 0.5);
}

.donate-floating:active {
  transform: translateY(0);
}

.donate-floating svg {
  display: block;
}

.donate-floating-label {
  letter-spacing: 0.02em;
}

.theme-icon {
  width: 18px;
  height: 18px;
  display: none;
}

[data-theme="dark"] .theme-icon--sun {
  display: block;
}

[data-theme="light"] .theme-icon--moon {
  display: block;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .page-frame {
    flex-direction: column;
  }

  .edge-rail {
    display: none;
  }

  .main-stage {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  /* 메인 사이드바 → 가로 스크롤 칩 + topnav 아래 sticky */
  .layout > .sidebar:not(.admin-sidebar) {
    position: sticky;
    top: var(--topnav-height);
    z-index: 5;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    background: var(--bg-blur);
    backdrop-filter: saturate(160%) blur(8px);
  }

  .layout > .sidebar:not(.admin-sidebar) .sidebar-section-label {
    display: none;
  }

  .layout > .sidebar:not(.admin-sidebar) .category-tabs {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 2px 2px 6px;
    margin: 0 -2px;
  }

  .layout > .sidebar:not(.admin-sidebar) .side-link {
    flex-shrink: 0;
    width: auto;
    padding: 7px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--panel-soft);
  }

  .layout > .sidebar:not(.admin-sidebar) .side-link.active {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .layout > .sidebar:not(.admin-sidebar) .side-link.active::before {
    display: none;
  }

  .layout > .sidebar:not(.admin-sidebar) .side-tab-inner {
    gap: 8px;
    width: auto;
  }

  .layout > .sidebar:not(.admin-sidebar) .side-tab-inner::after {
    display: none;
  }

  .layout > .sidebar:not(.admin-sidebar) .tab-label {
    flex: 0 0 auto;
    text-align: left;
  }

  .layout > .sidebar:not(.admin-sidebar) .tab-icon {
    width: 22px;
    height: 22px;
  }

  /* 관리자 사이드바는 세로 그대로 (편집 UI 들어있음) */
  .admin-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }
}

@media (max-width: 640px) {
  .topnav {
    padding: 0 14px;
    height: 52px;
  }

  :root {
    --topnav-height: 52px;
  }

  .brand {
    font-size: 15px;
    gap: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .topnav-link {
    height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }

  /* 관리자 페이지에서 "시세 보기"는 brand 클릭과 중복이라 숨김 */
  #goMainLink {
    display: none;
  }

  .content {
    padding: 16px 14px 28px;
  }

  .content-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .content-title {
    font-size: 20px;
  }

  .content-title-wrap {
    align-items: baseline;
  }

  .content-header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .last-updated {
    text-align: right;
  }

  .search-input {
    max-width: none;
    width: 100%;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form-items {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form-items > button {
    grid-column: 1 / -1;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  /* 테이블 컴팩트 */
  th,
  td {
    font-size: 13px;
    padding: 10px 12px;
  }

  .item-icon {
    width: 32px;
    height: 32px;
    border-radius: 5px;
  }

  .item-name-row {
    gap: 9px;
  }

  .sparkline {
    width: 56px;
    height: 20px;
  }

  .recent3-cell {
    gap: 8px;
  }

  .change {
    font-size: 12px;
    min-width: 44px;
  }

  /* 로그인 카드 */
  .login-card {
    padding: 22px 18px 18px;
    border-radius: 12px;
  }

  /* 관리자 액션 버튼 줄바꿈 친화적 */
  .admin-actions {
    gap: 6px;
  }

  .admin-actions .save-btn {
    flex: 1 1 auto;
    text-align: center;
  }

  /* 모바일에서는 플로팅 후원 버튼을 작게 */
  .donate-floating {
    bottom: 16px;
    right: 16px;
    padding: 10px 14px;
    font-size: 13px;
    gap: 6px;
  }
}
