:root {
  --bg: #e8e1d4;
  --panel: #f7f3eb;
  --panel-soft: #eee8dc;
  --text: #1f2521;
  --muted: #5f665f;
  --line: #d8cebc;
  --accent: #315b46;
  --accent-soft: rgba(49, 91, 70, 0.14);
  --shadow: 0 10px 24px rgba(13, 20, 17, 0.12);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Noto Serif KR", "Apple SD Gothic Neo", serif;
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(96, 126, 104, 0.15), transparent 56%),
    radial-gradient(900px 600px at 85% 0%, rgba(173, 146, 99, 0.12), transparent 56%),
    linear-gradient(180deg, #efe9dd 0%, #e5decf 55%, #ddd3c2 100%);
}

select,
input,
textarea,
button {
  font: inherit;
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(245, 241, 233, 0.95), rgba(237, 231, 220, 0.95));
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  background: linear-gradient(135deg, rgba(59, 111, 84, 0.12), rgba(199, 164, 107, 0.12));
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.brand:hover {
  transform: translateY(-1px);
  border-color: rgba(59, 111, 84, 0.26);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

.brand-mark,
.chip,
.nav-item .icon {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.brand-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, 0.75);
}

.nav-section-title {
  margin: 2px 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.nav-item {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover {
  background: rgba(49, 91, 70, 0.06);
  border-color: rgba(49, 91, 70, 0.12);
}

.nav-item.active {
  background: rgba(49, 91, 70, 0.12);
  border-color: rgba(49, 91, 70, 0.18);
}

.nav-item .icon {
  width: 18px;
  text-align: center;
}

.nav-item .nav-label {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-sub {
  margin-left: 8px;
  margin-top: 6px;
  padding-left: 10px;
  border-left: 1px dashed rgba(49, 91, 70, 0.2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-sub .nav-item {
  padding: 8px 10px;
  font-size: 12px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 6px;
}

.chip {
  display: inline-flex;
  width: max-content;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(49, 91, 70, 0.18);
  background: rgba(49, 91, 70, 0.08);
  font-size: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.main {
  min-width: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(241, 236, 227, 0.9);
  backdrop-filter: blur(8px);
}

.breadcrumbs {
  font-weight: 800;
  min-width: 0;
  overflow-wrap: anywhere;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.staff-user {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid rgba(49, 91, 70, 0.16);
  background: rgba(49, 91, 70, 0.06);
  padding: 7px 10px;
  border-radius: 999px;
}

.nav-btn {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.content {
  min-height: 0;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  overflow: visible;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  grid-column: span 12;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(247, 243, 235, 0.94);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0));
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(31, 41, 55, 0.14);
  border-color: rgba(59, 111, 84, 0.18);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.995);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card.fx-rise {
  animation: riseIn 0.28s ease both;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.kpi {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  font-size: 12px;
  border: 1px solid rgba(49, 91, 70, 0.14);
  background: rgba(49, 91, 70, 0.08);
  padding: 6px 10px;
  border-radius: 999px;
}

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

.home-tile {
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(59, 111, 84, 0.18);
  border-radius: 14px;
  padding: 12px;
  background: rgba(251, 248, 241, 0.84);
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.home-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(59, 111, 84, 0.28);
  background: rgba(255, 255, 255, 0.94);
}

.home-tile-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

.home-tile-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(247, 243, 235, 0.9);
}

.table th,
.table td {
  border-bottom: 1px solid rgba(231, 223, 209, 0.9);
  padding: 10px;
  text-align: left;
  font-size: 13px;
}

.table th {
  color: var(--muted);
  font-weight: 700;
}

.table tr td {
  transition: background-color 0.16s ease, color 0.16s ease;
}

.table tr:hover td {
  background: rgba(59, 111, 84, 0.06);
}

.post-board-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.post-card {
  border: 1px solid rgba(59, 111, 84, 0.16);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  display: grid;
  grid-template-rows: auto 1fr;
}

.post-card-media {
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: transparent;
  width: 100%;
  text-align: left;
}

.post-card-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
  background: rgba(49, 91, 70, 0.08);
}

.post-card-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid rgba(59, 111, 84, 0.1);
}

.post-card-body {
  padding: 10px;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.post-card-title-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
}

.post-card-title {
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.post-card-comment-count {
  color: #b31818;
  font-size: 12px;
  font-weight: 700;
}

.post-card-meta {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-card-stats {
  color: var(--text);
  font-size: 12px;
}

.post-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.post-card-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(31, 41, 55, 0.1);
  background: rgba(255, 255, 255, 0.75);
}

.badge.ok {
  border-color: rgba(47, 107, 79, 0.22);
  background: rgba(47, 107, 79, 0.1);
}

.badge.wait {
  border-color: rgba(202, 164, 106, 0.26);
  background: rgba(202, 164, 106, 0.12);
}

.badge.pause {
  border-color: rgba(107, 114, 128, 0.18);
  background: rgba(107, 114, 128, 0.08);
}

.badge.done {
  border-color: rgba(47, 107, 79, 0.22);
  background: rgba(139, 191, 122, 0.16);
}

.btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(31, 41, 55, 0.06);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.1);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(31, 41, 55, 0.08);
}

.btn-primary {
  border-color: rgba(49, 91, 70, 0.24);
  background: var(--accent-soft);
}

.btn-ghost {
  background: transparent;
  box-shadow: none;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.link-btn:hover {
  color: var(--accent);
  text-decoration: underline;
}

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

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pager {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btnTaskPage.active {
  background: rgba(59, 111, 84, 0.16);
  border-color: rgba(59, 111, 84, 0.26);
}

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

.field {
  grid-column: span 6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-wide {
  grid-column: span 12;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
#taskFilterSpace,
#taskFilterStatus,
#spacePicker {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(231, 223, 209, 0.9);
  background: rgba(251, 248, 242, 0.9);
  color: var(--text);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
#taskFilterSpace:focus,
#taskFilterStatus:focus,
#spacePicker:focus {
  border-color: rgba(49, 91, 70, 0.28);
  box-shadow: 0 0 0 3px rgba(49, 91, 70, 0.1);
}

.thumb-sm {
  width: 58px;
  height: 42px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(59, 111, 84, 0.16);
}

.thumb-md {
  width: 140px;
  height: 100px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(59, 111, 84, 0.18);
}

.post-detail {
  margin-top: 14px;
  border: 1px solid rgba(59, 111, 84, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  padding: 14px;
}

.post-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.post-detail-head h3 {
  margin: 0;
  font-size: 18px;
}

.post-detail-body {
  line-height: 1.75;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.post-detail-image-wrap {
  margin-top: 10px;
}

.post-detail-image {
  width: 100%;
  max-width: 560px;
  border-radius: 14px;
  border: 1px solid rgba(59, 111, 84, 0.16);
}

.post-comments {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed rgba(59, 111, 84, 0.2);
}

.post-comments h4 {
  margin: 0 0 8px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-item {
  border: 1px solid rgba(59, 111, 84, 0.14);
  background: rgba(251, 248, 242, 0.8);
  border-radius: 12px;
  padding: 10px;
}

.comment-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.comment-body {
  line-height: 1.7;
  font-size: 13px;
}

.comment-form {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.comment-form textarea {
  width: 100%;
  min-height: 88px;
  border-radius: 12px;
  border: 1px solid rgba(231, 223, 209, 0.9);
  background: rgba(251, 248, 242, 0.9);
  padding: 10px;
}

.current-image {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-editor {
  margin-top: 12px;
  border-top: 1px dashed rgba(59, 111, 84, 0.2);
  padding-top: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 41, 55, 0.35);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 90;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(720px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(59, 111, 84, 0.14);
  background: rgba(247, 243, 235, 0.98);
  box-shadow: 0 20px 40px rgba(31, 41, 55, 0.18);
}

.modal-header {
  padding: 14px 14px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  border-bottom: 1px solid rgba(231, 223, 209, 0.9);
}

.modal-title {
  font-weight: 800;
}

.modal-body {
  padding: 14px;
}

.modal-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    min-height: 100svh;
    min-height: 100dvh;
  }

  .nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .staff-user {
    max-width: 100%;
    order: -1;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    width: min(320px, 86vw);
    height: 100dvh;
    overflow-y: auto;
    padding-bottom: calc(20px + var(--safe-bottom));
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(31, 41, 55, 0.32);
    backdrop-filter: blur(2px);
    display: none;
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main {
    min-height: auto;
  }

  .content {
    padding: 12px 12px calc(18px + var(--safe-bottom));
  }

  .grid-cards {
    gap: 10px;
  }

  .card {
    border-radius: 14px;
    padding: 14px;
  }

  .table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table th,
  .table td {
    white-space: nowrap;
  }

  .field {
    grid-column: span 12;
  }

  .home-overview {
    grid-template-columns: 1fr;
  }

  .post-board-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #btnChangePassword,
  #btnExport,
  .staff-user,
  .sidebar-footer {
    display: none !important;
  }

  .kpi .pill:nth-child(n + 3) {
    display: none;
  }

  .post-detail .muted,
  .comment-meta {
    font-size: 11px;
  }

  .modal {
    width: min(720px, 96vw);
  }
}

@media (max-width: 420px) {
  .btn {
    padding: 8px 10px;
  }

  .breadcrumbs {
    font-size: 14px;
  }

  .nav-item {
    padding: 9px 10px;
  }

  .nav-section-title {
    font-size: 11px;
  }

  .post-board-grid {
    grid-template-columns: 1fr;
  }
}
