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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

a {
  color: #64b5f6;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.btn {
  padding: 5px 12px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2a2a4a;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}
.btn:hover {
  background: #3a3a5a;
}
.btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}
.btn-primary {
  background: #1565c0;
  border-color: #1565c0;
  color: #fff;
}
.btn-primary:hover {
  background: #1976d2;
}
.btn-danger {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}
.btn-danger:hover {
  background: #d32f2f;
}

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  color: #aaa;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 14px;
}
.form-group input:focus {
  outline: none;
  border-color: #64b5f6;
}

.login-container {
  max-width: 380px;
  margin: 80px auto;
  padding: 30px;
  background: #16213e;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.login-container h1 {
  text-align: center;
  margin-bottom: 20px;
  font-size: 24px;
}
.login-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 8px;
}
.login-container p {
  text-align: center;
  margin-bottom: 14px;
}
.login-form .btn {
  width: 100%;
  padding: 8px;
  font-size: 14px;
}
.error {
  color: #ef5350;
  font-size: 13px;
}
.login-error {
  background: rgba(198, 40, 40, 0.15);
  border: 1px solid #c62828;
  border-radius: 4px;
  color: #ef5350;
  font-size: 13px;
  padding: 10px;
  margin-bottom: 16px;
  text-align: center;
}

.error-page {
  text-align: center;
  margin-top: 100px;
}
.error-page h1 {
  font-size: 72px;
  color: #ef5350;
}
.error-page p {
  margin-top: 10px;
}
.error-page a {
  display: inline-block;
  margin-top: 20px;
}
.error-illustration {
  width: 240px;
  max-width: 60vw;
  height: auto;
  margin-bottom: 16px;
}

.dashboard {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  background: #0f3460;
  gap: 16px;
}
.brand {
  font-weight: bold;
  font-size: 16px;
  color: #64b5f6;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
}
.search-form {
  display: flex;
  gap: 6px;
  flex: 1;
  max-width: 400px;
}
.search-form input {
  padding: 6px 10px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  flex: 1;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.dashboard-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 220px;
  background: #16213e;
  border-right: 1px solid #333;
  overflow-y: auto;
  padding: 10px;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  color: #aaa;
}
.tree {
  list-style: none;
}
.tree-item {
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
}
.tree-item:hover {
  background: #1a1a4e;
}
.tree-item.active {
  background: #0f3460;
  color: #64b5f6;
}
.tree-item .tree-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-pane {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.list-pane.search-mode #list-table,
.list-pane.search-mode #empty-state,
.list-pane.search-mode #pagination,
.list-pane.search-mode #dz {
  display: none;
}
.list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.list-header h2 {
  font-size: 18px;
  flex: 1;
}

.dz {
  border: 2px dashed #444;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  color: #888;
  transition: border-color 0.2s;
}
.dz.dragover {
  border-color: #64b5f6;
  background: rgba(100, 181, 246, 0.05);
}

.list-table {
  width: 100%;
  border-collapse: collapse;
}
.list-table th {
  text-align: left;
  padding: 8px;
  font-size: 12px;
  color: #888;
  border-bottom: 1px solid #333;
}
.list-table td {
  padding: 8px;
  font-size: 14px;
  border-bottom: 1px solid #222;
}
.list-table tr:hover {
  background: #1a1a4e;
}
.list-table .row-name {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.list-table .row-name:hover {
  color: #64b5f6;
}
.list-table .row-name .group-icon,
.list-table .row-name .type-icon {
  flex: none;
}
.type-icon {
  width: 16px;
  height: 16px;
}
.row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
.row-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px 7px;
  font-size: 12px;
  line-height: 1;
  min-height: 28px;
}
.action-icon {
  width: 18px;
  height: 18px;
  flex: none;
}
.row-actions .kebab-icon {
  width: 18px;
  height: 18px;
  flex: none;
}

.muted {
  color: #666;
}

.detail-pane {
  width: 300px;
  background: #16213e;
  border-left: 1px solid #333;
  padding: 16px;
  overflow-y: auto;
}

