* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #e5e5e5;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#reload-btn {
    min-width: 96px;
    justify-content: center;
}

#reload-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.login-card {
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 32px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-card h1 {
    font-size: 18px;
    margin: 0 0 16px;
    text-align: center;
}

.login-card label {
    font-size: 12px;
    opacity: 0.75;
    margin-top: 10px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e5e5e5;
    padding: 8px 10px;
    font-size: 14px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-top: 12px;
}

.checkbox-row input {
    margin: 0;
}

.error-text {
    color: #ff6b6b;
    font-size: 13px;
    min-height: 18px;
    margin-top: 8px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    border: none;
    border-radius: 6px;
    padding: 9px 14px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-accent {
    background: #4f9dff;
    color: #0b1520;
    font-weight: 600;
    margin-top: 16px;
}

.btn-accent:hover {
    background: #6babff;
}

.btn-accent:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-ghost {
    background: transparent;
    color: #e5e5e5;
    border: 1px solid #3a3a3a;
}

.btn-ghost:hover {
    background: #2a2a2a;
}

/* ── File browser page ──────────────────────────────────────── */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #232323;
    border-bottom: 1px solid #333;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.logo {
    background: #4f9dff;
    color: #0b1520;
    font-weight: 700;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}

.toolbar-title {
    font-weight: 600;
    flex-shrink: 0;
}

.current-path {
    opacity: 0.6;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ── Breadcrumbs ────────────────────────────────────────────── */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 13px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
    padding: 2px 4px;
    scrollbar-width: thin;
}

.breadcrumbs[hidden] {
    display: none;
}

.current-path[hidden] {
    display: none;
}

.breadcrumbs::-webkit-scrollbar {
    height: 4px;
}

.breadcrumbs::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 2px;
}

.breadcrumbs .crumb {
    color: #8ab4ff;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s;
    flex-shrink: 0;
}

.breadcrumbs .crumb:hover {
    background: rgba(79, 157, 255, 0.15);
    color: #b0c8ff;
}

.breadcrumbs .crumb-sep {
    opacity: 0.4;
    margin: 0 1px;
    flex-shrink: 0;
}

.breadcrumbs .crumb-current {
    color: #e5e5e5;
    font-weight: 600;
    cursor: default;
    padding: 2px 6px;
    flex-shrink: 0;
}

.breadcrumbs .crumb-current:hover {
    background: transparent;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#file-input {
    display: none;
}

#search-input {
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e5e5e5;
    padding: 7px 10px;
    font-size: 13px;
    width: 180px;
}

.file-name-display {
    font-size: 12px;
    opacity: 0.7;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content {
    flex: 1;
    overflow: auto;
    padding: 12px 16px;
}

table#fileTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#fileTable th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid #333;
    opacity: 0.6;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
}

#fileTable th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.12s, opacity 0.12s;
}

#fileTable th.sortable:hover {
    color: #c8c8c8;
    opacity: 0.9;
}

#fileTable th.sorted {
    color: #8ab4ff;
    opacity: 1;
}

#fileTable th .sort-indicator {
    display: inline-block;
    font-size: 10px;
    margin-left: 3px;
    opacity: 0.8;
    text-transform: none;
}

#fileTable td {
    padding: 8px 10px;
    border-bottom: 1px solid #262626;
    border-top: 1px solid #262626;
}

#fileTable tr:hover {
    background: #212121;
}

#fileTable button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
}

#fileTable button:disabled {
    opacity: 0.5;
    cursor: default;
}

#fileTable td button+button {
    margin-left: 4px;
}

#fileTable td.previewable {
    cursor: pointer;
}

#fileTable td.previewable:hover {
    color: #6babff;
}

/* The file name is a span so only the text itself is the preview target. */
#fileTable span.previewable {
    cursor: pointer;
}

#fileTable span.previewable:hover {
    color: #6babff;
}

/* ── Preview modal ──────────────────────────────────────────── */
.preview-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-modal.hidden {
    display: none;
}

.preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}

.preview-box {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(94vw, 1200px);
    height: min(90vh, 820px);
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.preview-title {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-counter {
    font-size: 12px;
    opacity: 0.6;
}

.preview-close {
    padding: 6px 10px;
}

.preview-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1111119d;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
}

.preview-stage img,
.preview-stage video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Audio sits in the centre like an image, but doesn't try to fill the
   stage — the native player is a small horizontal bar. */
.preview-stage audio {
    width: min(90%, 500px);
    max-width: 100%;
}

.preview-status {
    padding: 16px;
    font-size: 14px;
    opacity: 0.7;
    text-align: center;
}

.preview-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 56px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #e5e5e5;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.preview-nav:hover {
    background: rgba(79, 157, 255, 0.55);
}

.preview-nav:disabled {
    display: none;
}

.preview-prev {
    left: 8px;
}

.preview-next {
    right: 8px;
}

/* ── Upload ─────────────────────────────────────────────────── */
.toolbar-right .btn-accent {
    margin-top: 0;
}

#fileBrowser.drag-over {
    outline: 2px dashed #4f9dff;
    outline-offset: -8px;
    background: rgba(79, 157, 255, 0.06);
}

#fileBrowser td {
    border-top: white 1px solid;
    border-bottom: rgba(255, 255, 255, 0.25) 1px solid;
}

