:root {
    --bg: #111;
    --panel: #1b1b1b;
    --fg: #eee;
    --muted: #888;
    --accent: #4da3ff;
    --danger: #ff6b6b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Hiragino Sans, "Yu Gothic", sans-serif;
}

a { color: inherit; }
.muted { color: var(--muted); font-size: 0.85rem; }
.error { color: var(--danger); font-size: 0.85rem; }

/* ログイン画面 */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--panel); padding: 32px; border-radius: 12px; width: 90%; max-width: 320px; text-align: center; }
.login-box h1 { margin: 0 0 4px; font-size: 1.3rem; }
.login-box input[type="password"] {
    width: 100%; padding: 10px; margin: 16px 0; border-radius: 6px;
    border: 1px solid #333; background: #0d0d0d; color: var(--fg); font-size: 1rem;
}
.login-box button {
    width: 100%; padding: 10px; border-radius: 6px; border: none;
    background: var(--accent); color: #fff; font-size: 1rem; cursor: pointer;
}

/* ヘッダー */
.site-header { padding: 16px 16px 12px; border-bottom: 1px solid #222; }
.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.breadcrumbs { font-size: 0.9rem; }
.breadcrumbs .crumb { text-decoration: none; padding: 2px 4px; border-radius: 4px; }
.breadcrumbs .crumb:not(.current):hover { text-decoration: underline; }
.breadcrumbs .crumb.drag-over { background: var(--accent); color: #fff; text-decoration: none; }
.breadcrumbs .current { color: var(--muted); }
.breadcrumbs .sep { color: var(--muted); margin: 0 6px; }
.logout-link { font-size: 0.85rem; color: var(--muted); text-decoration: none; }
.logout-link:hover { color: var(--fg); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
    padding: 8px 14px; border-radius: 6px; border: 1px solid #333;
    background: #222; color: var(--fg); font-size: 0.85rem; cursor: pointer;
}
.btn:hover { background: #2a2a2a; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.1); }

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

main { position: relative; min-height: 60vh; }

.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(77,163,255,0.15);
    border: 3px dashed var(--accent);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
}
.drop-overlay p { font-size: 1.3rem; color: var(--accent); background: rgba(0,0,0,0.7); padding: 16px 28px; border-radius: 10px; }
.drop-overlay[hidden] { display: none; }

/* フォルダグリッド */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; padding: 12px; }

.cell { position: relative; }
.folder-cell-wrap.drag-over .folder-cell-link { background: var(--accent); }
.folder-cell-link {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; background: #1c2733; border-radius: 8px; height: 110px; text-decoration: none;
}
.folder-cell-link:hover { background: #223244; }
.folder-icon { font-size: 2.2rem; }
.folder-name { font-size: 0.85rem; text-align: center; padding: 0 8px; word-break: break-word; }

.item-menu {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}
.cell:hover .item-menu, .file-row:hover .item-menu, .file-row .item-menu { opacity: 1; }

.icon-btn {
    width: 26px; height: 26px; border-radius: 50%; border: none;
    background: rgba(0,0,0,0.6); color: #fff; font-size: 0.9rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    text-decoration: none;
}
.icon-btn:hover { background: #444; }
.icon-btn.del-btn:hover { background: var(--danger); }

/* ファイル一覧テーブル */
.file-table { width: 100%; border-collapse: collapse; padding: 0 12px; }
.file-table th, .file-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #222; font-size: 0.85rem; }
.file-table th { color: var(--muted); font-weight: normal; font-size: 0.78rem; }
.file-row { cursor: grab; }
.file-row.drag-ghost { opacity: 0.4; }
.file-row:hover { background: #1a1a1a; }
.col-icon { width: 32px; text-align: center; font-size: 1.1rem; }
.col-name a { text-decoration: none; }
.col-name a:hover { text-decoration: underline; }
.col-size, .col-date { color: var(--muted); white-space: nowrap; }
.col-actions { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.item-menu, .col-actions .icon-btn { position: static; }
.col-actions { position: relative; }

/* モーダル */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); padding: 24px; border-radius: 12px; width: 90%; max-width: 380px; }
.modal-box h2 { margin: 0 0 12px; font-size: 1.1rem; }
.modal-box input[type="text"], .modal-box select {
    width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #333;
    background: #0d0d0d; color: var(--fg); font-size: 1rem; margin-top: 8px;
}
.modal-box input[type="file"] { width: 100%; margin-top: 12px; color: var(--fg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.upload-progress { margin-top: 14px; }
.upload-bar { background: #333; border-radius: 6px; height: 8px; overflow: hidden; }
.upload-bar-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.2s ease; }

@media (max-width: 600px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; padding: 6px; }
    .toolbar { width: 100%; }
    .btn { flex: 1; }
    .file-table { font-size: 0.78rem; }
    .col-date { display: none; }
    .item-menu { opacity: 1; }
}
