/* ==========================================================================
   Mathematical Terms Master-Detail Workspace Styles (Claymorphic)
   ========================================================================== */

.terms-page {
  width: 100%;
  animation: fadeInWorkspace 0.3s ease-out;
}

@keyframes fadeInWorkspace {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Two-Panel Split Workspace */
.terms-workspace {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
  min-height: calc(100vh - 170px);
}

/* ==========================================================================
   Left Sidebar: Search, Title List, Add Button
   ========================================================================== */
.terms-sidebar {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--clay-card);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  position: sticky;
  top: 85px;
  overflow: hidden;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

/* Top: Search Header */
.sidebar-search-box {
  padding: 1.25rem 1.25rem 0.85rem;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  font-size: 1rem;
  color: var(--text-light);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.sidebar-search-input {
  width: 100%;
  padding: 0.75rem 2.4rem 0.75rem 2.6rem;
  font-size: 0.925rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-alt);
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  outline: none;
  box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.04), inset -2px -2px 5px rgba(255, 255, 255, 0.9);
  transition: all 0.2s ease;
}

.sidebar-search-input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.sidebar-search-input::placeholder {
  color: var(--text-light);
}

.search-clear-btn {
  position: absolute;
  right: 0.85rem;
  background: var(--text-light);
  color: #fff;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.search-clear-btn:hover {
  background: var(--danger);
  transform: scale(1.1);
}

.search-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.65rem;
  padding: 0 0.25rem;
  font-size: 0.775rem;
}

.search-count-badge {
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.search-live-hint {
  color: var(--text-light);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.search-live-hint::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--success);
  border-radius: 50%;
  animation: pulseGreen 1.6s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Sidebar Category Combobox Filter */
.sidebar-category-filter-wrapper {
  margin-top: 0.65rem;
  position: relative;
}

.sidebar-cat-combobox {
  position: relative;
  width: 100%;
}

.sidebar-cat-input-row {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-cat-prefix-icon {
  position: absolute;
  left: 0.85rem;
  font-size: 0.85rem;
  pointer-events: none;
  opacity: 0.75;
  z-index: 2;
}

.sidebar-cat-input {
  width: 100%;
  padding: 0.45rem 3.8rem 0.45rem 2.2rem !important;
  font-size: 0.825rem !important;
  border-radius: var(--radius-full) !important;
  height: auto !important;
  background-color: var(--bg-alt) !important;
  border: 1.5px solid var(--border) !important;
  color: var(--text-main);
  box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}

.sidebar-cat-input:focus {
  background-color: #ffffff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

.sidebar-cat-clear-btn {
  position: absolute;
  right: 2.1rem;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-light);
  color: #fff;
  border: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 2;
  transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar-cat-clear-btn:hover {
  background: var(--danger);
  transform: translateY(-50%) scale(1.15);
}

.sidebar-cat-toggle-btn {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  z-index: 2;
  transition: all 0.2s ease;
}

.sidebar-cat-toggle-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.sidebar-cat-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14), 0 4px 10px rgba(99, 102, 241, 0.1);
  max-height: 230px;
  overflow-y: auto;
  animation: slideDownFade 0.16s ease-out;
}

.sidebar-cat-all-option {
  border-bottom: 1px dashed var(--border);
  font-weight: 600;
}

/* Middle: Scrollable Titles List */
.sidebar-terms-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scrollbar-width: thin;
  scrollbar-color: #c7d2fe transparent;
}

.sidebar-terms-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-terms-list::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-terms-list::-webkit-scrollbar-thumb {
  background-color: #c7d2fe;
  border-radius: 10px;
}

.sidebar-terms-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--primary);
}

/* Row Container: Standalone Order Box + Standalone Term Card */
.term-sidebar-row {
  display: flex;
  align-items: stretch;
  gap: 0.65rem;
  width: 100%;
  cursor: pointer;
  border-radius: var(--radius-md);
  outline: none;
  transition: transform 0.18s ease;
  user-select: none;
}

.term-sidebar-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.term-sidebar-row:hover:not(.active) {
  transform: translateX(2px);
}