.folder-row {
    background-color: rgba(255, 187, 0, 0.05) !important;
}

.upload-panel {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: 50vh;
    display: flex;
    flex-direction: column;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 50;
}

.upload-panel.hidden {
    display: none;
}

.upload-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #333;
    font-size: 13px;
    font-weight: 600;
}

.upload-panel-header .spacer {
    flex: 1;
}

.upload-summary {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.6;
}

.upload-link {
    background: none;
    border: none;
    color: #4f9dff;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.upload-link:disabled {
    opacity: 0.4;
    cursor: default;
}

.upload-list {
    overflow: auto;
    padding: 4px 12px 8px;
}

.upload-item {
    padding: 8px 0;
    border-bottom: 1px solid #2a2a2a;
}

.upload-item:last-child {
    border-bottom: none;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.upload-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-cancel {
    background: none;
    border: none;
    color: #e5e5e5;
    opacity: 0.6;
    cursor: pointer;
    font-size: 13px;
    padding: 0 2px;
}

.upload-cancel:hover {
    opacity: 1;
}

.upload-cancel:disabled {
    opacity: 0.25;
    cursor: default;
}

.upload-bar {
    height: 6px;
    margin-top: 6px;
    background: #171717;
    border-radius: 3px;
    overflow: hidden;
}

.upload-fill {
    height: 100%;
    width: 0;
    background: #4f9dff;
    transition: width 0.15s linear;
}

.upload-meta {
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.65;
}

.preview-stage iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.preview-text-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.preview-text {
    flex: 1;
    margin: 0;
    padding: 14px 16px;
    overflow: auto;
    font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.preview-note {
    padding: 8px 16px;
    font-size: 12px;
    opacity: 0.7;
    border-top: 1px solid #333;
}

.new-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 1px 6px;
    background: #ffd60a;
    color: #000;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.04em;
    border-radius: 4px;
    vertical-align: middle;
}

.upload-item.finalizing .upload-fill {
    background: #d9a441;
}

.upload-item.done .upload-fill {
    background: #4cc38a;
}

.upload-item.error .upload-fill {
    background: #ff6b6b;
}

.upload-item.error .upload-meta {
    color: #ff6b6b;
    opacity: 1;
}

.upload-item.cancelled .upload-fill {
    background: #666;
    width: 100%;
}

.upload-item.queued .upload-fill {
    width: 0;
}

/* ── Per-file comments (guestbook) ─────────────────────────── */
#fileTable tr.commentable {
    cursor: pointer;
}

#fileTable tr.comments-open {
    background: #212121;
}

#fileTable tr.comments-row:hover {
    background: transparent;
}

#fileTable tr.comments-row>td {
    padding: 0;
    border-bottom: 1px solid #333;
}

.comments-panel {
    padding: 10px 14px 14px;
    background: #1d1d1d;
    border-left: 3px solid #4f9dff;
}

.comments-list {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.comments-empty {
    opacity: 0.55;
    font-size: 13px;
    padding: 6px 0;
}

.comment {
    padding: 8px 0;
    border-bottom: 1px solid #2a2a2a;
}

.comment:last-child {
    border-bottom: none;
}

.comment-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 3px;
}

.comment-id {
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.comment-you {
    opacity: 0.55;
    font-style: italic;
}

.comment-time {
    opacity: 0.5;
    margin-left: auto;
    font-size: 11px;
}

.comment-text {
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.comments-form textarea {
    width: 100%;
    resize: vertical;
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e5e5e5;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    min-height: 44px;
}

.comments-form textarea:focus {
    outline: none;
    border-color: #4f9dff;
}

.comments-form-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.comments-count {
    font-size: 11px;
    opacity: 0.5;
    white-space: nowrap;
}

.comments-error {
    font-size: 12px;
    color: #ff6b6b;
    flex: 1;
}

.comments-send {
    background: #4f9dff;
    color: #0b1520;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
}

.comments-send:hover:not(:disabled) {
    background: #6babff;
}

.comments-send:disabled {
    opacity: 0.6;
    cursor: default;
}

/* ── Comment count badge in file rows ──────────────────────── */
.comment-count-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 11px;
    line-height: 1.5;
    color: #8ab4ff;
    background: rgba(79, 157, 255, 0.14);
    border-radius: 8px;
    vertical-align: middle;
    font-weight: 500;
    white-space: nowrap;
}

#fileTable td.previewable .comment-count-badge {
    color: #8ab4ff;
}

/* ── Activity log sidebar ──────────────────────────────────── */
.logs-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.logs-backdrop.hidden {
    display: none;
}

.logs-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 92vw;
    display: flex;
    flex-direction: column;
    background: #1d1d1d;
    border-left: 1px solid #333;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
    z-index: 95;
}

.logs-sidebar.hidden {
    display: none;
}

.logs-sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid #333;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.logs-sidebar-header .spacer {
    flex: 1;
}

.logs-summary {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.6;
}

.logs-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 14px 14px;
}

.logs-empty {
    opacity: 0.55;
    font-size: 13px;
    padding: 16px 0;
    text-align: center;
}

.log-entry {
    padding: 10px 0;
    border-bottom: 1px solid #2a2a2a;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 12px;
}

