:root {
  --toolbar-height: 72px;
  --header-offset: 0px;
  --sidebar-width: 240px;
  --footer-height: 64px;
  --footer-spacing: 32px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans KR, Helvetica, Arial, Apple SD Gothic Neo, Malgun Gothic, sans-serif;
  background: #f7f7f9;
  color: #222;
  padding-bottom: var(--footer-spacing);
}

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

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0;
  width: 100%;
  padding: 0;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: flex-start;
  box-sizing: border-box;
}

.toolbar-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 0 16px;
  margin: 0;
}

.toolbar button {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar button:hover {
  background: #f3f4f6;
}

.toolbar .mode-btn.active {
  background: #111827;
  color: #fff;
  border-color: #111827;
}

.toolbar .material-icons,
.toolbar .material-symbols-outlined {
  font-size: 14px;
  line-height: 1;
}

.column-grade-icon {
  color: #10b981;
  font-size: 18px;
  line-height: 1;
  vertical-align: middle;
  display: inline-flex;
}

main {
  margin: 0;
  padding: 0 24px calc(var(--footer-spacing) + 24px) 0;
  position: relative;
  min-height: calc(100vh - var(--toolbar-height));
  display: flex;
  align-items: flex-start;
  gap: 0;
  background: #ffffff;
  box-sizing: border-box;
}

.workspace {
  flex: 1;
  min-width: 0;
  background: #ffffff;
  padding: 0 24px 24px 0;
  box-sizing: border-box;
}

body.sidebar-collapsed main {
  padding-left: 24px;
}

body.sidebar-collapsed .workspace {
  width: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 0;
  box-sizing: border-box;
  position: sticky;
  top: calc(var(--header-offset) + var(--toolbar-height));
  align-self: flex-start;
  overflow: visible;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

body.header-condensed .sidebar {
  top: var(--toolbar-height);
}

body.sidebar-collapsed .sidebar {
  display: none;
}

.common-footer {
  margin: 0;
}

.folder-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.folder-card {
  border: none;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 0;
  padding: 12px;
  margin: 0;
}

.folder-card:last-child {
  border-bottom: none;
}

.folder-card.default {
  border-bottom: 1px solid #2563eb;
  background: #eff6ff;
}

.folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
}

.folder-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.folder-toggle {
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
}

.folder-toggle:hover {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.08);
}

.folder-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.folder-edit-button {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  font-size: 11px;
  color: #374151;
  cursor: pointer;
  transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.folder-edit-button:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.folder-card:hover .folder-edit-button,
.folder-edit-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
}


.file-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.file-list.collapsed {
  display: none;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  transition: background 0.2s ease;
}

.file-row:hover {
  background: #f9fafb;
}

.file-row:last-of-type {
  border-bottom: none;
}

.file-row.active {
  background: #f0f7ff;
  border-radius: 8px;
}

.file-row.empty {
  cursor: default;
  color: #9ca3af;
  border-bottom: none;
}

