:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #5d6a78;
  --line: #dce2e8;
  --brand: #1565c0;
  --brand-strong: #0d47a1;
  --accent: #16855c;
  --danger: #b3261e;
  --shadow: 0 18px 50px rgba(20, 30, 43, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(21, 101, 192, 0.08), rgba(22, 133, 92, 0.06)),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.site-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(21, 101, 192, 0.12), rgba(22, 133, 92, 0.08)),
    var(--bg);
}

.site-gate[hidden] {
  display: none;
}

.gate-card {
  width: min(380px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.gate-card h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}

.gate-subtitle {
  margin: 0 0 18px;
  color: var(--muted);
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.app-shell[hidden] {
  display: none;
}

h2,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 5px;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.tab-bar {
  display: flex;
  gap: 8px;
}

.tab-button {
  min-height: 42px;
  padding: 0 18px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.tab-button:hover {
  background: rgba(21, 101, 192, 0.08);
}

.tab-button.active {
  color: var(--brand);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

#filesView,
#notepadView {
  display: grid;
  gap: 18px;
}

#filesView[hidden],
#notepadView[hidden] {
  display: none;
}

.notepad-textarea {
  width: 100%;
  min-height: 360px;
  padding: 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.notepad-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.14);
}

.notepad-textarea.read-only {
  color: var(--muted);
  background: #f7f8fa;
}

.notepad-preview {
  min-height: 360px;
  padding: 14px;
  overflow-wrap: break-word;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.notepad-preview :first-child {
  margin-top: 0;
}

.notepad-preview code {
  padding: 2px 5px;
  background: rgba(21, 101, 192, 0.08);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pad-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.notepad-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.notepad-status.error {
  color: var(--danger);
}

.section-heading .notepad-status {
  margin: 0;
}

.panel,
.helper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.section-heading p,
.helper p {
  margin-bottom: 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.14);
}

.actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions[hidden] {
  display: none;
}

button {
  min-height: 42px;
  padding: 0 16px;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--brand-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button.secondary {
  color: var(--brand);
  background: #fff;
}

button.secondary:hover {
  background: rgba(21, 101, 192, 0.08);
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #fff;
  border-color: var(--line);
}

.icon-button:hover {
  color: var(--danger);
  background: rgba(179, 38, 30, 0.08);
}

.drop-zone {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  border: 2px dashed #b8c4d1;
  border-radius: 8px;
  background: #fafcff;
  cursor: pointer;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(22, 133, 92, 0.08);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-title {
  font-weight: 850;
}

.drop-subtitle {
  color: var(--muted);
}

.selected-files {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.selected-files li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.selected-files li span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-files li span:last-child {
  flex: 0 0 auto;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th:first-child,
td:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pad-table th:nth-child(2),
.pad-table td:nth-child(2) {
  width: 220px;
  white-space: nowrap;
}

.pad-table th:nth-child(3),
.pad-table td:nth-child(3) {
  width: 100px;
}

.blob-table th:first-child,
.blob-table td:first-child {
  width: 34px;
  overflow: visible;
  white-space: normal;
}

.blob-table th:nth-child(2),
.blob-table td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.blob-table th:nth-child(3),
.blob-table td:nth-child(3) {
  width: 90px;
}

.blob-table th:nth-child(4),
.blob-table td:nth-child(4) {
  width: 170px;
  white-space: nowrap;
}

.blob-table th:nth-child(5),
.blob-table td:nth-child(5) {
  width: 210px;
}

.blob-table td:first-child input[type="checkbox"] {
  cursor: pointer;
}

tbody tr.row-selected {
  background: rgba(21, 101, 192, 0.09);
}

.pad-table tbody tr.row-selected td:first-child {
  border-left: 3px solid var(--brand);
}

.blob-table tbody tr.row-selected td:nth-child(2) {
  border-left: 3px solid var(--brand);
}

.folder-link {
  color: var(--ink);
  background: transparent;
  border: none;
  padding: 0;
  min-height: auto;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.folder-link:hover {
  color: var(--brand);
  background: transparent;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
}

.breadcrumb-link {
  padding: 2px 6px;
  color: var(--brand);
  background: transparent;
  border: none;
  min-height: auto;
  font-weight: 700;
  cursor: pointer;
}

.breadcrumb-link:disabled {
  color: var(--ink);
  cursor: default;
  background: transparent;
}

.breadcrumb-link:hover:not(:disabled) {
  background: rgba(21, 101, 192, 0.08);
  border-radius: 4px;
}

.breadcrumb-separator {
  color: var(--line);
}

.search-input {
  flex: 1 1 220px;
  min-width: 160px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.14);
}

.bulk-actions {
  align-items: center;
  padding: 10px 14px;
  background: rgba(21, 101, 192, 0.06);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.bulk-actions .notepad-status {
  margin: 0;
}

#blobTableHead th[data-sort-key] {
  user-select: none;
}

#blobTableHead th.sorted {
  color: var(--brand);
}

.progress-bar {
  margin-top: 14px;
  height: 8px;
  overflow: hidden;
  background: rgba(21, 101, 192, 0.12);
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  background: var(--brand);
  transition: width 120ms ease;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.right {
  text-align: right;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
}

.icon-action[hidden] {
  display: none;
}

.icon-action {
  width: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 1rem;
  line-height: 1;
}

.download-link {
  color: var(--brand);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  font-weight: 800;
}

.download-link:hover {
  border-color: var(--brand);
  background: rgba(21, 101, 192, 0.08);
}

.danger-button {
  color: var(--danger);
  background: #fff;
  border-color: var(--line);
}

.danger-button:hover {
  border-color: var(--danger);
  background: rgba(179, 38, 30, 0.08);
}

.status-pill {
  flex: 0 0 auto;
  padding: 6px 10px;
  color: var(--accent);
  background: rgba(22, 133, 92, 0.1);
  border-radius: 999px;
  font-weight: 850;
}

.empty {
  padding: 28px 10px;
  color: var(--muted);
  text-align: center;
}

.helper {
  padding: 20px 22px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 15px;
  color: #fff;
  background: #17202a;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.toast.error {
  background: var(--danger);
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    grid-template-columns: 1fr;
    padding-top: 10px;
  }

  .panel,
  .helper {
    padding: 18px;
  }

  .blob-table th:nth-child(3),
  .blob-table td:nth-child(3),
  .blob-table th:nth-child(4),
  .blob-table td:nth-child(4) {
    display: none;
  }

  .pad-table th:nth-child(2),
  .pad-table td:nth-child(2) {
    display: none;
  }
}
