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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card-bg: #fff;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ヘッダー */
header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); }
.header-right { display: flex; align-items: center; gap: 1rem; }

/* ボタン */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-outline {
  display: inline-block;
  border: 2px solid var(--primary);
  color: var(--primary);
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  text-align: center;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .875rem;
  padding: .25rem;
}
.btn-text:hover { color: var(--text); }

.btn-copy {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: .3rem .75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8rem;
}
.btn-copy:hover { background: #e2e8f0; }

.btn-delete {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .3rem .75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8rem;
}
.btn-delete:hover { background: #e2e8f0; }

/* 認証ページ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.auth-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.auth-box .logo { display: block; text-align: center; font-size: 2rem; margin-bottom: .5rem; }
.tagline { text-align: center; color: var(--text-muted); font-size: .875rem; margin-bottom: 2rem; }

.auth-box form { display: flex; flex-direction: column; gap: .75rem; }
.auth-box input { width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .625rem .875rem;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.auth-box input:focus { border-color: var(--primary); }
.auth-box .btn-primary { margin-top: .25rem; padding: .75rem; font-size: 1rem; }

.switch-link { text-align: center; font-size: .875rem; color: var(--text-muted); margin-top: 1.25rem; }

.error-msg {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius);
  padding: .75rem;
  font-size: .875rem;
  margin-bottom: 1rem;
}

/* バッジ */
.badge-free { font-size: .75rem; background: #f1f5f9; color: var(--text-muted); padding: .25rem .625rem; border-radius: 999px; }
.badge-paid { font-size: .75rem; background: #dbeafe; color: var(--primary); padding: .25rem .625rem; border-radius: 999px; }
.btn-upgrade { font-size: .8rem; background: var(--primary); color: #fff; padding: .3rem .8rem; border-radius: 6px; text-decoration: none; font-weight: 600; }
.btn-upgrade:hover { opacity: .85; }

/* ダッシュボード */
.dashboard { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 1.5rem;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary);
  background: #eff6ff;
}
.upload-inner { display: flex; flex-direction: column; align-items: center; gap: .75rem; color: var(--text-muted); }
.upload-inner svg { color: var(--primary); opacity: .7; }
.upload-note { font-size: .8rem; }

.upload-progress { margin-bottom: 1rem; display: flex; align-items: center; gap: 1rem; }
.progress-bar { flex: 1; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

.limit-warn {
  background: #fefce8;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--radius);
  padding: .875rem 1rem;
  font-size: .875rem;
  margin-bottom: 1.5rem;
}

.files-section h2 { font-size: 1rem; color: var(--text-muted); margin-bottom: 1rem; }

.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }

.file-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: box-shadow .15s;
}
.file-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }

.card-thumb { display: block; aspect-ratio: 4/3; overflow: hidden; background: #f8fafc; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }

.card-info { padding: .875rem; }
.card-name { font-weight: 500; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { font-size: .75rem; color: var(--text-muted); margin: .3rem 0 .75rem; }
.card-actions { display: flex; flex-direction: column; gap: .4rem; }

/* エディター */
.editor-page { }
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: calc(100vh - 56px);
}

.canvas-wrap {
  overflow: auto;
  padding: 1.5rem;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.canvas-hint { font-size: .8rem; color: var(--text-muted); margin-top: .5rem; }

#main-image { cursor: crosshair; border-radius: 6px; box-shadow: 0 2px 16px rgba(0,0,0,.12); }

.comment-panel {
  border-left: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.comment-panel h2 { padding: 1rem 1.25rem; font-size: 1rem; border-bottom: 1px solid var(--border); }
#comment-list { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }

.comment-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem;
  font-size: .875rem;
}
.comment-card.resolved { opacity: .5; }

.comment-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; flex-wrap: wrap; }
.comment-number {
  background: #e74c3c;
  color: #fff;
  border-radius: 999px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.comment-card.resolved .comment-number { background: #aaa; }
.comment-author { font-weight: 600; }
.comment-date { color: var(--text-muted); font-size: .75rem; margin-left: auto; }
.comment-body { color: var(--text); white-space: pre-wrap; }

.btn-resolve {
  font-size: .7rem;
  border: 1px solid var(--border);
  background: none;
  padding: .15rem .5rem;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
}
.btn-resolve:hover { background: #f1f5f9; }

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: .875rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.15);
}
.modal-box h3 { font-size: 1.1rem; }
.modal-box input, .modal-box textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .625rem .875rem;
  font-size: .95rem;
  outline: none;
  width: 100%;
  resize: vertical;
  font-family: inherit;
}
.modal-box input:focus, .modal-box textarea:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: .75rem; }

/* ビューページのコメント追加ボックス */
.add-comment-box {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .625rem;
}
.add-comment-box h3 { font-size: .9rem; font-weight: 600; }
.add-comment-box input, .add-comment-box textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: .875rem;
  outline: none;
  width: 100%;
  font-family: inherit;
  resize: vertical;
}
.add-comment-box input:focus, .add-comment-box textarea:focus { border-color: var(--primary); }
.hint-text { font-size: .75rem; color: var(--text-muted); }

/* 料金ページ */
.pricing-page {
  max-width: 800px;
  margin: 3rem auto;
  padding: 0 1.5rem;
  text-align: center;
}
.pricing-page h1 { font-size: 2rem; margin-bottom: .75rem; }
.pricing-subtitle { color: var(--text-muted); margin-bottom: 3rem; }

.pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  text-align: left;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  background: #fff;
  position: relative;
}
.plan-card.featured { border-color: var(--primary); border-width: 2px; }

