:root {
  --bg: #faf9f7;
  --panel: #ffffff;
  --border: #e3ded7;
  --text: #2b2620;
  --text-muted: #7a7368;
  --accent: #a6805a;
  --accent-dark: #8a6740;
  --danger: #b3564a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--accent-dark); }

/* 認証系ページ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 420px;
  width: 100%;
}

.auth-card h1 {
  font-size: 1.25rem;
  margin: 0 0 16px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}

button {
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}

button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--accent-dark); }

.error { color: var(--danger); font-size: 0.9rem; }
.hint { color: var(--text-muted); font-size: 0.85rem; }
.totp-secret {
  font-family: ui-monospace, monospace;
  font-size: 1.1rem;
  letter-spacing: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  word-break: break-all;
}

/* アプリ本体 */
#app, #shareApp { max-width: 1120px; margin: 0 auto; padding: 24px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.topbar h1 { font-size: 1.15rem; margin: 0; flex: 0 0 auto; }
.usage-meter { color: var(--text-muted); font-size: 0.85rem; flex: 1; }
.logout-link { font-size: 0.85rem; }

.breadcrumb { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 12px; }
.breadcrumb a { cursor: pointer; }
.breadcrumb span.sep { margin: 0 6px; }

/* 左のフォルダツリー */
.layout { display: flex; gap: 20px; align-items: flex-start; }

.folder-tree {
  flex: 0 0 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  max-height: 70vh;
  overflow-y: auto;
  font-size: 0.88rem;
}

.main-content { flex: 1 1 auto; min-width: 0; }

.tree-root, .folder-tree ul { list-style: none; margin: 0; padding: 0; }
.tree-node { }
.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.tree-row:hover { background: #faf6f0; }
.tree-row.active { background: #f3e8d8; font-weight: 600; }
.tree-row.drop-target { background: #e8d9bd; outline: 1px dashed var(--accent); }
.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
  flex: none;
}
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-empty-hint { color: var(--text-muted); padding: 6px; font-size: 0.85rem; }

@media (max-width: 700px) {
  .layout { flex-direction: column; }
  .folder-tree { flex: none; width: 100%; max-height: 200px; }
}

.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

.dropzone {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 200px;
}

.dropzone.dragover { border-color: var(--accent); background: #fdf7ef; }

.file-table { width: 100%; border-collapse: collapse; }
.file-table th, .file-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.file-table th { color: var(--text-muted); font-weight: 500; font-size: 0.82rem; }
.file-table tr.folder-row { cursor: pointer; }
.file-table tr:hover { background: #faf6f0; }
.file-table tr.drop-target { background: #e8d9bd; outline: 1px dashed var(--accent); outline-offset: -2px; }
.file-table tr[draggable="true"] { cursor: grab; }
.col-check { width: 32px; }

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

.upload-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.upload-panel h2 { font-size: 1rem; margin: 0 0 10px; }
.upload-panel ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.upload-item { font-size: 0.88rem; }
.upload-item .progress-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-top: 4px;
}
.upload-item .progress-fill { height: 100%; background: var(--accent); width: 0%; }

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 90%;
}

dialog h2 { font-size: 1.05rem; margin: 0 0 12px; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; color: var(--text-muted); }
dialog label input[type="checkbox"] { align-self: flex-start; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.move-folder-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.move-folder-list li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.move-folder-list li:last-child { border-bottom: none; }
.move-folder-list li:hover { background: #faf6f0; }
.move-folder-list .empty-hint { color: var(--text-muted); cursor: default; }
.move-folder-list .empty-hint:hover { background: none; }

.shares-section { margin-top: 32px; }
.shares-section h2 { font-size: 1rem; }
.shares-table { width: 100%; border-collapse: collapse; }
.shares-table th, .shares-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.85rem; text-align: left; }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .file-table th:nth-child(3), .file-table td:nth-child(3) { display: none; }
}