.log-entry-id {
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    flex-shrink: 0;
}

.log-entry-action {
    font-weight: 600;
    flex: 1;
}

.log-entry-time {
    opacity: 0.5;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
}

.log-entry-meta {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.75;
    word-break: break-word;
}

.log-entry-error {
    margin-top: 4px;
    font-size: 12px;
    color: #ff6b6b;
    word-break: break-word;
}

.log-entry-failure .log-entry-action {
    color: #ff9e9e;
}

/* ── Personal accounts ─────────────────────────────────────── */
.account-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(79, 157, 255, 0.15);
    color: #8ab4ff;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* The register form lives inside <details>. The parent login card uses
   flex, but `<details>` wraps its content in an internal slot that
   doesn't reliably participate in flex layout, so use plain block flow
   inside it and force inputs onto their own line with width: 100%. */
.login-card details {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #333;
}

.login-card summary {
    cursor: pointer;
    font-size: 13px;
    opacity: 0.8;
    outline: none;
    padding: 2px 0;
    user-select: none;
}

.login-card summary:hover {
    opacity: 1;
}

.login-card details[open] summary {
    margin-bottom: 6px;
}

.login-card details .hint {
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.45;
    opacity: 0.6;
}

/* Labels and inputs each take their own row. This is what was missing:
   without display:block + width:100% the input is inline-block and the
   next label flows onto the same line. */
.login-card details label {
    display: block;
    font-size: 12px;
    opacity: 0.75;
    margin-top: 10px;
}

.login-card details input[type="text"],
.login-card details input[type="password"] {
    display: block;
    width: 100%;
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e5e5e5;
    padding: 8px 10px;
    font-size: 14px;
    margin-top: 4px;
}

.login-card details input[type="text"]:focus,
.login-card details input[type="password"]:focus {
    outline: none;
    border-color: #4f9dff;
}

#register-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
}

#registerError {
    margin-top: 8px;
    min-height: 0;
}
/* ── Rating column & fractional star widget ────────────────── */

#fileTable td.rating-cell {
    white-space: nowrap;
    width: 130px;
}

.rating-widget {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    line-height: 1;
    vertical-align: middle;
}

.rating-widget .stars {
    position: relative;
    display: inline-block;
    cursor: pointer;
    user-select: none;
    letter-spacing: 1px;
    font-size: 15px;
}

/* Grey track behind the fill. */
.rating-widget .stars-track {
    color: #3a3a3a;
}

/* Gold overlay, width set inline by JS to the fractional value. */
.rating-widget .stars-fill {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    white-space: nowrap;
    color: #ffd60a;
    pointer-events: none;
    letter-spacing: 1px;
}

.rating-widget .rating-count {
    color: #8a8a8a;
    font-size: 11px;
}

.rating-widget .stars:hover .stars-track {
    color: #4a4a4a;
}

/* ── Digest modal ──────────────────────────────────────────── */
.digest-modal .digest-box {
    width: min(560px, 92vw);
    height: auto;
    max-height: 88vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.digest-modal .preview-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.digest-modal .preview-title {
    font-size: 15px;
}

.digest-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding-right: 4px;
}

.digest-hint {
    margin: 0;
    font-size: 12px;
    opacity: 0.65;
    line-height: 1.5;
}

/* Section = label + content, consistent spacing everywhere. */
.digest-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.digest-section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.6;
}

.digest-input {
    width: 100%;
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e5e5e5;
    padding: 8px 10px;
    font-size: 14px;
    box-sizing: border-box;
}

.digest-input:focus {
    outline: none;
    border-color: #4f9dff;
}

.digest-input-number {
    width: 60px;
    text-align: center;
    padding: 6px 4px;
    font-size: 13px;
    -moz-appearance: textfield;
    appearance: textfield;
}

.digest-input-number::-webkit-outer-spin-button,
.digest-input-number::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ── Subscribe row (folder · every N hours · button) ──────── */
.digest-subscribe-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.digest-folder-chip {
    flex: 1;
    min-width: 120px;
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 8px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #8ab4ff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.digest-interval-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.digest-interval-prefix,
.digest-interval-unit {
    font-size: 12px;
    opacity: 0.65;
}

.digest-subscribe-row .btn-accent {
    margin-top: 0;
    padding: 8px 14px;
    font-size: 13px;
}

.digest-subscribe-hint {
    font-size: 11px;
    opacity: 0.5;
}

/* ── Subscriptions list ──────────────────────────────────── */
.digest-section-list {
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid #333;
}

.digest-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.digest-empty {
    opacity: 0.5;
    font-size: 13px;
    padding: 6px 0;
}

.digest-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: #1d1d1d;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    transition: opacity 0.15s;
}

.digest-row.digest-row-saving {
    opacity: 0.55;
}

.digest-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.digest-path {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: #e5e5e5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.digest-remove {
    background: none;
    border: none;
    color: #e5e5e5;
    opacity: 0.5;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    line-height: 1;
}

.digest-remove:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.15);
    color: #ff8a8a;
}

.digest-row-bottom {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.85;
}

.digest-row-every,
.digest-row-unit {
    opacity: 0.65;
    font-size: 12px;
}