.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  font-size: .75rem;
  padding: .25rem .75rem;
  border-radius: 999px;
  font-weight: 600;
}

.plan-card h2 { font-size: 1.25rem; margin-bottom: .75rem; }
.price { font-size: 2.5rem; font-weight: 700; color: var(--text); margin-bottom: 1.5rem; }
.price span { font-size: 1rem; color: var(--text-muted); font-weight: 400; }

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .625rem;
  margin-bottom: 1.75rem;
  font-size: .95rem;
  color: var(--text);
}

.plan-card .btn-primary, .plan-card .btn-outline { display: block; width: 100%; text-align: center; padding: .75rem; font-size: 1rem; }

@media (max-width: 640px) {
  .editor-layout { grid-template-columns: 1fr; grid-template-rows: 1fr 300px; }
  .pricing-grid { grid-template-columns: 1fr; }
}

/* アップロード上限時 */
.upload-area.upload-disabled { cursor: not-allowed; opacity: 0.5; pointer-events: all; }
.upload-area.upload-disabled:hover { border-color: #ddd; background: #fff; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)} }
.upload-area.upload-shake { animation: shake .35s ease; }

/* フォルダ・ソートツールバー */
.files-toolbar { display:flex; align-items:center; gap:8px; margin-bottom:.75rem; flex-wrap:wrap; }
.toolbar-right { display:flex; align-items:center; gap:8px; margin-left:auto; }
.folder-tabs { display:flex; gap:6px; flex-wrap:wrap; }
.folder-tab { padding:4px 12px; border-radius:99px; font-size:.8rem; border:1px solid #ddd; color:#666; background:#fff; cursor:pointer; transition:all .15s; }
.folder-tab:hover { border-color:#aaa; }
.folder-tab.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.sort-sel { font-size:.8rem; padding:.3rem .6rem; border:1px solid #ddd; border-radius:6px; background:#fff; }

/* フォルダ管理 */
.folder-manager { background:#f8f9fa; border:1px solid #e9ecef; border-radius:8px; padding:.75rem 1rem; margin-bottom:.75rem; }
.folder-row { display:flex; align-items:center; gap:8px; margin-bottom:.5rem; }
.folder-row input { flex:1; font-size:.85rem; padding:.3rem .6rem; border:1px solid #ddd; border-radius:6px; }
.folder-add-row { display:flex; gap:8px; margin-top:.5rem; }
.folder-add-row input { flex:1; font-size:.85rem; padding:.35rem .7rem; border:1px solid #ddd; border-radius:6px; }

/* ファイルカードのフォルダ移動 */
.folder-move-sel { font-size:.75rem; padding:.2rem .4rem; border:1px solid #ddd; border-radius:4px; background:#fff; width:100%; }
.card-folder { font-size:.72rem; color:#888; }

/* 表示切り替えトグル */
.view-toggle { display:flex; border:1px solid #ddd; border-radius:6px; overflow:hidden; }
.view-toggle button { padding:4px 10px; font-size:13px; border:none; background:#fff; color:#888; cursor:pointer; }
.view-toggle button.active { background:#f0f0f0; color:#333; }

/* コンパクトリスト */
.compact-list .cl-item { display:flex; align-items:center; gap:12px; padding:8px 4px; border-bottom:1px solid #f0f0f0; }
.compact-list .cl-item:hover { background:#fafafa; }
.compact-list .cl-thumb { width:48px; height:32px; object-fit:cover; border-radius:4px; flex-shrink:0; background:#eee; }
.compact-list .cl-title { flex:1; font-size:.875rem; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.compact-list .cl-title a { color:inherit; text-decoration:none; }
.compact-list .cl-title a:hover { text-decoration:underline; }
.compact-list .cl-meta { font-size:.75rem; color:#888; white-space:nowrap; }
.compact-list .cl-actions { display:flex; flex-direction:row; gap:4px; flex-shrink:0; align-items:center; }

/* 使用状況バー */
.usage-bar {
  display:flex; align-items:center; gap:1.5rem;
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px;
  padding:.6rem 1rem; margin-bottom:1.2rem; flex-wrap:wrap;
}
.usage-item { font-size:.8rem; color:#555; display:flex; align-items:center; gap:.4rem; }
.usage-item strong { color:#1a1a1a; }
.usage-bar .usage-progress { flex:1; min-width:100px; height:6px; background:#e2e8f0; border-radius:3px; overflow:hidden; }
.usage-bar .usage-progress-fill { height:100%; background:var(--accent,#4a9eff); border-radius:3px; transition:width .3s; }
.usage-warn .usage-progress-fill { background:#f59e0b; }
.usage-full .usage-progress-fill { background:#ef4444; }

/* days-left バッジ */
.days-left { font-size:12px; font-family:'DM Mono',monospace; padding:2px 8px; border-radius:10px; background:#1e2530; color:#7a7f8a; }
.days-left.warn { color:#ff8c00; background:#2a1f0a; }
.days-left.danger { color:#ff4d4d; background:#2a0f0f; }

/* アカウントページ */
.account-page { max-width:560px; margin:40px auto; padding:0 24px; }
.account-page h2 { font-size:1.2rem; font-weight:600; margin-bottom:1.5rem; }
.account-card { background:#fff; border:1px solid #e2e8f0; border-radius:12px; padding:1.5rem; margin-bottom:1rem; }
.account-card h3 { font-size:.85rem; color:#888; margin-bottom:.8rem; text-transform:uppercase; letter-spacing:.05em; }
.account-card .plan-name { font-size:1.4rem; font-weight:700; margin-bottom:.3rem; }
.account-card .plan-desc { font-size:.85rem; color:#666; }
.account-card .danger-btn { margin-top:1rem; background:#fff; color:#ef4444; border:1px solid #ef4444; border-radius:6px; padding:.5rem 1rem; font-size:.875rem; cursor:pointer; }
.account-card .danger-btn:hover { background:#fef2f2; }

/* URLアップロード */
.url-upload-row { display:flex; gap:.5rem; margin:.75rem 0; }
.url-input { flex:1; padding:.5rem .75rem; border:1px solid #ddd; border-radius:6px; font-size:.875rem; }
.url-upload-btn { padding:.5rem 1rem; white-space:nowrap; }

/* 招待リスト */
.invite-row { display:flex; align-items:center; gap:.75rem; padding:.6rem 0; border-bottom:1px solid #f0f0f0; }
.invite-thumb { width:48px; height:32px; object-fit:cover; border-radius:4px; flex-shrink:0; background:#eee; }
.invite-row.expired { opacity:.5; }
.invite-filename { flex:1; font-size:.875rem; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.invite-expiry { font-size:.75rem; color:#888; white-space:nowrap; min-width:70px; }