.file-create-button {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px dashed #cbd5f5;
  background: #f8fbff;
  color: #2563eb;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.file-create-button:hover {
  background: #e0ecff;
  border-color: #93c5fd;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.file-primary {
  font-size: 13px;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-secondary {
  font-size: 11px;
  color: #6b7280;
}

.file-secondary.has-date::before {
  content: '\00B7';
  margin-right: 6px;
  color: #d1d5db;
}

.file-secondary.no-date::before {
  content: '';
}

.file-meta {
  font-size: 12px;
  color: #6b7280;
  padding: 12px 0;
}

.tabulator .tabulator-cell.wrap-text-cell {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: initial;
  word-break: break-word;
  line-height: 1.4;
}

.tabulator .tabulator-cell.similarity-metric-cell {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-end;
  text-align: right;
}

.tables-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tables-container {
  overflow: visible;
  width: 100%;
}

.table-empty {
  border: 1px dashed #cbd5f5;
  background: #f8fbff;
  color: #2563eb;
  padding: 20px;
  border-radius: 12px;
  font-size: 13px;
  text-align: center;
}

.table-section {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  padding: 52px 18px 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  scroll-margin-top: calc(var(--header-offset, 0px) + var(--toolbar-height, 0px) + 8px);
  --table-body-height: auto;
}

.table-section:hover {
  border-color: #cbd5f5;
}

.table-section.active {
  border-color: #e5e7eb;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.table-section-header {
  position: sticky;
  top: calc(var(--header-offset, 0px) + var(--toolbar-height, 0px) - 1px);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -52px -18px 16px;
  padding: 14px 18px 12px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 12px 24px -18px rgba(15, 23, 42, 0.32);
}

body.header-condensed .table-section {
  scroll-margin-top: calc(var(--toolbar-height, 0px) + 6px);
}

body.header-condensed .table-section-header {
  top: calc(var(--toolbar-height, 0px) - 1px);
}

.table-section-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.table-section-order {
  font-size: 12px;
  color: #2563eb;
  background: #e0ecff;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 500;
  white-space: nowrap;
}

.table-section-body {
  margin-top: 0;
  min-height: var(--table-body-height, auto);
  background-color: #fff;
}

.file-meta {
  font-size: 11px;
  color: #6b7280;
}

.table-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.table-tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 9999px;
  background: #e5e7eb;
  color: #374151;
}

.table-tag.active {
  background: #2563eb;
  color: #fff;
}

.table-section-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-auto-wrap-btn {
  font-weight: 600;
  color: #4338ca;
  background: #eef2ff;
  border-color: #c7d2fe;
}

.table-auto-wrap-btn:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #312e81;
}

.table-row-btn,
.table-edit-btn,
.table-answer-btn,
.table-save-btn,
.table-move-btn,
.table-delete-btn {
  padding: 6px 10px;
  border-radius: 9999px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.table-row-btn:hover,
.table-edit-btn:hover,
.table-answer-btn:hover,
.table-save-btn:hover,
.table-move-btn:hover,
.table-delete-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.table-row-btn:focus-visible,
.table-edit-btn:focus-visible,
.table-answer-btn:focus-visible,
.table-save-btn:focus-visible,
.table-move-btn:focus-visible,
.table-delete-btn:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.table-edit-btn {
  font-weight: 500;
  color: #2563eb;
}

.table-answer-btn {
  font-weight: 500;
  color: #047857;
}

.table-save-btn {
  font-weight: 500;
  color: #374151;
}

.table-move-btn {
  font-weight: 500;
  color: #0f766e;
}

.table-delete-btn {
  font-weight: 500;
  color: #b91c1c;
}

.table-edit-btn:hover {
  color: #1d4ed8;
  border-color: #2563eb;
}

.table-save-btn[data-state="dirty"] {
  color: #065f46;
  border-color: #34d399;
}

.table-save-btn[data-state="dirty"]:hover,
.table-save-btn[data-state="dirty"]:focus-visible {
  color: #047857;
  border-color: #10b981;
}

.table-save-btn[data-state="saving"] {
  color: #1f2937;
  border-color: #9ca3af;
}

.table-move-btn:hover,
.table-move-btn:focus-visible {
  color: #0d9488;
  border-color: #14b8a6;
}

.table-delete-btn:hover,
.table-delete-btn:focus-visible {
  color: #dc2626;
  border-color: #f87171;
}

.table-save-btn:disabled {
  cursor: default;
  opacity: 0.6;
  color: #6b7280;
  border-color: #d1d5db;
  background: #f9fafb;
}

.table-save-btn:disabled[data-state="saving"] {
  color: #1f2937;
  border-color: #9ca3af;
  background: #f3f4f6;
}

#table {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 0 24px 24px;
  z-index: calc(var(--header-z-max, 2147483647) + 1);
  overflow-y: auto;
}

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

.modal-backdrop.open .modal {
  margin-top: 0;
}

@media (max-width: 720px) {
  .modal-backdrop {
    padding: 0 12px 16px;
  }
}

.modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
  position: relative;
  padding: 24px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
}