.digest-row-interval {
    width: 52px;
    padding: 4px 6px;
    font-size: 12px;
}

.digest-row-sep {
    opacity: 0.4;
    margin: 0 2px;
}

.digest-when {
    opacity: 0.65;
    font-size: 12px;
}
/* ── Info modal ────────────────────────────────────────────── */
.info-modal .info-box {
    width: min(520px, 92vw);
    height: auto;
    max-height: 85vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.info-modal .preview-header {
    padding-bottom: 8px;
}

.info-modal .preview-title {
    font-size: 16px;
}

.info-body {
    overflow-y: auto;
    padding-right: 4px;
}

.info-divider {
    border: 0;
    border-top: 1px solid #3a3a3a;
    margin: 0 0 14px;
}

.info-sections {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.info-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.info-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #8ab4ff;
}

.info-section-text {
    font-size: 13px;
    line-height: 1.5;
    color: #d0d0d0;
}
/* ── Read-only rating widget (used for folder aggregates) ──────── */
.rating-widget.rating-readonly {
    opacity: 0.85;
}

.rating-widget.rating-readonly .stars {
    cursor: default;
}

/* No hover highlight on read-only widgets. */
.rating-widget.rating-readonly .stars:hover .stars-track {
    color: #3a3a3a;
}
/* ── Login page: column wrapper + READ THIS button ─────────────── */
.login-column {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    width: 320px;
}

.read-this-btn {
    background: transparent;
    border: 1px dashed #4a4a4a;
    border-radius: 8px;
    color: #8ab4ff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 10px 14px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.read-this-btn:hover {
    border-color: #4f9dff;
    background: rgba(79, 157, 255, 0.08);
    color: #b0c8ff;
}

.read-this-btn:active {
    background: rgba(79, 157, 255, 0.14);
}
/* ── Upload disabled (no permission) ──────────────────────────── */
/* The button stays visible but reads as unavailable, with a clearer
   look than just a dimmed accent. */
#upload-btn:disabled,
#upload-btn.btn-accent:disabled {
    background: #2f2f2f;
    color: #7a7a7a;
    border: 1px solid #3a3a3a;
    cursor: not-allowed;
    opacity: 1;
}

/* Belt and braces: while uploads are disabled, never show drag-drop
   affordances. (upload.js also skips wiring them entirely.) */
body.no-upload #fileBrowser.drag-over {
    outline: none;
    background: transparent;
}
/* ── View modes (table / grid) ─────────────────────────────── */

#fileBrowser.view-grid #fileTable {
    display: none;
}

#fileBrowser:not(.view-grid) #fileGrid {
    display: none;
}

/* ── Compact grid ──────────────────────────────────────────── */

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    padding: 4px 0;
}

.file-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: #1f1f1f;
    border: 1px solid #2e2e2e;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, transform 0.08s;
    min-width: 0;
    text-align: left;
    font: inherit;
    color: inherit;
    overflow: hidden;
}

.file-card:hover {
    background: #232323;
    border-color: #3a3a3a;
}

.file-card.comments-open {
    background: #212121;
    border-color: #4f9dff;
}

.file-card.folder-card {
    background: rgba(255, 187, 0, 0.05);
    border-color: rgba(255, 187, 0, 0.15);
}

.file-card.folder-card:hover {
    background: rgba(255, 187, 0, 0.09);
    border-color: rgba(255, 187, 0, 0.3);
}

/* ── Thumbnail cell ────────────────────────────────────────── */

.card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #141414;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}

.card-thumb-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    opacity: 0.35;
    line-height: 1;
    user-select: none;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 0;
}

.card-thumb-img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
}

.card-thumb-icon {
    font-size: 48px;
    opacity: 0.55;
    line-height: 1;
    user-select: none;
    pointer-events: none;
}

.card-thumb-folder {
    font-size: 52px;
    opacity: 0.7;
    background: rgba(255, 187, 0, 0.06);
}

/* Spacer cards ("Go up" / "Back to browsing") don't get a thumbnail
   but keep the same column-spanning layout. */
.file-card-spacer {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 14px;
    background: #171717;
    border: 1px dashed #3a3a3a;
    color: #8ab4ff;
    font-size: 13px;
}

.file-card-spacer:hover {
    background: #1d1d1d;
    border-color: #4f9dff;
    border-style: dashed;
}

/* ── Card internals ────────────────────────────────────────── */

.file-card-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
}

.file-card-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.file-card-name-text.previewable:hover {
    color: #6babff;
}

.file-card .comment-count-badge {
    flex-shrink: 0;
    margin-left: 0;
}

.file-card-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    opacity: 0.65;
    overflow: hidden;
    white-space: nowrap;
    flex-wrap: wrap;
    row-gap: 2px;
}

.file-card-sep {
    opacity: 0.6;
}

.file-card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 22px;
}

.file-card-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.file-card-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 2px 5px;
    border-radius: 4px;
    opacity: 0.85;
    color: inherit;
}

.file-card-actions button:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.07);
}

.file-card-actions button:disabled {
    opacity: 0.4;
    cursor: default;
}

.file-card .rating-cell {
    width: auto;
}

/* Comment panel in grid mode: span every column. */
.comments-row-card {
    grid-column: 1 / -1;
    min-width: 0;
}

