@font-face {
  font-family: 'TheYearofHandicrafts';
  src: url('/assets/fonts/TheYearofHandicrafts-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'TheYearofHandicrafts';
  src: url('/assets/fonts/TheYearofHandicrafts-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: 'TheYearofHandicrafts';
  src: url('/assets/fonts/TheYearofHandicrafts-SemiBold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
}
@font-face {
  font-family: 'TheYearofHandicrafts';
  src: url('/assets/fonts/TheYearofHandicrafts-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
}

:root {
  --primary: #637b69;
  --primary-dark: #4a5d50;
  --primary-light: #7c9381;
  --surface: #ffffff;
  --background: #f4f2ee;
  --muted: #807e7a;
  --border: #e3e0da;
  --shadow: 0 8px 18px rgba(60, 60, 60, 0.08);
  --font-family: 'TheYearofHandicrafts', sans-serif;
  --danger: #d54b4b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  font-family: var(--font-family);
  background: var(--background);
  color: #1c1c1c;
}

body {
  direction: rtl;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 16px 150px;
}

.header {
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.now-label {
  color: var(--muted);
  font-size: 0.95rem;
}

.now-value {
  font-weight: 600;
  font-size: 1.05rem;
}

.path-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.path-value {
  font-weight: 600;
  color: #1f1f1f;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn.ghost {
  background: #efede8;
  color: var(--primary-dark);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.catalog-node {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-inline-start: calc(var(--depth, 0) * 16px);
}

.catalog-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-row {
  --checkbox-size: 38px;
  --checkbox-column: 80px;
  --toggle-size: 44px;
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: var(--checkbox-column) 1fr var(--toggle-size);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
}

.catalog-row.section {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.catalog-row.section .row-title,
.catalog-row.section .row-meta {
  color: #fff;
}

.catalog-row.section .row-toggle {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.catalog-row.section input[type='checkbox'] {
  accent-color: #ffffff;
}

.catalog-row.media {
  grid-template-columns: var(--checkbox-column) 1fr var(--toggle-size);
}

.catalog-row.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 123, 105, 0.25);
}

.catalog-row.section.is-selected {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.catalog-row.is-playing {
  outline: 3px solid rgba(99, 123, 105, 0.65);
  outline-offset: 2px;
}

.row-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.row-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.row-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: #1c1c1c;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.row-title span {
  white-space: normal;
  line-height: 1.3;
}

.row-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.entry-checkbox-wrap {
  width: var(--checkbox-column);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  cursor: pointer;
}

.entry-checkbox {
  width: var(--checkbox-size);
  height: var(--checkbox-size);
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.row-toggle {
  border: none;
  border-radius: 12px;
  width: var(--toggle-size);
  height: var(--toggle-size);
  background: #efede8;
  color: var(--primary-dark);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.row-toggle.is-open {
  transform: rotate(-90deg);
}

.row-toggle.is-disabled {
  opacity: 0.3;
  pointer-events: none;
}

.row-toggle.placeholder {
  background: transparent;
  box-shadow: none;
}

.media-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}

.media-preview img,
.media-preview video {
  max-height: 16vh;
  height: auto;
  width: auto;
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
  background: #000;
}

.media-preview video {
  background: #000;
}

.item-preview-grid {
  margin-top: 8px;
  width: 100%;
  max-width: 180px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  border-radius: 12px;
  overflow: hidden;
  background: #e7e3dc;
}

.item-preview-grid.one {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.item-preview-grid.two {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: 1fr;
}

.item-preview-grid.two .item-preview-cell {
  grid-row: 1 / -1;
}

.item-preview-cell {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.item-preview-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.loading-row,
.empty-row {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-state,
.loading-state {
  padding: 18px;
  background: var(--surface);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  box-shadow: var(--shadow);
}

.media-toolbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  z-index: 75;
}

.media-toolbar[hidden] {
  display: none !important;
}

.media-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #6f8c6d;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  margin: 0 auto;
}

.control-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: #efede8;
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.control-btn.play {
  width: 62px;
  height: 62px;
  background: var(--primary);
  color: #fff;
  font-size: 1.4rem;
}

.control-btn:active {
  transform: scale(0.96);
}

.control-btn i {
  pointer-events: none;
}

.clear-selection-btn {
  position: absolute;
  left: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #e59a3a;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: 1px solid #6f8c6d;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.clear-selection-btn:active {
  transform: scale(0.96);
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #5e755c;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-size: 1rem;
  z-index: 60;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

@media (max-width: 720px) {
  .catalog-row {
    --checkbox-size: 34px;
    --checkbox-column: 70px;
    --toggle-size: 42px;
    grid-template-columns: var(--checkbox-column) 1fr var(--toggle-size);
  }

  .row-title {
    font-size: 1rem;
  }

  .media-toolbar {
    bottom: 90px;
    padding: 0 18px;
  }

  .media-controls {
    padding: 8px 14px;
    gap: 10px;
  }

  .control-btn {
    width: 50px;
    height: 50px;
  }

  .control-btn.play {
    width: 58px;
    height: 58px;
  }

  .clear-selection-btn {
    left: 18px;
    width: 52px;
    height: 52px;
  }
}
.catalog-row.is-expandable {
  cursor: pointer;
}
