/* Front shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-header-inner {
  height: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--fw-bold);
  font-size: var(--text-md);
  color: var(--color-navy);
  white-space: nowrap;
  min-width: 0;
  max-width: 11.25rem; /* 180px */
}

.brand-link:hover {
  color: var(--color-navy);
}

.brand-logo {
  display: block;
  height: 2.75rem; /* 44px */
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  background: var(--color-navy);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
}

.header-search {
  max-width: 520px;
  width: 100%;
  justify-self: center;
}

.header-search .form-control {
  min-height: 2.35rem;
  border-color: var(--color-border);
}

.header-search .form-control:focus {
  border-color: var(--color-accent);
}

.header-nav {
  display: none;
  align-items: center;
  gap: var(--space-1);
}

.header-nav a {
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
}

.header-nav a:hover,
.header-nav a.is-active {
  color: var(--color-navy);
  background: var(--color-bg);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-self: end;
}

.user-chip {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  font-size: var(--text-sm);
  color: var(--color-navy);
}

.user-chip-role {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.menu-toggle {
  display: inline-flex;
}

.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

.app-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: min(var(--sidebar-w), 88vw);
  z-index: 35;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  transform: translateX(-105%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-sidebar.is-open {
  transform: translateX(0);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(27, 42, 74, 0.35);
  z-index: 30;
}

.sidebar-backdrop.is-visible {
  display: block;
}

.sidebar-head {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.sidebar-head h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--color-navy);
  letter-spacing: 0.01em;
}

.sidebar-scroll {
  flex: 1;
  overflow: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
}

.app-main {
  min-width: 0;
  padding: var(--space-4) var(--space-4) var(--space-6);
}

.app-main-inner {
  max-width: var(--max-content);
  margin: 0 auto;
}

.page-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
}

.article-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 var(--space-2);
}

.article-title-row .page-title {
  margin: 0;
  min-width: 0;
  flex: 1;
}