.comments-row-card .comments-panel {
    padding: 10px 14px 14px;
}
/* ── Grid sort bar ─────────────────────────────────────────── */
/* Lives above the file list. Hidden in table mode, where the <th>
   headers already do the same job. */
.sort-bar {
    margin-left: 40%;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 2px 0 12px;
}

#fileBrowser.view-grid .sort-bar {
    display: flex;
}

.sort-bar-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.55;
    margin-right: 2px;
}

.sort-btn {
    background: transparent;
    border: 1px solid #333;
    border-radius: 6px;
    color: #b5b5b5;
    padding: 4px 11px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.sort-btn:hover {
    border-color: #4a4a4a;
    color: #e5e5e5;
}

.sort-btn.active {
    border-color: #4f9dff;
    color: #8ab4ff;
    background: rgba(79, 157, 255, 0.08);
}

.sort-btn .sort-indicator {
    font-size: 10px;
    opacity: 0.9;
    display: inline-block;
    text-transform: none;
    margin-left: 0;
    letter-spacing: 0;
}
/* ── Share links manager modal ─────────────────────────────── */
.links-modal .links-box {
    width: min(560px, 92vw);
    height: auto;
    max-height: 88vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.links-modal .preview-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
    align-items: baseline;
}

.links-modal .preview-title {
    font-size: 15px;
}

.links-count {
    font-size: 12px;
    opacity: 0.55;
    margin-left: 6px;
    font-variant-numeric: tabular-nums;
}

.links-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    padding-right: 4px;
}

.links-hint {
    margin: 0;
    font-size: 12px;
    opacity: 0.65;
    line-height: 1.5;
}

.links-notice {
    padding: 8px 10px;
    background: rgba(255, 187, 0, 0.08);
    border: 1px solid rgba(255, 187, 0, 0.25);
    border-radius: 6px;
    color: #ffd07a;
    font-size: 12px;
    line-height: 1.45;
}

.links-notice.hidden {
    display: none;
}

.links-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.links-empty {
    opacity: 0.5;
    font-size: 13px;
    padding: 14px 0;
    text-align: center;
}

.links-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: #1d1d1d;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    transition: opacity 0.15s;
}

.links-row.links-row-saving {
    opacity: 0.55;
}

.links-row-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.links-row-icon {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
    opacity: 0.85;
}

.links-row-path {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: #e5e5e5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.links-remove {
    background: none;
    border: none;
    color: #e5e5e5;
    opacity: 0.5;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    line-height: 1;
}

.links-remove:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.15);
    color: #ff8a8a;
}

.links-row-bottom {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.7;
    padding-left: 22px;
}

.links-row-sep {
    opacity: 0.5;
}
/* ── Folder explorer panel ───────────────────────────────────── */
.tree-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.tree-backdrop.hidden {
    display: none;
}

.tree-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 460px;
    max-width: 94vw;
    display: flex;
    flex-direction: column;
    background: #1d1d1d;
    border-left: 1px solid #333;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
    z-index: 96;
}

.tree-panel.hidden {
    display: none;
}

.tree-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid #333;
    font-size: 15px;
    font-weight: 600;
    flex-shrink: 0;
}

.tree-header .spacer {
    flex: 1;
}

.tree-title {
    flex-shrink: 0;
}

.tree-summary {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.6;
}

.tree-refresh,
.tree-close {
    background: none;
    border: none;
    color: #e5e5e5;
    cursor: pointer;
    font-size: 15px;
    opacity: 0.65;
    padding: 3px 8px;
    border-radius: 4px;
    line-height: 1;
}

.tree-refresh:hover,
.tree-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.07);
}

.tree-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.tree-tabs button {
    flex: 1;
    background: none;
    border: none;
    color: #b5b5b5;
    padding: 11px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.12s, border-color 0.12s;
}

.tree-tabs button:hover {
    color: #e5e5e5;
}

.tree-tabs button.active {
    color: #8ab4ff;
    border-bottom-color: #4f9dff;
}

.tree-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 14px;
}

.tree-footer {
    border-top: 1px solid #333;
    padding: 9px 18px;
    font-size: 12px;
    opacity: 0.55;
    flex-shrink: 0;
    min-height: 32px;
    text-align: right;
}

.tree-status {
    padding: 24px 20px;
    font-size: 14px;
    opacity: 0.6;
    text-align: center;
}

.tree-status.tree-error {
    color: #ff8a8a;
    opacity: 0.9;
}

.tree-list {
    display: flex;
    flex-direction: column;
}

/* ── Folder nodes ─────────────────────────────────────────────── */
.tree-node {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px 6px 0;
    font-size: 14px;
    cursor: pointer;
    color: #e5e5e5;
    border-radius: 4px;
    margin: 0 8px;
    user-select: none;
}

.tree-node:hover {
    background: rgba(79, 157, 255, 0.1);
}

.tree-node-root {
    font-weight: 600;
    color: #8ab4ff;
}

.tree-toggle {
    background: none;
    border: none;
    color: #b5b5b5;
    cursor: pointer;
    font-size: 12px;
    width: 18px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.75;
}

.tree-toggle:hover:not(:disabled) {
    color: #e5e5e5;
    opacity: 1;
}

