:root {
  --bg: #0d0f14;
  --surface: #151820;
  --surface2: #1c2030;
  --border: #2a2f42;
  --accent: #4f8ef7;
  --accent2: #7c4dff;
  --green: #2de08a;
  --red: #ff4f6a;
  --yellow: #ffc94d;
  --text: #e8eaf2;
  --text-dim: #6b7280;
  --text-mid: #9ca3af;
  --mono: "JetBrains Mono", monospace;
  --sans: "Sora", sans-serif;
  --radius: 12px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
}

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

.logo small {
  color: var(--text-mid);
  margin-left: 4px;
}

.mode-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.mode-badge.teacher {
  background: rgba(79, 142, 247, 0.15);
  color: var(--accent);
  border: 1px solid rgba(79, 142, 247, 0.3);
}

.mode-badge.student {
  background: rgba(45, 224, 138, 0.12);
  color: var(--green);
  border: 1px solid rgba(45, 224, 138, 0.25);
}

.btn-switch {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-mid);
  padding: 7px 16px;
  border-radius: 8px;
}

.btn-switch:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.app {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 57px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}

.btn-new {
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.items-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-card {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
}

.item-card.active {
  background: rgba(79, 142, 247, 0.1);
  border-color: rgba(79, 142, 247, 0.3);
}

.item-type {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.item-name {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-date,
.file-size {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.del-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  opacity: 0;
}

.item-card:hover .del-btn {
  opacity: 1;
}

.del-btn:hover {
  color: var(--red);
}

.main,
#teacher-view {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main,
#teacher-view,
#student-view {
  flex: 1;
}

.toolbar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.type-btn {
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-mid);
}

.type-btn.active {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.1);
  color: var(--accent);
}

.editor-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.inp {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  outline: none;
}

textarea.inp {
  font-family: var(--mono);
  min-height: 120px;
  resize: vertical;
}

.upload-zone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  background: var(--surface2);
  margin-bottom: 10px;
  transition: all 0.2s;
}

.upload-zone:hover {
  border-color: var(--accent);
  background: rgba(79, 142, 247, 0.05);
}

.upload-zone input {
  display: none;
}

.upload-zone.folder {
  border-color: var(--green);
  background: rgba(45, 224, 138, 0.05);
}

.upload-zone.folder:hover {
  background: rgba(45, 224, 138, 0.1);
}

.file-preview {
  margin-top: 12px;
  padding: 10px;
  background: rgba(232, 121, 249, 0.1);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-publish {
  padding: 11px 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 9px;
  color: #fff;
  font-weight: 600;
}

.btn-share {
  padding: 11px 20px;
  background: rgba(255, 201, 77, 0.15);
  border: 1px solid var(--yellow);
  border-radius: 9px;
  color: var(--yellow);
}

#student-view {
  overflow-y: auto;
  padding: 28px 32px;
}

.empty-state,
.empty-list {
  text-align: center;
  color: var(--text-dim);
}

.empty-state {
  margin-top: 80px;
}

.empty-list {
  padding: 24px;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 500;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  width: 340px;
}

.modal h3 {
  margin-bottom: 14px;
}

.pin-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1rem;
  padding: 12px;
  margin-bottom: 14px;
}

.btn-pin-ok {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 9px;
  color: #fff;
  font-weight: 600;
}

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  transform: translateY(20px);
  opacity: 0;
  transition: 0.3s;
  z-index: 1000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--green);
}

.toast.error {
  border-color: var(--red);
}

.student-page {
  padding: 40px 20px;
}

.student-container {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
}

.badge {
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
}

.student-title {
  font-size: 1.5rem;
  margin: 10px 0;
}

.student-date {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-bottom: 20px;
}

.text-block {
  background: var(--surface2);
  padding: 20px;
  border-radius: 12px;
  white-space: pre-wrap;
}

.code-block {
  background: #0a0c10;
  border-radius: 12px;
  overflow: auto;
}

.code-bar {
  background: var(--surface);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.copy-btn {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
}

.pre-code {
  padding: 20px;
  margin: 0;
  font-family: var(--mono);
}

.link-card {
  background: var(--surface2);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.btn {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 20px;
  background: rgba(255, 201, 77, 0.12);
  border-radius: 9px;
  color: var(--yellow);
  text-decoration: none;
}

.file-card {
  background: var(--surface2);
  padding: 20px;
  border-radius: 12px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.file-icon {
  font-size: 2rem;
}

.btn-download {
  background: rgba(232, 121, 249, 0.2);
  padding: 9px 20px;
  border-radius: 8px;
  color: #e879f9;
  text-decoration: none;
  margin-left: auto;
}

.not-found-page {
  align-items: center;
  justify-content: center;
}

.not-found {
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 0.3s;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px;
  }

  .header-right,
  .toolbar {
    flex-wrap: wrap;
  }

  .app {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    min-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .student-container {
    padding: 22px;
  }
}
