:root {
  --bg: #0f0f13;
  --surface: #17171d;
  --surface2: #1e1e27;
  --border: #2a2a38;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --accent3: #43e97b;
  --text: #e8e8f0;
  --text2: #8888aa;
  --text3: #555570;
  --listening: #6c63ff;
  --reading: #ff6584;
  --speaking: #43e97b;
  --writing: #ffd166;
  --extra: #38bdf8;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Golos Text', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* TOP BAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,15,19,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 32px;
  height: 64px;
}

.logo {
  font-family: 'Unbounded', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
  margin-right: 40px;
  white-space: nowrap;
}

.logo span { color: var(--accent); }

.nav-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-tab {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}

.nav-tab::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  border-radius: 2px;
  transition: width 0.3s;
}

.nav-tab.listening::before { background: var(--listening); }
.nav-tab.reading::before { background: var(--reading); }
.nav-tab.speaking::before { background: var(--speaking); }
.nav-tab.writing::before { background: var(--writing); }
.nav-tab.extra::before { background: var(--extra); }

.nav-tab:hover { color: var(--text); background: var(--surface2); }
.nav-tab.active { color: var(--text); background: var(--surface2); }
.nav-tab.active::before { width: 60%; }

/* MAIN */
.main {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
}

/* SECTION HEADER */
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.section-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.section-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 20px;
  font-weight: 600;
}

/* SUBTABS */
.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.subtab {
  padding: 8px 18px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-family: 'Golos Text', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.subtab:hover { border-color: var(--accent); color: var(--text); }
.subtab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.subtab.active.listening-tab { background: var(--listening); border-color: var(--listening); }
.subtab.active.reading-tab { background: var(--reading); border-color: var(--reading); }
.subtab.active.speaking-tab { background: var(--speaking); border-color: var(--speaking); color: #0f0f13; }
.subtab.active.writing-tab { background: var(--writing); border-color: var(--writing); color: #0f0f13; }
.subtab.active.extra-tab { background: var(--extra); border-color: var(--extra); color: #0f0f13; }

/* TABLE AREA */
.table-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.05em;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  flex: 1;
  max-width: 300px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Golos Text', sans-serif;
  font-size: 13px;
  width: 100%;
}

.search-box input::placeholder { color: var(--text3); }

.btn-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: 'Golos Text', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-add:hover { opacity: 0.85; transform: translateY(-1px); }

/* TABLE */
.table-wrap { overflow-x: auto; }

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

th {
  padding: 12px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text3);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 14px 20px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid rgba(42,42,56,0.5);
  vertical-align: middle;
}

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

tr:hover td { background: rgba(108,99,255,0.04); }

.td-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 1px dashed var(--text3);
  transition: color 0.15s;
}

.td-truncate:hover { color: var(--accent); border-color: var(--accent); }

/* TEXT PREVIEW POPUP */
.text-preview {
  position: fixed;
  z-index: 500;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  max-width: 420px;
  min-width: 200px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.15s, transform 0.15s;
  word-break: break-word;
  white-space: pre-wrap;
}

.text-preview.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.td-id {
  font-family: 'Unbounded', sans-serif;
  font-size: 11px;
  color: var(--text3);
}

/* AUDIO PLAYER */
.audio-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--listening);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.play-btn:hover { transform: scale(1.1); }
.play-btn svg { width: 12px; height: 12px; fill: #fff; margin-left: 2px; }
.play-btn.playing svg { margin-left: 0; }

.audio-name {
  font-size: 12px;
  color: var(--text2);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* BADGE */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.badge-true { background: rgba(67,233,123,0.15); color: var(--accent3); }
.badge-false { background: rgba(255,101,132,0.15); color: var(--accent2); }

/* ACTIONS */
.actions { display: flex; gap: 6px; }

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--text2);
}

.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: rgba(108,99,255,0.08); }
.btn-icon.danger:hover { border-color: var(--accent2); color: var(--accent2); background: rgba(255,101,132,0.08); }
.btn-icon svg { width: 14px; height: 14px; }

/* EMPTY */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text3);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* LOADING */
.loading {
  padding: 60px 20px;
  text-align: center;
  color: var(--text3);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

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

/* SEARCHABLE SELECT */
.ss-wrap {
  position: relative;
}

.ss-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.2s;
  gap: 8px;
}

.ss-trigger:hover, .ss-trigger.open { border-color: var(--accent); }

.ss-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.ss-trigger-label.placeholder { color: var(--text3); }

.ss-trigger-arrow {
  flex-shrink: 0;
  transition: transform 0.2s;
  color: var(--text3);
}