.tree-toggle:disabled {
    cursor: default;
    opacity: 0.3;
}

.tree-icon {
    font-size: 13px;
    flex-shrink: 0;
    opacity: 0.85;
}

.tree-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.tree-count {
    font-size: 11px;
    opacity: 0.5;
    flex-shrink: 0;
    padding: 1px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

/* ── File rows (recent / rated) ───────────────────────────────── */
.tree-file {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 18px;
    cursor: pointer;
    border-bottom: 1px solid #252525;
    min-width: 0;
}

.tree-file:hover {
    background: rgba(79, 157, 255, 0.08);
}

.tree-file-name {
    display: flex;
    align-items: baseline;
    gap: 7px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.tree-file-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    color: #e5e5e5;
}

.tree-file-stars {
    color: #ffd60a;
    font-size: 13px;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.tree-file-rating {
    color: #8a8a8a;
    font-size: 12px;
    flex-shrink: 0;
}

.tree-file-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.6;
    overflow: hidden;
    white-space: nowrap;
}

.tree-file-folder {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65%;
}

.tree-file-sep {
    opacity: 0.5;
}
/* ── Language chip, cell, and filter ─────────────────────────── */

/* Compact flag-only chip — used in grid cards. */
.lang-chip {
    display: inline-block;
    flex-shrink: 0;
    font-size: 13px;
    line-height: 1;
    cursor: help;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

.lang-chip[hidden] {
    display: none;
}

/* Full "🇬🇧 English" cell content — used in table rows. */
.lang-cell {
    white-space: nowrap;
    max-width: 140px;
}

.lang-cell-full {
    display: inline-block;
    font-size: 13px;
    line-height: 1.3;
    cursor: help;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    vertical-align: middle;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.lang-cell-full[hidden] {
    display: none;
}

/* The header cell that holds the filter dropdown. */
th.lang-th {
    padding: 4px 6px;
    text-transform: none;
}

/* Filter dropdown styled to look integrated with the header row. */
.lang-filter {
    width: 100%;
    min-width: 90px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: inherit;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    opacity: 0.7;
    cursor: pointer;
    padding: 4px 6px;
    transition: border-color 0.12s, background 0.12s, opacity 0.12s;
}

.lang-filter:hover {
    border-color: #3a3a3a;
    background: #171717;
    opacity: 1;
}

.lang-filter:focus {
    outline: none;
    border-color: #4f9dff;
    opacity: 1;
}

/* Same dropdown, in the grid sort bar. */
.lang-filter-grid {
    background: transparent;
    border: 1px solid #333;
    border-radius: 6px;
    color: #b5b5b5;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.lang-filter-grid:hover {
    border-color: #4a4a4a;
    color: #e5e5e5;
}

.lang-filter-grid:focus {
    outline: none;
    border-color: #4f9dff;
    color: #8ab4ff;
    background: rgba(79, 157, 255, 0.08);
}

/* Rows hidden by the language filter. */
tr.lang-filtered,
.file-card.lang-filtered {
    display: none;
}
/* No-speech classification: files with no detectable text or audio.
   Shown regardless of the active language filter, so they carry no
   data-lang attribute and never get the .lang-filtered class. */
.lang-cell-full.lang-nospeech,
.lang-chip.lang-nospeech {
    opacity: 0.45;
    font-style: italic;
    font-size: 12px;
}

.lang-cell-full.lang-nospeech {
    font-family: inherit;
}
/* ── Upload modal ─────────────────────────────────────────── */
.upload-modal .upload-modal-box {
    width: min(520px, 92vw);
    height: auto;
    max-height: 88vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.upload-modal .preview-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.upload-modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding-right: 4px;
}

.upload-modal-tabs {
    display: flex;
    border-bottom: 1px solid #333;
}

.upload-tab {
    flex: 1;
    background: none;
    border: none;
    color: #b5b5b5;
    padding: 10px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.12s, border-color 0.12s;
}

.upload-tab:hover {
    color: #e5e5e5;
}

.upload-tab.active {
    color: #8ab4ff;
    border-bottom-color: #4f9dff;
}

.upload-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.upload-pane.hidden {
    display: none;
}

.upload-pane-hint {
    margin: 0;
    font-size: 12px;
    opacity: 0.65;
    line-height: 1.5;
}

.upload-pane-hint-small {
    font-size: 11px;
    opacity: 0.5;
}

.upload-pane-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.6;
    margin-top: 4px;
}

.upload-format-row {
    display: flex;
    gap: 8px;
}

.upload-format {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: #1d1d1d;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: border-color 0.12s, background 0.12s;
}

.upload-format:hover {
    border-color: #4a4a4a;
}

.upload-format input {
    margin: 0;
}

.upload-format:has(input:checked) {
    border-color: #4f9dff;
    background: rgba(79, 157, 255, 0.08);
}

.upload-format span {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.upload-format small {
    font-size: 10px;
    opacity: 0.6;
    font-weight: 400;
}
/* ── Account usage indicator ───────────────────────────────── */
.account-usage {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: #b5b5b5;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.account-usage.near-limit {
    background: rgba(255, 187, 0, 0.12);
    color: #ffd07a;
}

.account-usage.over-limit {
    background: rgba(255, 107, 107, 0.15);
    color: #ff9e9e;
}

.account-usage.unlimited {
    color: #8ab4ff;
    background: rgba(79, 157, 255, 0.1);
}
/* ── Filename confirmation modal ───────────────────────────── */
.naming-modal .naming-box {
    width: min(560px, 92vw);
    height: auto;
    max-height: 88vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.naming-modal .preview-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.naming-hint {
    margin: 0;
    font-size: 12px;
    opacity: 0.65;
    line-height: 1.5;
}

.naming-list {
    flex: 1;
    min-height: 80px;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.naming-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #1d1d1d;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
}

.naming-icon {
    flex-shrink: 0;
    font-size: 18px;
    line-height: 1.2;
    opacity: 0.75;
    padding-top: 2px;
}

.naming-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.naming-original {
    font-size: 11px;
    opacity: 0.5;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.naming-input {
    width: 100%;
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e5e5e5;
    padding: 7px 10px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    box-sizing: border-box;
}

.naming-input:focus {
    outline: none;
    border-color: #4f9dff;
    background: #1a1a1a;
}

.naming-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid #333;
}

.naming-footer .error-text {
    flex: 1;
    min-height: 0;
   
    margin: 0;
}/* ── Compact toolbar ──────────────────────────────────────── */
.toolbar {
    padding: 8px 12px;
    gap: 10px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.toolbar-right .btn {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 5px;
    line-height: 1.2;
}

.toolbar-right .btn-accent {
    padding: 6px 12px;
}

.search-wrap {
    display: flex;
    align-items: center;
}

.search-wrap input {
    background: #171717;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e5e5e5;
    padding: 6px 10px;
    font-size: 12px;
    width: 160px;
    outline: none;
}

.search-wrap input:focus {
    border-color: #4f9dff;
}

/* ── Hover-triggered "More" dropdown ──────────────────────── */
.toolbar-more {
    position: relative;
    /* Extend the hover area below the trigger by 8px without
       affecting layout, so the mouse can travel from the button
       into the dropdown without crossing a dead zone. */
    padding-bottom: 8px;
    margin-bottom: -8px;
}

.toolbar-more-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 220px;
    background: #232323;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 6px;
    z-index: 40;
    display: none;
    flex-direction: column;
    gap: 1px;
}

.toolbar-more:hover .toolbar-more-dropdown {
    display: flex;
}

.toolbar-more-dropdown button {
    background: none;
    border: none;
    color: #e5e5e5;
    padding: 8px 12px;
    text-align: left;
    font-size: 13px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.toolbar-more-dropdown button:hover {
    background: #2d2d2d;
}

.toolbar-more-dropdown button:disabled {
    opacity: 0.5;
    cursor: default;
}

.toolbar-more-dropdown button.menu-danger {
    color: #ff8a8a;
}

.toolbar-more-dropdown button.menu-danger:hover {
    background: rgba(255, 107, 107, 0.12);
}

.toolbar-more-dropdown .menu-sep {
    height: 1px;
    background: #333;
    margin: 4px 6px;
}

/* ── Personal folder modal ─────────────────────────────────── */
.personal-folder-modal .pf-box {
    width: min(500px, 92vw);
    height: auto;
    max-height: 88vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.personal-folder-modal .preview-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.pf-hint {
    margin: 0;
    font-size: 12px;
    opacity: 0.7;
    line-height: 1.5;
}

.pf-hint code {
    background: #171717;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pf-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.6;
    margin-top: 4px;
}

.pf-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.pf-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #333;
}
/* ── Personal folder modal ─────────────────────────────────── */
.personal-folder-modal .pf-box {
    width: min(500px, 92vw);
    height: auto;
    max-height: 88vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.personal-folder-modal .preview-header {
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

.pf-hint {
    margin: 0;
    font-size: 12px;
    opacity: 0.7;
    line-height: 1.5;
}

.pf-hint code {
    background: #171717;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pf-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.6;
    margin-top: 4px;
}

.pf-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.pf-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #333;
}
/* ── Row kebab menu ───────────────────────────────────────── */
.kebab-btn {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.75;
    font-family: inherit;
}

.kebab-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
}

.kebab-menu {
    position: fixed;
    background: #232323;
    border: 1px solid #333;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 4px;
    min-width: 140px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.kebab-menu button {
    background: none;
    border: none;
    color: #e5e5e5;
    text-align: left;
    padding: 7px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    font-family: inherit;
    white-space: nowrap;
}

.kebab-menu button:hover {
    background: #2d2d2d;
}

.kebab-menu button.menu-danger {
    color: #ff8a8a;
}

.kebab-menu button.menu-danger:hover {
    background: rgba(255, 107, 107, 0.12);
}

#fileTable td button+button,
#fileTable td button+.kebab-btn,
#fileTable td .kebab-btn+button {
    margin-left: 2px;
}
/* ── Selection: bar, checkboxes, drag & drop ─────────────────── */

.selection-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    background: linear-gradient(180deg, rgba(79, 157, 255, 0.14), rgba(79, 157, 255, 0.05));
    border: 1px solid rgba(79, 157, 255, 0.35);
    border-radius: 8px;
    font-size: 13px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.selection-bar.hidden {
    display: none;
}

.selection-bar .spacer {
    flex: 1;
}

.selection-count {
    font-weight: 600;
    color: #b0c8ff;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(79, 157, 255, 0.18);
    white-space: nowrap;
}

.selection-bar .btn {
    padding: 6px 12px;
    font-size: 12px;
}

.selection-bar .btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Checkbox column in the table */
#fileTable th.select-col,
#fileTable td.select-col {
    width: 34px;
    padding-left: 10px;
    padding-right: 4px;
    text-align: center;
}

.row-checkbox-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.row-checkbox {
    width: 15px;
    height: 15px;
    accent-color: #4f9dff;
    cursor: pointer;
    margin: 0;
}

/* Selected rows get a subtle highlight. */
#fileTable tr.selected {
    background: rgba(79, 157, 255, 0.09);
}

#fileTable tr.selected:hover {
    background: rgba(79, 157, 255, 0.14);
}

/* Grid cards: checkbox floating top-left */
.file-card {
    position: relative;
}

.file-card .card-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 4px;
    padding: 3px;
    opacity: 0.35;
    transition: opacity 0.12s;
}

.file-card:hover .card-checkbox,
.file-card.selected .card-checkbox {
    opacity: 1;
}

.file-card.selected {
    border-color: #4f9dff;
    background: rgba(79, 157, 255, 0.08);
}

.file-card.selected:hover {
    background: rgba(79, 157, 255, 0.12);
}

/* Drag & drop */
#fileTable tr.dragging,
.file-card.dragging {
    opacity: 0.5;
}

#fileTable tr.drop-target {
    outline: 2px dashed #4f9dff;
    outline-offset: -2px;
    background: rgba(79, 157, 255, 0.16) !important;
}