.modal-close:hover {
  color: #111827;
}

.modal-form h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.modal-description {
  margin: 0 0 12px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #374151;
}

.modal-field-label {
  font-weight: 600;
  color: #1f2937;
  font-size: 13px;
}

.modal-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 4px 0 8px;
}

.modal-select-all-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid #2563eb;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: #1f2937;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.24s ease, background 0.24s ease;
}

.modal-select-all-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
}

.modal-select-all-btn:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.65);
  outline-offset: 3px;
}

.modal-select-all-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.modal-field input[type="text"],
.modal-field input[type="file"],
.modal-field select,
.row-move-block select {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.modal-select-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 0;
  margin-bottom: 12px;
  background: #f9fafb;
}

.modal-select-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
  border-bottom: 1px solid #e5e7eb;
}

.modal-select-item:last-child {
  border-bottom: none;
}

.modal-select-item input[type="checkbox"] {
  margin-top: 3px;
}

.modal-select-item .modal-select-item-label {
  color: #374151;
  flex: 1;
  word-break: break-word;
}

.modal-select-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  max-height: 180px;
  overflow-y: auto;
  font-size: 13px;
}

.modal-select-summary .modal-select-summary-item {
  color: #374151;
  line-height: 1.4;
}

.row-move-flex-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.row-move-modal {
  max-width: 900px;
  width: min(95vw, 900px);
}