.article-edit-btn {
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.page-lead {
  margin: 0 0 var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Tree */
.tree-filter {
  margin: 0;
  min-height: 2.15rem;
  font-size: var(--text-sm);
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Nest by indent only — no guide lines */
.tree ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 23px;
  border: 0;
  border-left: 0;
}

.tree-item {
  margin: 0.05rem 0;
}

.tree-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  width: auto;
  min-width: 0;
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  font-size: var(--text-sm);
  box-sizing: border-box;
}

.tree-row:hover {
  background: var(--color-bg);
}

.tree-row.is-active {
  background: var(--color-accent-soft);
  color: var(--color-navy);
  font-weight: var(--fw-semibold);
}

.tree-row.is-active .tree-icon {
  color: var(--color-accent);
}

.tree-toggle {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
  cursor: pointer;
}

.tree-toggle:hover {
  background: rgba(27, 42, 74, 0.06);
  color: var(--color-navy);
}

.tree-toggle-spacer {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.tree-toggle .icon {
  transition: transform 0.12s ease;
}

.tree-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.tree-item.is-collapsed > .tree-children {
  display: none;
}

.tree-item.is-collapsed > .tree-row .tree-toggle .icon {
  transform: rotate(-90deg);
}

.tree-label {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-meta {
  margin-left: 0.35rem;
  max-width: 42%;
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-meta.badge {
  border-color: var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
  padding: 0.1rem 0.35rem;
}

.tree-leaf {
  padding-left: 0.5rem;
}

.tree-empty {
  padding: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.detail-meta {
  margin: 0;
  display: grid;
  gap: var(--space-3);
}

.detail-meta > div {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: var(--space-2);
  align-items: start;
  font-size: var(--text-sm);
}

.detail-meta dt {
  margin: 0;
  color: var(--color-text-muted);
  font-weight: var(--fw-medium);
}

.detail-meta dd {
  margin: 0;
  color: var(--color-navy);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-related-section {
  margin-top: var(--space-5);
}

.tree-related-count {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.tree-related-empty {
  background: var(--color-surface);
}

.tree-related-list {
  margin-top: 0;
}

.tree-feed-status {
  margin: 0 0 var(--space-3);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.tree-feed-status--loading {
  color: var(--color-text-muted);
}

.tree-feed-status--error {
  color: #8a1f1f;
  border-color: #e2b6b6;
  background: #fdf5f5;
}

/* Home — article cards (do not alter shared .panel) */
.home-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.home-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.home-section-copy {
  min-width: 0;
  flex: 1;
}

.home-section-copy .page-lead {
  margin: var(--space-1) 0 0;
}

.home-section-action {
  flex-shrink: 0;
  align-self: center;
}

.home-empty {
  padding: var(--space-5);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.home-empty .empty-state-title,
.home-empty .empty-state-text {
  margin: 0;
}

.home-empty .empty-state-text {
  margin-top: var(--space-2);
}

.home-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.article-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.article-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.article-card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow);
  color: inherit;
}

.article-card:hover .article-card-title {
  color: var(--color-navy);
}

.article-card:hover .article-card-arrow {
  color: var(--color-accent);
}

.article-card-body {
  min-width: 0;
  flex: 1;
}

.article-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.article-card-type {
  background: var(--color-accent-soft);
  border-color: #b7e0e0;
  color: var(--color-accent);
}

.article-card-aux {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.article-card-title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--fw-semibold);
  color: var(--color-navy);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.article-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.article-card-meta span:not(:last-child)::after {
  content: "·";
  margin: 0 0.5rem;
  color: var(--color-border-strong);
}

.article-card-tags {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-card-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-4);
  background: var(--color-bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo {
  display: block;
  width: 150px;
  max-width: min(170px, 72vw);
  height: auto;
  margin: 0 auto 1rem;
}

.auth-brand h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-navy);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.auth-brand-sub {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

@media (max-width: 480px) {
  .auth-shell {
    padding: 1.25rem 1rem;
    align-items: flex-start;
    padding-top: 2rem;
  }

  .auth-logo {
    width: 130px;
    margin-bottom: 0.85rem;
  }

  .auth-brand {
    margin-bottom: 1.15rem;
  }

  .auth-brand h1 {
    font-size: 1.2rem;
  }
}

.home-grid {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 900px) {
  .home-grid {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }

  .home-primary {
    grid-column: 1 / -1;
  }
}

@media (min-width: 992px) {
  .menu-toggle {
    display: none;
  }

  .header-nav {
    display: flex;
  }

  .user-chip {
    display: inline-flex;
  }

  .app-body {
    grid-template-columns: var(--sidebar-w) 1fr;
  }

  .app-sidebar {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    transform: none;
    z-index: 1;
  }

  .sidebar-backdrop {
    display: none !important;
  }

  .app-header-inner {
    padding: 0 var(--space-5);
  }

  .app-main {
    padding: var(--space-5) var(--space-5) var(--space-7);
  }
}

@media (max-width: 991px) {
  .app-header-inner {
    grid-template-columns: auto auto 1fr auto;
  }

  .brand-link {
    max-width: 10rem; /* 160px */
  }

  .brand-logo {
    height: 2.625rem; /* 42px */
  }

  .header-search {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
    padding-bottom: var(--space-3);
    display: none;
  }

  .app-header.has-mobile-search {
    height: auto;
    min-height: var(--header-h);
  }

  .app-header.has-mobile-search .app-header-inner {
    padding-top: var(--space-2);
  }

  .app-header.has-mobile-search .header-search {
    display: flex;
  }

  .home-section-action {
    width: 100%;
    text-align: center;
  }
}

/* ===== Board (전체 기술자료) ===== */
.board-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.board-head-copy {
  min-width: 0;
  flex: 1;
}

.board-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.board-filters .board-q {
  flex: 1 1 12rem;
  min-width: 10rem;
  max-width: 22rem;
}

.board-filter-select {
  flex: 0 1 10rem;
  min-width: 8rem;
}

.board-count {
  margin: 0;
}

.board-table-wrap {
  width: 100%;
  overflow-x: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.board-table th,
.board-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  font-size: var(--text-sm);
}

.board-table th {
  text-align: left;
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  background: var(--color-bg);
}

.board-table tbody tr:last-child td {
  border-bottom: 0;
}

.board-table .col-no {
  width: 4.5rem;
  color: var(--color-text-muted);
}

.board-table .col-scope {
  width: 18%;
}

.board-table .col-type {
  width: 12%;
}

.board-table .col-title {
  width: auto;
}

.board-table .col-author {
  width: 6.5rem;
}

.board-table .col-date {
  width: 6.5rem;
  white-space: nowrap;
  color: var(--color-text-muted);
}

.board-table .col-actions {
  width: 7.25rem;
  text-align: right;
}

.board-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
  align-items: center;
}

.board-delete-form {
  display: inline;
  margin: 0;
}

.board-delete-btn {
  border: 1px solid #c9a3a0;
  background: #fff;
  color: #9b2c2c;
}

.board-delete-btn:hover {
  background: #fdf2f2;
  color: #7f1d1d;
}

.board-title-link {
  display: block;
  color: var(--color-navy);
  text-decoration: none;
  font-weight: var(--fw-semibold);
  min-height: 2.75rem;
  padding: 0.35rem 0;
}

.board-title-link:hover .board-title-text {
  text-decoration: underline;
}

.board-title-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: 1.4;
  word-break: break-word;
}

.board-meta-mobile {
  display: none;
}

.board-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
  margin-top: var(--space-2);
}

.board-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--text-sm);
}

.board-page.is-current {
  background: var(--color-navy);
  border-color: var(--color-navy);
  color: #fff;
  font-weight: var(--fw-semibold);
}

.board-page.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.board-create-bottom {
  display: none;
  margin-top: var(--space-2);
}

@media (max-width: 860px) {
  .board-create-btn {
    display: none;
  }

  .board-create-bottom {
    display: block;
  }

  .board-create-bottom .btn {
    width: 100%;
    min-height: 2.75rem;
  }

  .board-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .board-filters .board-q,
  .board-filter-select,
  .board-filters .btn {
    max-width: none;
    width: 100%;
    min-height: 2.5rem;
  }

  .board-table thead {
    display: none;
  }

  .board-table,
  .board-table tbody,
  .board-table tr,
  .board-table td {
    display: block;
    width: 100%;
  }

  .board-table tr {
    position: relative;
    padding: 0.85rem 0.85rem 0.85rem 3.4rem;
    border-bottom: 1px solid var(--color-border);
  }

  .board-table tbody tr:last-child {
    border-bottom: 0;
  }

  .board-table td {
    border: 0;
    padding: 0;
  }

  .board-table .col-no {
    position: absolute;
    left: 0.75rem;
    top: 0.95rem;
    width: auto;
    font-size: var(--text-sm);
  }

  .board-table .col-scope,
  .board-table .col-type,
  .board-table .col-author,
  .board-table .col-date {
    display: none;
  }

  .board-table .col-title {
    width: 100%;
  }

  .board-table .col-actions {
    display: block;
    width: 100%;
    text-align: left;
    margin-top: 0.55rem;
  }

  .board-row-actions {
    justify-content: flex-start;
  }

  .board-row-actions .btn {
    min-height: 2rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.8125rem;
  }

  .board-title-link {
    min-height: 3.25rem;
    padding: 0;
  }

  .board-title-text {
    font-size: 1rem;
  }

  .board-meta-mobile {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    font-weight: var(--fw-regular, 400);
    color: var(--color-text-muted);
    line-height: 1.4;
  }
}