/* Standalone Number Box in Front of Term (Creative, Vibrant, Bold) */
.term-order-box {
  width: 46px;
  min-width: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1.5px solid #c7d2fe;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.08), inset 0 1px 1px #ffffff;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

/* Decorative top micro-gradient bar */
.term-order-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

/* Bold, vibrant number text inside the standalone order box */
.term-order-num {
  font-family: var(--font-fun, 'Outfit', 'Plus Jakarta Sans', system-ui, sans-serif);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  line-height: 1;
  transition: transform 0.2s ease;
}

/* Hover state for standalone order box */
.term-sidebar-row:hover:not(.active) .term-order-box {
  background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
  border-color: #818cf8;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.18), inset 0 1px 2px #ffffff;
}

.term-sidebar-row:hover:not(.active) .term-order-box::before {
  opacity: 1;
}

.term-sidebar-row:hover:not(.active) .term-order-num {
  transform: scale(1.08);
}

/* Active / Selected state for standalone order box */
.term-sidebar-row.active .term-order-box {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  border-color: #4f46e5;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.38), 0 2px 6px rgba(217, 70, 239, 0.25);
}

.term-sidebar-row.active .term-order-box::before {
  opacity: 0;
}

.term-sidebar-row.active .term-order-num {
  background: none;
  -webkit-background-clip: border-box;
  -webkit-text-fill-color: #ffffff;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  font-weight: 900;
  transform: scale(1.1);
}

/* Standalone Term Card (Contains only term title) */
.term-sidebar-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0.8rem 1rem 0.8rem 1.15rem;
  min-height: 52px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1.5px solid var(--border);
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  text-align: left;
  box-sizing: border-box;
}

.term-sidebar-row:hover:not(.active) .term-sidebar-item {
  border-color: #c7d2fe;
  background: #f8faff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.06);
}

.term-sidebar-row.active .term-sidebar-item {
  background: #f5f7ff;
  border-color: #6366f1;
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.14);
}

.term-sidebar-row.active .term-sidebar-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 4px;
  background: #4f46e5;
  border-radius: 0 4px 4px 0;
}

.term-item-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.35;
  margin: 0;
  word-break: break-word;
  transition: color 0.18s ease;
  flex: 1;
}

.term-sidebar-row.active .term-item-title {
  color: #4338ca;
  font-weight: 800;
}

/* Empty or Loading inside sidebar list */
.sidebar-empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.sidebar-empty-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

/* Bottom: Add Term Button / Auth Callout */
.sidebar-footer {
  padding: 1rem 1.25rem;
  background: #ffffff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-clay-add {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-fun);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--clay-btn-primary);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.btn-clay-add:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 10px 24px rgba(99, 102, 241, 0.45);
}

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

.btn-clay-add .add-icon {
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 700;
}

.btn-clay-signin {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.8rem 1rem;
  background: var(--bg-alt);
  color: var(--primary);
  border: 1.5px dashed var(--border-focus);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-clay-signin:hover {
  background: var(--primary-light);
  border-style: solid;
  transform: translateY(-1px);
}

/* ==========================================================================
   Right Panel: Selected Math Term Full Content
   ========================================================================== */
.terms-content-pane {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--clay-card);
  padding: 2.25rem;
  min-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.term-detail-article {
  animation: fadeInDetail 0.25s ease-out;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@keyframes fadeInDetail {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Detail Header */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px dashed var(--border);
}

.detail-badge-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.detail-category-badge {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.detail-date-badge {
  font-size: 0.8rem;
  color: var(--text-light);
}

.detail-title {
  font-family: var(--font-fun);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

/* Action Buttons (Edit / Delete) */
.detail-actions {
  display: flex;
  gap: 0.65rem;
}

.btn-clay-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: var(--bg-alt);
  color: var(--text-main);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clay-edit:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-hover);
  transform: translateY(-2px);
}

.btn-clay-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  background: #ffffff;
  color: var(--danger);
  border: 1.5px solid var(--coral-light);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clay-delete:hover {
  background: var(--coral-light);
  transform: translateY(-2px);
}

/* Formula Showcase Box */
.detail-formula-box {
  background: linear-gradient(135deg, #1e1b4b 0%, #2e266d 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 8px 24px rgba(30, 27, 75, 0.18), inset 0 2px 4px rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.detail-formula-box::after {
  content: '∑ ∫ π';
  position: absolute;
  right: 1.5rem;
  bottom: -0.3rem;
  font-family: var(--font-fun);
  font-size: 3.5rem;
  color: rgba(255, 255, 255, 0.05);
  pointer-events: none;
  font-weight: 700;
}

.formula-content {
  flex: 1;
}

.formula-label {
  font-size: 0.725rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sky);
  margin-bottom: 0.25rem;
  font-weight: 700;
}

.formula-text {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f8faff;
  word-break: break-all;
}

.btn-copy-formula {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-copy-formula:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

/* Image / Diagram Banner */
.detail-image-box {
  width: 100%;
  min-height: 220px;
  max-height: 450px;
  background: #f8fafc;
  background-image: radial-gradient(rgba(148, 163, 184, 0.3) 1px, transparent 1px);
  background-size: 16px 16px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.04);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.detail-img {
  max-width: 100%;
  max-height: 430px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-md);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.detail-img:hover {
  transform: scale(1.01);
}

/* Description Section */
.detail-desc-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.25rem 0;
}

.desc-heading {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.desc-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-main);
}

.desc-paragraph {
  margin-bottom: 0.85rem;
}

.desc-paragraph:last-child {
  margin-bottom: 0;
}

.desc-subheading {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 1.25rem 0 0.5rem;
}

.desc-subheading-small {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 1rem 0 0.4rem;
}

.desc-list,
.desc-list-ordered {
  padding-left: 1.5rem;
  margin: 0.5rem 0 0.85rem;
}

.desc-list li,
.desc-list-ordered li {
  margin-bottom: 0.35rem;
}

.desc-blockquote {
  border-left: 4px solid var(--primary);
  background: var(--bg-alt);
  padding: 0.75rem 1.1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 0.85rem 0;
  font-style: italic;
  color: var(--text-muted);
}

.math-code-inline {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: #4338ca;
  font-weight: 600;
}

.katex-block-wrapper {
  margin: 0.85rem 0;
  padding: 0.85rem 1.25rem;
  background: #fdfefe;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow-x: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.katex-inline-wrapper {
  padding: 0 0.2rem;
  display: inline-block;
  vertical-align: baseline;
}

/* Detail Footer / Author Info */
.detail-meta-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.author-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Empty Detail State */
.detail-empty-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.detail-empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: floatEmoji 3s ease-in-out infinite;
}