.ss-trigger.open .ss-trigger-arrow { transform: rotate(180deg); }

.ss-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  z-index: 400;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
}

.ss-dropdown.open { display: block; }

.ss-search-wrap {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.ss-search {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-family: 'Golos Text', sans-serif;
  font-size: 13px;
  outline: none;
}

.ss-search:focus { border-color: var(--accent); }
.ss-search::placeholder { color: var(--text3); }

.ss-list {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.ss-item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ss-item:hover { background: rgba(108,99,255,0.1); }
.ss-item.selected { background: rgba(108,99,255,0.15); color: var(--accent); }
.ss-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ss-item-id { font-size: 11px; color: var(--text3); flex-shrink: 0; font-family: 'Unbounded', sans-serif; }
.ss-empty { padding: 16px 14px; font-size: 13px; color: var(--text3); text-align: center; }

/* MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-body { padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }

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

.view-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view-value {
  font-size: 14px;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.view-value.empty { color: var(--text3); font-style: italic; }

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--accent); }

.field textarea { resize: vertical; min-height: 90px; }

.field select option { background: var(--surface2); }

/* FILE UPLOAD */
.file-upload {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.file-upload:hover { border-color: var(--accent); background: rgba(108,99,255,0.04); }
.file-upload.has-file { border-color: var(--accent3); background: rgba(67,233,123,0.04); }

.file-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.file-upload-icon { font-size: 28px; margin-bottom: 8px; }
.file-upload-text { font-size: 13px; color: var(--text2); }
.file-upload-name { font-size: 13px; color: var(--accent3); font-weight: 500; margin-top: 4px; }

/* TOGGLE */
.toggle-field { display: flex; align-items: center; justify-content: space-between; }

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 100px;
  cursor: pointer;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent3); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* MODAL FOOTER */
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 28px 24px;
}

.btn-cancel {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover { color: var(--text); background: var(--surface2); }

.btn-save {
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save:hover { opacity: 0.85; }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* CONFIRM MODAL */
.confirm-modal-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 380px;
  padding: 36px 28px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.confirm-icon { font-size: 36px; margin-bottom: 4px; }
.confirm-title { font-family: 'Unbounded', sans-serif; font-size: 16px; margin-bottom: 4px; }
.confirm-text { font-size: 14px; color: var(--text2); margin-bottom: 16px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

.btn-danger {
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: var(--accent2);
  color: #fff;
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover { opacity: 0.85; }

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.3s ease;
  max-width: 320px;
}

.toast.success { background: rgba(67,233,123,0.15); border: 1px solid rgba(67,233,123,0.3); color: var(--accent3); }
.toast.error { background: rgba(255,101,132,0.15); border: 1px solid rgba(255,101,132,0.3); color: var(--accent2); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.page-info { font-size: 13px; color: var(--text2); }

.page-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.pagination { flex-wrap: wrap; gap: 6px; }

.page-num {
  width: auto;
  min-width: 32px;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Golos Text', sans-serif;
}
.page-num.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.page-num.active:hover { color: #fff; border-color: var(--accent); }

.page-ellipsis {
  color: var(--text3);
  font-size: 13px;
  padding: 0 2px;
  user-select: none;
}

.page-jump { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.page-jump input {
  width: 56px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  text-align: center;
  font-family: 'Golos Text', sans-serif;
  font-size: 13px;
  outline: none;
}
.page-jump input:focus { border-color: var(--accent); }
.page-jump input::placeholder { color: var(--text3); }

/* PAGE */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }

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

/* TAGS */
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }

.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(56,189,248,0.12);
  color: var(--extra);
  border: 1px solid rgba(56,189,248,0.25);
  white-space: nowrap;
}

/* TOPIC MULTI-SELECT */
.topic-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.15s;
}
.topic-item:hover { background: rgba(108,99,255,0.1); }
.topic-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.topic-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* LOGIN */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.login-overlay.open { opacity: 1; pointer-events: all; }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-logo {
  font-family: 'Unbounded', sans-serif;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.login-logo span { color: var(--accent); }

.login-subtitle {
  font-size: 13px;
  color: var(--text2);
  text-align: center;
  margin-top: -12px;
}

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

.login-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-field input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.login-field input:focus { border-color: var(--accent); }

.login-btn {
  padding: 13px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: 'Golos Text', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.login-btn:hover { opacity: 0.85; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  display: none;
  background: rgba(255,101,132,0.1);
  border: 1px solid rgba(255,101,132,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--accent2);
  text-align: center;
}