.pane-divider {
  width: 5px;
  flex: none;
  cursor: col-resize;
  background: #333;
  transition: background 0.15s;
}
.pane-divider:hover,
.pane-divider.dragging {
  background: #64b5f6;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.detail-header h3 {
  font-size: 14px;
  color: #aaa;
}
.detail-content {
  min-height: 200px;
}
.detail-content img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 4px;
}
.detail-icon {
  font-size: 64px;
  text-align: center;
  padding: 40px 0;
}
.detail-icon img {
  width: 96px;
  height: 96px;
}

.meta {
  margin-top: 12px;
  border-top: 1px solid #333;
  padding-top: 10px;
  font-size: 13px;
}
.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
}
.meta-key {
  color: #888;
  flex: none;
}
.meta-val {
  color: #e0e0e0;
  text-align: right;
  word-break: break-word;
}

.link-section {
  margin-top: 20px;
  border-top: 1px solid #333;
  padding-top: 16px;
}
.link-section h3 {
  font-size: 14px;
  color: #aaa;
  margin-bottom: 10px;
}
.link-item {
  padding: 8px;
  margin-bottom: 8px;
  background: #1a1a4e;
  border-radius: 4px;
  font-size: 13px;
}
.link-item .token {
  font-family: monospace;
  color: #64b5f6;
}
.link-item .meta {
  color: #888;
  font-size: 11px;
  margin-top: 4px;
}
.lock-icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 2px;
}
.group-icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 4px;
}
.close-icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}
.back-icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 4px;
}
.kebab-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}
.menu-icon {
  width: 22px;
  height: 22px;
}
.link-item .actions {
  margin-top: 6px;
  display: flex;
  gap: 4px;
}
.link-item .expired-note {
  color: #ef5350;
  font-size: 11px;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #16213e;
  padding: 24px;
  border-radius: 8px;
  min-width: 320px;
  max-width: 420px;
}
.modal-content h3 {
  margin-bottom: 16px;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.modal-header h3 {
  margin-bottom: 0;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.confirm-message {
  color: #ccc;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 4px;

  white-space: pre-line;
  overflow-wrap: anywhere;
}
.link-url {
  width: 100%;
  padding: 8px;
  margin: 8px 0;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a2e;
  color: #64b5f6;
  font-family: monospace;
}

.search-results {
  margin-top: 20px;
}
.search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.search-results h2 {
  font-size: 16px;
  margin-bottom: 12px;
}
.search-results h3 {
  font-size: 14px;
  color: #aaa;
  margin: 12px 0 8px;
}
.search-results ul {
  list-style: none;
}
.search-results li {
  padding: 4px 0;
}
.search-group-list {
  list-style: none;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tree-item .tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-delete {
  padding: 0 6px;
  font-size: 10px;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  background: none;
  border-color: transparent;
  color: #c62828;
}
.tree-delete:hover {
  background: rgba(198, 40, 40, 0.15);
}
.tree-item:hover .tree-delete {
  opacity: 1;
}

@media (hover: none) {
  .tree-delete {
    opacity: 1;
  }
}

.detail-type-note {
  font-size: 12px;
  margin-top: 8px;
  line-height: 1.4;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #aaa;
  cursor: pointer;
}
.checkbox-label input {
  width: auto;
}

.password-input-wrap {
  display: flex;
  gap: 6px;
}
.password-input-wrap input {
  flex: 1;
  min-width: 0;
}
.btn-show-pw {
  flex-shrink: 0;
}

.picker-content {
  min-width: 340px;
  max-width: 460px;
}
.picker-hint {
  font-size: 13px;
  margin-bottom: 8px;
}
.picker-tree-wrap {
  max-height: 45vh;
  overflow-y: auto;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 6px;
  background: #1a1a2e;
  margin-bottom: 8px;
}
.picker-tree {
  list-style: none;
}
.picker-children {
  list-style: none;
}
.picker-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.picker-node:hover {
  background: #1a1a4e;
}
.picker-node.selected {
  background: #0f3460;
  color: #64b5f6;
}
.picker-toggle {
  width: 14px;
  flex: none;
  text-align: center;
  color: #888;
  font-size: 11px;
  user-select: none;
}
.picker-toggle.leaf {
  visibility: hidden;
}
.picker-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #64b5f6;
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
}
.detail-back {
  display: none;
}

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

.drawer-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 900;
}
.drawer-scrim.visible {
  display: block;
}

@media (max-width: 768px) {
  .menu-toggle {
    display: inline-block;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }
  .brand {
    font-size: 15px;
  }
  .search-form {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .search-form input {
    font-size: 16px;
  }

  .search-form .btn {
    display: none;
  }
  .topbar-actions {
    margin-left: auto;
  }

  .dashboard {
    height: 100vh;
  }
  .dashboard-body {
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 82vw;
    z-index: 950;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .list-pane {
    width: 100%;
    padding: 10px;
  }
  .list-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .list-header h2 {
    font-size: 16px;
  }

  .dz {
    display: none;
  }

  .list-table {
    font-size: 13px;
  }
  .list-table th,
  .list-table td {
    padding: 8px 6px;
  }
  .list-table .col-select,
  .list-table th.col-select {
    display: none;
  }
  .list-table .col-size {
    display: none;
  }
  .list-table .time-cell {
    display: none;
  }
  .row-name {
    word-break: break-word;
  }
  .kebab-icon {
    width: 20px;
    height: 20px;
  }

  .pane-divider {
    display: none;
  }
  .detail-pane {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 960;
    transform: translateY(100%);
    transition: transform 0.2s ease;
    padding: 12px;
  }
  .detail-pane.fullscreen {
    transform: translateY(0);
  }
  .detail-back {
    display: inline-block;
  }
  .detail-content img {
    max-height: 45vh;
  }

  .modal-content {
    min-width: 0;
    width: calc(100vw - 32px);
    max-width: 92vw;
    max-height: 90vh;
    overflow-y: auto;
  }
  .link-url {
    font-size: 13px;
    word-break: break-all;
  }

  .search-results h2 {
    font-size: 15px;
  }
  .search-results .list-table td {
    word-break: break-word;
  }
}

.breadcrumb {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px;
  font-size: 12px;
  color: #888;
}
.breadcrumb a {
  color: #64b5f6;
  text-decoration: none;
  padding: 1px 3px;
  border-radius: 3px;
}
.breadcrumb a:hover {
  background: #1a1a4e;
}
.breadcrumb a.bc-current {
  color: #e0e0e0;
  cursor: default;
}
.breadcrumb a.bc-current:hover {
  background: none;
}
.bc-sep {
  color: #555;
  margin: 0 1px;
}
.breadcrumb .bc-title {
  font-size: 18px;
  font-weight: 600;
  color: #e0e0e0;
  padding: 0;
  margin-left: 2px;
}
.list-title {
  flex: 1;
  min-width: 0;
}

.summary {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #333;
  font-size: 12px;
  color: #888;
}

.list-table tr.selected {
  background: #0f3460;
}
.list-table tr.selected .row-name {
  color: #64b5f6;
}

.kebab-wrap {
  position: relative;
  display: inline-block;
}
.kebab-btn {
  padding: 2px 6px;
  font-size: 14px;
  line-height: 1;
}
.kebab-menu {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 100;
  background: #16213e;
  border: 1px solid #444;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  min-width: 120px;
  padding: 4px 0;
}
.kebab-menu.flip-up {
  top: auto;
  bottom: 100%;
}
.kebab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.kebab-item:hover {
  background: #1a1a4e;
}
.kebab-item.kebab-danger {
  color: #ef5350;
}
.kebab-item.kebab-danger:hover {
  background: rgba(198, 40, 40, 0.15);
}

.action-label {
  font-size: 13px;
}

.batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: #0f3460;
  border-radius: 4px;
  font-size: 13px;
}
.batch-bar #batch-count {
  font-weight: bold;
  color: #64b5f6;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px;
}
th.sortable:hover {
  color: #e0e0e0;
}
th.sortable.sort-asc::after {
  content: " ▲";
  font-size: 10px;
  color: #64b5f6;
}
th.sortable.sort-desc::after {
  content: " ▼";
  font-size: 10px;
  color: #64b5f6;
}

.no-results {
  padding: 20px;
  text-align: center;
  color: #888;
  font-size: 14px;
}

.link-url-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.link-url-row .token {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.copy-btn {
  padding: 2px 6px;
  font-size: 11px;
  flex-shrink: 0;
}

.dz.active {
  border-color: #64b5f6;
  background: rgba(100, 181, 246, 0.08);
}
.dz.active p {
  color: #64b5f6;
}
.task-title {
  margin-bottom: 8px;
}
.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.task-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name name"
    "track pct";
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
}
.task-name {
  grid-area: name;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-track {
  grid-area: track;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}
.task-bar {
  height: 100%;
  width: 0;
  background: #64b5f6;
  transition: width 0.15s ease;
}
.task-pct {
  grid-area: pct;
  font-size: 11px;
  color: #64b5f6;
  min-width: 34px;
  text-align: right;
}
.task-item.done .task-bar {
  background: #66bb6a;
}
.task-item.done .task-pct {
  color: #66bb6a;
}
.task-item.failed .task-bar {
  background: #c62828;
}
.task-item.failed .task-pct {
  color: #c62828;
}
.task-item.working .task-bar {
  width: 100% !important;
  animation: task-pulse 1.1s ease-in-out infinite;
}
@keyframes task-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.search-row {
  cursor: pointer;
}
.search-row:hover {
  background: #1a1a4e;
}

.field-error {
  color: #ef5350;
  font-size: 12px;
  margin-top: 4px;
}

.col-select {
  width: 30px;
  text-align: center;
}
.col-select input[type="checkbox"] {
  cursor: pointer;
}

.summary .summary-line {
  line-height: 1.6;
}
.summary .summary-total {
  color: #aaa;
  margin-top: 2px;
}

.pagination {
  padding: 12px 16px;
  text-align: center;
}
.pagination .btn {
  min-width: 180px;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: #888;
}
.empty-state-icon {
  width: 72px;
  height: 72px;
  opacity: 0.5;
  margin-bottom: 12px;
}
.empty-state p {
  margin: 4px 0;
  font-size: 14px;
}

.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: #1e1e3f;
  border: 1px solid #444;
  border-left: 3px solid #64b5f6;
  color: #e0e0e0;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  word-break: break-word;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast-error {
  border-left-color: #ef5350;
}
.toast-success {
  border-left-color: #66bb6a;
}

.page-illustration {
  width: 96px;
  height: 96px;
  display: block;
  margin: 0 auto 12px;
}

.detail-media {
  border-radius: 4px;
}
.detail-media video,
.detail-media audio {
  width: 100%;
}
.detail-media audio {
  min-height: 40px;
}
.detail-content video {
  max-width: 100%;
  max-height: 400px;
}

@media (max-width: 768px) {
  .action-label {
    display: none;
  }
  .kebab-menu {
    min-width: 100px;
  }
  .breadcrumb {
    font-size: 11px;
  }
  .breadcrumb .bc-title {
    font-size: 16px;
  }
  .batch-bar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
  }

  .link-url-row .token {
    font-size: 11px;
  }
  .col-select {
    width: 24px;
  }
}

.pw-success {
  background: rgba(102, 187, 106, 0.15);
  border: 1px solid #66bb6a;
  border-radius: 4px;
  color: #a5d6a7;
  font-size: 13px;
  padding: 10px;
  margin-bottom: 16px;
  text-align: center;
}
.pw-error {
  background: rgba(198, 40, 40, 0.15);
  border: 1px solid #c62828;
  border-radius: 4px;
  color: #ef5350;
  font-size: 13px;
  padding: 10px;
  margin-bottom: 16px;
  text-align: center;
}

.loading-row td {
  padding: 24px 8px;
  text-align: center;
  color: #666;
  font-size: 13px;
}