.row-move-block {
  flex: 1 1 200px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row-move-preview-block {
  flex: 1 1 260px;
  min-width: 260px;
}

.row-move-block select {
  width: 100%;
}

.row-move-preview {
  min-height: 120px;
  max-height: 240px;
  overflow-y: auto;
}

@media (max-width: 960px) {
  .row-move-flex-group {
    flex-direction: column;
  }

  .row-move-block {
    min-width: 0;
  }
}

.legacy-import-modal {
  width: min(95vw, 960px);
  max-width: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(20px, 4vw, 32px);
  padding-top: clamp(24px, 5vw, 36px);
  padding-bottom: clamp(20px, 4vw, 32px);
  max-height: calc(100vh - clamp(64px, 12vh, 120px));
  overflow: hidden;
}

@media (min-width: 1024px) {
  .legacy-import-modal {
    width: min(70vw, 1080px);
  }
}

@media (min-width: 1440px) {
  .legacy-import-modal {
    width: min(70vw, 1200px);
  }
}

.modal-backdrop.legacy-top {
  align-items: flex-start;
  justify-content: center;
  padding-top: 0;
  padding-bottom: clamp(16px, 4vh, 48px);
}

.legacy-modal-title {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legacy-modal-title .legacy-import-warning {
  font-size: 13px;
  font-weight: 600;
  color: #dc2626;
  line-height: 1.5;
}

.legacy-modal-description {
  margin: 0 0 16px;
  font-size: 13px;
  color: #4b5563;
}

.legacy-import-modal .modal-steps {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.legacy-import-modal .legacy-step {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.legacy-category-list {
  flex: 1 1 auto;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  margin: 0 0 16px;
  background: #f9fafb;
  text-align: left;
  font-size: 13px;
  line-height: 1.5;
  color: #1f2937;
  min-height: 0;
}

.legacy-category-item {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 8px;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.legacy-category-item:last-child {
  margin-bottom: 0;
}

.legacy-category-item.expanded {
  border-color: #2563eb;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.1);
}

.legacy-category-empty,
.legacy-category-loading {
  padding: 24px 12px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

.legacy-category-name {
  font-weight: 600;
  color: #111827;
  margin-bottom: 2px;
}

.legacy-category-meta {
  font-size: 12px;
  color: #6b7280;
}

.legacy-toggle-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 6px;
  margin-left: auto;
}

.legacy-toggle-btn:hover {
  text-decoration: underline;
}

.legacy-category-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legacy-container-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legacy-container-item {
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #f3f4f6;
  padding: 10px 12px;
}

.legacy-container-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.legacy-container-title {
  font-weight: 600;
  color: #1f2937;
  word-break: break-word;
}

.legacy-container-meta {
  font-size: 12px;
  color: #6b7280;
}

.legacy-container-empty {
  padding: 12px;
  font-size: 12px;
  color: #6b7280;
}

.legacy-row-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legacy-row-item {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
}

.legacy-row-question {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
  word-break: break-word;
}

.legacy-row-answer {
  font-size: 12px;
  color: #374151;
  line-height: 1.4;
  margin-top: 2px;
  word-break: break-word;
}

.legacy-row-meta {
  margin-top: 4px;
  font-size: 11px;
  color: #6b7280;
}

.legacy-row-empty {
  font-size: 12px;
  color: #6b7280;
}

@media (max-width: 768px) {
  .legacy-import-modal {
    width: min(96vw, 640px);
    max-height: calc(100vh - 80px);
  }
}

.legacy-modal-error {
  min-height: 18px;
  margin: 0 0 12px;
  font-size: 12px;
  color: #dc2626;
}

.legacy-actions {
  display: flex;
  justify-content: center;
  gap: 0;
}

.legacy-confirm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 184px;
  padding: 12px 28px;
  border: 1px solid #2563eb;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  background: linear-gradient(135deg, #f8fafc 0%, #dbeafe 100%);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.14);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.24s ease, background 0.24s ease;
}

.legacy-confirm:disabled {
  cursor: not-allowed;
  opacity: 0.9;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.12);
}

.legacy-confirm:not(:disabled):hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #eff6ff 0%, #bfdbfe 100%);
  box-shadow: 0 20px 36px rgba(37, 99, 235, 0.2);
}

.legacy-confirm:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 3px;
}

.legacy-confirm-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.legacy-confirm-icon::before {
  content: '';
  width: 8px;
  height: 12px;
  border-right: 2px solid #1d4ed8;
  border-bottom: 2px solid #1d4ed8;
  transform: rotate(45deg);
  margin-top: -1px;
}

.legacy-confirm-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legacy-confirm-pending {
  display: none;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.legacy-confirm-pending-label {
  font-size: 13px;
}

.legacy-confirm-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid rgba(59, 130, 246, 0.25);
  border-top-color: #2563eb;
  animation: legacy-confirm-spin 0.9s linear infinite;
}

.legacy-confirm.is-pending {
  cursor: progress;
}

.legacy-confirm.is-pending .legacy-confirm-text {
  display: none;
}

.legacy-confirm.is-pending .legacy-confirm-pending {
  display: inline-flex;
}

@keyframes legacy-confirm-spin {
  to {
    transform: rotate(360deg);
  }
}

.table-order-block {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.table-order-heading {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.table-order-helper {
  margin: 0;
  font-size: 11px;
  color: #6b7280;
}

.table-order-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-order-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  cursor: grab;
}

.table-order-item.dragging {
  opacity: 0.6;
}

.table-order-item:active {
  cursor: grabbing;
}

.table-order-item.is-active {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.table-order-item.drag-over {
  border-color: #2563eb;
  background: #e0ecff;
}

.table-order-handle {
  font-size: 16px;
  color: #9ca3af;
  cursor: grab;
  user-select: none;
}

.table-order-label {
  flex: 1;
  font-size: 13px;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-order-controls {
  display: flex;
  gap: 4px;
}

.table-order-control {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.table-order-control:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #cbd5f5;
}

.table-order-control:disabled {
  opacity: 0.4;
  cursor: default;
}

.pdf-modal {
  max-width: 420px;
}

.folder-edit-modal {
  max-width: 520px;
}

.folder-edit-modal .modal-form {
  max-height: calc(80vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.folder-edit-modal .modal-actions {
  margin-top: 12px;
}

.folder-edit-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.folder-edit-files-heading {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.folder-edit-hint {
  margin: 4px 0 0;
  font-size: 11px;
  color: #6b7280;
}

.folder-edit-file-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.folder-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.folder-edit-order {
  width: 28px;
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  text-align: center;
}

.folder-edit-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
}

.folder-edit-controls {
  display: flex;
  gap: 4px;
}

.folder-edit-control {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.folder-edit-control:hover:not(:disabled) {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.folder-edit-control:disabled {
  opacity: 0.4;
  cursor: default;
}

.folder-edit-delete {
  border-color: #fca5a5;
  color: #b91c1c;
}

.folder-edit-delete:hover {
  background: #fee2e2;
  border-color: #ef4444;
}

.folder-edit-empty {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

.pdf-orientation {
  margin-bottom: 16px;
}

.pdf-select-all {
  margin-top: 0;
  margin-bottom: 12px;
}

.pdf-table-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pdf-table-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: #1f2937;
}

.pdf-table-item input[type="checkbox"] {
  margin-top: 2px;
}

.modal-fieldset {
  margin: 0 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
}

.modal-fieldset legend {
  padding: 0 6px;
  font-size: 12px;
  color: #6b7280;
}

.modal-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}

.modal-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 8px;
}

.modal-checkbox input {
  margin-top: 3px;
}

.upload-fields {
  border: 1px dashed #93c5fd;
  background: #f8fbff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

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

.modal-actions button {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.modal-actions button:hover {
  background: #f3f4f6;
}

#file-modal-submit {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

#file-modal-submit:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.modal-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: #ef4444;
  display: none;
}

.auto-wrap-modal {
  width: 90vw;
  max-width: 1360px;
  max-height: calc(100vh - 80px);
}

.auto-wrap-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: inherit;
}

.auto-wrap-modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

.auto-wrap-modal-description {
  margin: 0;
  font-size: 13px;
  color: #4b5563;
}

.auto-wrap-preview {
  flex: 1 1 auto;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
}

.auto-wrap-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.auto-wrap-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.auto-wrap-pane-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

.auto-wrap-select-btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #1f2937;
  background: #e0e7ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.auto-wrap-select-btn:hover {
  background: #c7d2fe;
  border-color: #a5b4fc;
  color: #1e3a8a;
}

.auto-wrap-select-btn[aria-pressed="true"] {
  background: #4f46e5;
  border-color: #4338ca;
  color: #fff;
}

.auto-wrap-preview-box {
  flex: 1 1 auto;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  padding: 16px;
  font-size: 13px;
  line-height: 1.55;
  color: #374151;
  overflow: auto;
  max-height: 360px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.auto-wrap-preview-box--after {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.auto-wrap-preview-box:hover {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  border-color: #9ca3af;
}

.auto-wrap-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.auto-wrap-modal-actions #auto-wrap-modal-apply {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.auto-wrap-modal-actions #auto-wrap-modal-apply:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.auto-wrap-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: inherit;
}

.auto-wrap-table thead th {
  padding: 10px 12px;
  border-bottom: 1px solid #d1d5db;
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  text-align: left;
}

.auto-wrap-select-header {
  width: 48px;
}

.auto-wrap-table tbody td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  color: #374151;
  font-size: 13px;
  word-break: break-word;
  white-space: pre-wrap;
}

.auto-wrap-select-cell {
  width: 48px;
  text-align: center;
  vertical-align: middle;
}

.auto-wrap-select-cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.auto-wrap-table tbody tr:last-child td {
  border-bottom: none;
}

.auto-wrap-empty-cell {
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  padding: 20px 12px;
}

.auto-wrap-selected-row {
  background: rgba(79, 70, 229, 0.08);
}

.auto-wrap-preview-box--after .auto-wrap-table thead th {
  border-bottom-color: #c7d2fe;
}

.auto-wrap-preview-box--after .auto-wrap-table tbody td {
  border-bottom-color: #dedefd;
}

.auto-wrap-placeholder {
  color: #9ca3af;
  font-style: italic;
}

.auto-wrap-preview::-webkit-scrollbar {
  height: 8px;
}

.auto-wrap-preview::-webkit-scrollbar-thumb {
  background: rgba(55, 65, 81, 0.2);
  border-radius: 999px;
}

@media (max-width: 1024px) {
  .auto-wrap-preview {
    grid-template-columns: 1fr;
  }
}

.modal-progress {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.modal-progress.visible {
  display: flex;
}

.modal-progress-bar {
  position: relative;
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
}

.modal-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
  transition: width 0.25s ease-in-out;
}

.modal-progress-label {
  font-size: 12px;
  color: #2563eb;
  text-align: right;
  font-weight: 500;
}

@media (max-width: 1024px) {
  body {
    padding-bottom: var(--footer-spacing);
  }

  main {
    flex-direction: column;
    padding: 0 0 calc(var(--footer-spacing) + 16px) 0;
  }

  .sidebar {
    position: relative;
    width: 100%;
    max-height: none;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 16px;
    display: none;
  }

  body.sidebar-expanded .sidebar {
    display: block;
  }

  body.sidebar-collapsed .sidebar {
    display: none;
  }

  body.sidebar-collapsed .workspace,
  .workspace {
    width: 100%;
    padding: 0 0 24px 0;
  }

  .tables-wrapper,
  #table {
    width: 100%;
  }
}

/* Tabulator tweaks */
.tabulator {
  width: 100%;
  border: 1px solid #000;
}

.tabulator .tabulator-header {
  border-bottom: 1px solid #000;
}

.tabulator .tabulator-header .tabulator-col {
  border-right: 1px solid #000;
}

.tabulator .tabulator-header .tabulator-col:last-child {
  border-right: none;
}

.tabulator .tabulator-header .tabulator-col-group {
  border-right: 1px solid #000;
}

.tabulator .tabulator-header .tabulator-col-group:last-child {
  border-right: none;
}

.tabulator .tabulator-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  /* 줄바꿈 표시 */
}

.tabulator .tabulator-cell .tabulator-cell-value {
  flex: 1 1 auto;
  width: 100%;
  white-space: inherit;
  word-break: inherit;
  overflow-wrap: inherit;
}

.tabulator .tabulator-row {
  position: relative;
  background: #fff;
  border-bottom: 1px solid #000;
}

.tabulator .tabulator-row:last-of-type {
  border-bottom: none;
}

.tabulator .tabulator-row.tabulator-selectable:hover,
.tabulator .tabulator-row.tabulator-selected,
.tabulator .tabulator-row.tabulator-selected:hover,
.tabulator .tabulator-row.tabulator-moving {
  background: #fff;
}

.tabulator .tabulator-row .tabulator-cell {
  background: #fff;
  border-right: 1px solid #000;
}

.tabulator .tabulator-row .tabulator-cell:last-child {
  border-right: none;
}

.tabulator .tabulator-row.tabulator-selectable:hover .tabulator-cell,
.tabulator .tabulator-row.tabulator-selected .tabulator-cell,
.tabulator .tabulator-row.tabulator-selected:hover .tabulator-cell {
  background: #fff;
}

.tabulator-textarea-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  color: inherit;
  resize: none;
  box-sizing: border-box;
  background-color: transparent;
  overflow: hidden;
}

.tabulator-textarea-editor:focus {
  outline: none;
  box-shadow: none;
}

.tabulator .tabulator-cell.tabulator-editing {
  border-right: 1px solid #000;
  border-top: 0;
  border-left: 0;
  border-bottom: 0;
  padding: 4px;
  outline: none;
  box-shadow: none;
  background: inherit;
}

.tabulator .tabulator-row:last-of-type .tabulator-cell.tabulator-editing {
  border-bottom: 0;
}

.tabulator .tabulator-row .tabulator-cell:last-child.tabulator-editing {
  border-right: none;
}

.tabulator .tabulator-tableholder {
  overflow: visible;
  background-color: #fff;
}

.tabulator .tabulator-tableholder .tabulator-table {
  background-color: #fff;
}

.tabulator .tabulator-col[data-field="similarity"] .tabulator-col-content {
  justify-content: flex-start;
}

/* Footer */
footer {
  text-align: center;
  padding: 16px;
  color: #9ca3af;
}

.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
}