.file-card.drop-target {
    outline: 2px dashed #4f9dff;
    outline-offset: -2px;
    background: rgba(79, 157, 255, 0.16) !important;
}

/* ── Confirm modal ──────────────────────────────────────────── */
.confirm-modal .confirm-box,
.prompt-modal .prompt-box,
.move-modal .move-box {
    width: min(500px, 92vw);
    height: auto;
    max-height: 85vh;
    background: #232323;
    border: 1px solid #333;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.confirm-body,
.prompt-body {
    padding: 4px 0;
    overflow-y: auto;
}

.confirm-message,
.prompt-message {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.confirm-footer,
.prompt-footer,
.move-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid #333;
}

.confirm-footer .btn,
.prompt-footer .btn,
.move-footer .btn {
    margin-left: auto;
}

.confirm-footer .btn+.btn,
.prompt-footer .btn+.btn,
.move-footer .btn+.btn {
    margin-left: 0;
}

.confirm-footer .btn-ghost,
.prompt-footer .btn-ghost,
.move-footer .btn-ghost {
    margin-left: 0 !important;
}

.move-footer .error-text {
    flex: 1;
    min-height: 0;
    margin: 0;
}

/* ── Move picker ─────────────────────────────────────────────── */
.move-modal .move-box {
    width: min(560px, 92vw);
    height: min(80vh, 700px);
}

.move-hint {
    margin: 0;
    font-size: 12px;
    opacity: 0.7;
    line-height: 1.5;
}

.move-search-wrap input {
    width: 100%;
}

.move-tree {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    border: 1px solid #2f2f2f;
    border-radius: 6px;
    background: #1a1a1a;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
}
.move-node {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 4px 0;
    font-size: 13px;
    min-width: 0;
    border-radius: 4px;
    margin: 1px 6px;
    user-select: none;
}

.move-node:hover {
    background: #262626;
}

.move-node.picked {
    background: rgba(79, 157, 255, 0.18);
}

.move-node.picked .move-label {
    color: #b0c8ff;
    font-weight: 600;
}

.move-chevron {
    background: none;
    border: none;
    color: #888;
    width: 22px;
    height: 22px;
    padding: 0;
    cursor: pointer;
    font-size: 11px;
    flex-shrink: 0;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    line-height: 1;
}

.move-chevron:hover:not(:disabled) {
    background: #333;
    color: #eee;
}

.move-chevron:disabled {
    opacity: 0.35;
    cursor: default;
}

.move-icon {
    flex-shrink: 0;
    font-size: 13px;
    opacity: 0.85;
    line-height: 1;
}

.move-label {
    flex: 1;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    padding: 2px 6px;
    border-radius: 3px;
}

.move-label:hover {
    background: rgba(79, 157, 255, 0.08);
}

.move-empty {
    padding: 24px 16px;
    font-size: 13px;
    opacity: 0.55;
    text-align: center;
}

.move-count {
    font-size: 12px;
    opacity: 0.6;
    margin-left: 4px;
    font-weight: 400;
}

.move-empty {
    padding: 24px 16px;
    font-size: 13px;
    opacity: 0.55;
    text-align: center;
}

.move-count {
    font-size: 12px;
    opacity: 0.6;
    margin-left: 4px;
    font-weight: 400;
}

/* Danger button */
.btn-danger {
    background: #d64545;
    color: #fff;
    font-weight: 600;
}

.btn-danger:hover {
    background: #e35a5a;
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Kebab menu danger item already styled; ensure disabled state works */
.kebab-menu button:disabled {
    opacity: 0.4;
    cursor: default;
}