@keyframes floatEmoji {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.detail-empty-title {
  font-family: var(--font-fun);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.detail-empty-sub {
  max-width: 420px;
  line-height: 1.6;
  font-size: 0.95rem;
}

/* ==========================================================================
   Inline Term Editing Form (Right Content Pane)
   ========================================================================== */
.detail-edit-form {
  animation: fadeInDetail 0.25s ease-out;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.edit-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px dashed var(--border);
}

.edit-badge {
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--primary-light);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-bottom: 0.35rem;
}

.edit-title-heading {
  font-family: var(--font-fun);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.edit-actions-top {
  display: flex;
  gap: 0.65rem;
}

.edit-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .edit-form-grid {
    grid-template-columns: 1fr;
  }
}

.edit-preview-row {
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
}

.edit-preview-thumbnail {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  background: #ffffff;
  flex-shrink: 0;
}

.edit-file-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: block;
}

.edit-file-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 2px;
}

.edit-footer-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.btn-save-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--clay-btn-primary);
  transition: all 0.2s ease;
}

.btn-save-inline:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

.btn-save-inline:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-cancel-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel-inline:hover {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--text-muted);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 960px) {
  .terms-workspace {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .terms-sidebar {
    height: auto;
    max-height: 480px;
    position: static;
  }

  .terms-content-pane {
    min-height: auto;
  }
}

/* ==========================================================================
   Modal Dialog Styles (Preserved for Add / Edit with file upload)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-card);
  width: 100%;
  max-width: 540px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 20px 40px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--border);
  overflow: hidden;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
}

.modal-header h2 {
  font-family: var(--font-fun);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s ease;
}

.modal-close-btn:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.75rem;
  max-height: calc(85vh - 160px);
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.75rem;
  background-color: var(--bg-alt);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   Combobox Category Component Styles (Select or Type to Create)
   ========================================================================== */

.category-combobox-group {
  position: relative;
}

.category-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.category-combobox-hint {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-weight: 500;
}

.combobox-wrapper {
  position: relative;
  width: 100%;
}

.combobox-input-row {
  position: relative;
  display: flex;
  align-items: center;
}

.combobox-input {
  width: 100%;
  padding-right: 2.75rem !important;
  cursor: text;
}

.combobox-toggle-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.combobox-toggle-btn:hover {
  background: var(--primary-light);
  transform: translateY(-50%) scale(1.1);
}

.combobox-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 999;
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(99, 102, 241, 0.08);
  max-height: 250px;
  overflow-y: auto;
  animation: slideDownFade 0.18s ease-out;
}

@keyframes slideDownFade {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.combobox-options-list {
  list-style: none;
  padding: 0.35rem 0;
  margin: 0;
}

.combobox-option-item {
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.combobox-option-item:hover,
.combobox-option-item.highlighted {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.combobox-option-item.selected {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  font-weight: 700;
}

.combobox-option-icon {
  margin-right: 0.5rem;
  font-size: 0.9rem;
}

.combobox-option-check {
  color: var(--primary);
  font-weight: 800;
  font-size: 1rem;
}

.combobox-empty-item {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

.combobox-create-action {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #eef2ff 0%, #f0fdf4 100%);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.combobox-create-action:hover {
  background: var(--primary);
  color: #ffffff;
}

.combobox-create-action:hover .create-badge {
  background: #ffffff;
  color: var(--primary);
}

.combobox-create-action:hover .create-name {
  color: #ffffff;
}

.create-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.create-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.15s ease;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.1rem;
  padding-right: 2.75rem !important;
  cursor: pointer;
}


