:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --card: #ffffff;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --border: #e5e7eb;
  --surface-hover: #eef2f7;
  --surface-subtle: #f8fafc;
  --focus-ring: rgba(37, 99, 235, 0.2);
  --shadow: rgba(15, 23, 42, 0.14);
  --radius: 10px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #172033;
  --surface: #172033;
  --text: #e5e7eb;
  --muted: #a8b3c5;
  --accent: #60a5fa;
  --accent-dark: #3b82f6;
  --danger: #f87171;
  --border: #334155;
  --surface-hover: #243047;
  --surface-subtle: #1e293b;
  --focus-ring: rgba(96, 165, 250, 0.35);
  --shadow: rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #0f172a;
    --card: #172033;
    --surface: #172033;
    --text: #e5e7eb;
    --muted: #a8b3c5;
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
    --danger: #f87171;
    --border: #334155;
    --surface-hover: #243047;
    --surface-subtle: #1e293b;
    --focus-ring: rgba(96, 165, 250, 0.35);
    --shadow: rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.material-icon { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; fill: currentColor; }
.icon-button { display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--surface-hover); color: var(--accent); }
.icon-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

input, textarea, select, dialog { color: var(--text); }
input, textarea, select { border-color: var(--border); background-color: var(--card); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.2rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-name {
  min-width: 0;
  max-width: 16rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu { position: relative; }
.user-menu summary { min-height: 44px; display: flex; align-items: center; padding: 0 .65rem; border-radius: var(--radius); cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary::after { content: "▾"; margin-left: .45rem; color: var(--muted); }
.user-menu summary:hover, .user-menu summary:focus-visible { background: var(--surface-hover); color: var(--accent); outline: none; }
.user-menu-panel { position: absolute; z-index: 20; top: calc(100% + .35rem); right: 0; display: grid; min-width: 12rem; padding: .35rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: 0 8px 24px var(--shadow); }
.user-menu-panel a { padding: .55rem .7rem; border-radius: .45rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.user-menu-panel a:hover, .user-menu-panel a:focus-visible { background: var(--surface-hover); color: var(--accent); outline: none; }
.theme-setting { display: grid; gap: .25rem; padding: .55rem .7rem; color: var(--muted); font-size: .78rem; }
.theme-setting select { min-height: 36px; padding: .25rem .4rem; border: 1px solid var(--border); border-radius: .4rem; background: var(--card); color: var(--text); font: inherit; }
.theme-setting-inline { display: flex; align-items: center; gap: .4rem; padding: 0; }

main { max-width: 1080px; margin: 0 auto; padding: 1.2rem; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 2rem 0 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn .material-icon { margin-right: 0.35rem; }

.material-select {
  min-height: 44px;
  padding: 0.45rem 2.5rem 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='m7 10 5 5 5-5z'/%3E%3C/svg%3E");
  background-position: right 0.65rem center;
  background-repeat: no-repeat;
  color: var(--text);
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}
.material-select:hover { border-color: var(--accent); }
.material-select:focus-visible { border-color: var(--accent); outline: 2px solid var(--focus-ring); outline-offset: 1px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-dark); color: #fff; }

.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.badge {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  font-size: 0.75rem;
}

.badge-public { background: #dcfce7; color: #15803d; }
.sync-status, .link-status { font-weight: 600; }
.sync-status-ready, .sync-status-unchanged, .link-status-active { background: #dcfce7; color: #15803d; }
.sync-status-pending { background: #fef3c7; color: #92400e; }
.sync-status-converting { background: #dbeafe; color: #1d4ed8; }
.sync-status-pending::before, .sync-status-converting::before {
  content: "";
  display: inline-block;
  width: .7rem;
  height: .7rem;
  margin-right: .35rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -.1rem;
  animation: sync-spin .8s linear infinite;
}
@keyframes sync-spin { to { transform: rotate(360deg); } }
.sync-status-error, .link-status-deleted { background: #fee2e2; color: #b91c1c; }
.git-group-card { margin: 1rem 0 1.5rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.git-group-card h2 { margin-top: 0; }
.git-sync-summary { display: flex; align-items: center; gap: .65rem; min-height: 2rem; }
.git-sync-summary .deck-setting-status { min-height: 0; margin: 0 0 0 auto; }
.git-group-settings { display: grid; grid-template-columns: minmax(13rem, 1fr) auto minmax(10rem, 13rem) auto; align-items: end; gap: 1rem 1.25rem; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.git-group-interval { display: grid; gap: .35rem; color: var(--muted); font-size: .82rem; }
.git-group-save { display: grid; align-self: start; gap: .3rem; justify-items: end; padding-top: 1.35rem; }
.git-group-save .btn { min-height: 42px; }
.git-group-save #settings-status { min-height: 1.2rem; color: var(--muted); font-size: .78rem; white-space: nowrap; }
.git-link-help { margin: -.5rem 0 1rem; color: var(--muted); font-size: .85rem; }
.confirm-dialog { width: min(36rem, calc(100% - 2rem)); padding: 1.25rem; border: 0; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(15,23,42,.3); }
.confirm-dialog::backdrop { background: rgba(15,23,42,.5); }
.confirm-dialog h2 { margin-top: 0; }
.delete-target-list { max-height: 16rem; overflow: auto; padding-left: 1.4rem; }
.delete-target-list small { display: block; color: var(--muted); }
.git-deck-actions input { min-width: min(22rem, 100%); }
.download-disabled-badge { display: inline-flex; align-items: center; color: #b45309; }
.download-disabled-badge.material-symbols-outlined { font-size: 1.15rem; }
.git-group-deck { display: flex; flex-direction: column; }
.git-group-deck > a { flex: 1; }
.git-deck-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: auto; padding: .85rem .75rem .75rem 0; }
.filter-apply { justify-self: end; }

.deck-settings { margin-top: 1.4rem; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.deck-settings h2 { margin: 0; padding: 1rem; border-bottom: 1px solid var(--border); font-size: 1.05rem; }
.deck-settings-form { display: grid; }
.deck-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; }
.deck-setting-label, .deck-setting-help { display: block; }
.deck-setting-label { font-weight: 600; }
.deck-setting-help, .deck-setting-status { color: var(--muted); font-size: .82rem; }
.deck-setting-status { min-height: 1.4rem; margin: -.65rem 1rem .25rem; text-align: right; }
.deck-settings-actions { display: flex; justify-content: flex-end; padding: .5rem 1rem 1rem; }
.deck-access-groups .radio { display: flex; align-items: center; gap: .5rem; min-height: 2rem; }
.radio input { flex: 0 0 auto; margin: 0; }
.setting-switch { display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; padding: .35rem .55rem; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); cursor: pointer; }
.setting-switch-track { position: relative; width: 2.75rem; height: 1.5rem; border-radius: 999px; background: #9ca3af; transition: background .15s ease; }
.setting-switch-track span { position: absolute; top: .2rem; left: .2rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s ease; }
.setting-switch[aria-checked="true"] { color: var(--accent); }
.setting-switch[aria-checked="true"] .setting-switch-track { background: var(--accent); }
.setting-switch[aria-checked="true"] .setting-switch-track span { transform: translateX(1.25rem); }
.setting-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.setting-switch:disabled { cursor: wait; opacity: .65; }
.deck-danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.4rem; padding: 1rem; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--card); }
.deck-danger-zone h2, .deck-danger-zone p { margin: 0; }
.deck-danger-zone h2 { color: var(--danger); font-size: 1rem; }
.deck-danger-zone p { color: var(--muted); font-size: .82rem; }

/* デッキ一覧 */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.deck-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s;
}

.deck-card[hidden] { display: none; }

.deck-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1); }

.deck-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-subtle);
  display: block;
}

.deck-card-body { padding: 0.7rem 0.9rem; }

.deck-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty { color: var(--muted); }

.deck-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.deck-list-header h1 { margin: 0; }

.deck-search { position: relative; width: min(360px, 48%); }
.search-suggestions { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); box-shadow: 0 6px 18px #0002; }
.search-suggestions[hidden], .search-suggestion-retry[hidden] { display: none; }
.search-suggestion-status { margin: 4px 4px 8px; font-size: 0.85rem; overflow-wrap: anywhere; }
#search-tag-options { display: flex; flex-wrap: wrap; gap: 4px; max-height: 40vh; overflow-y: auto; }
.search-tag-option { min-height: 44px; min-width: 44px; max-width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: inherit; font: inherit; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.search-tag-option:hover, .search-tag-option[aria-selected="true"] { outline: 2px solid currentColor; outline-offset: -2px; }
#deck-filters { position: relative; }
@media (max-width: 768px) {
  #deck-filters .deck-search { position: static; }
}

.deck-search input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.deck-filters { display: flex; align-items: center; justify-content: flex-end; gap: 0.45rem; flex: 1; }
.deck-filters select, .tag-editor input { min-height: 42px; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); font: inherit; }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.65rem; }
.result-toolbar .result-count { margin: 0; }
.deck-sort-controls { display: flex; align-items: center; gap: 0.3rem; margin-left: auto; }
.sort-select { display: flex; align-items: center; min-height: 42px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); }
.sort-select select { min-height: 40px; padding: 0.35rem 1rem; border: 0; border-radius: 999px; background: transparent; color: var(--text); font: inherit; outline: 0; appearance: none; -webkit-appearance: none; }
.sort-direction .material-icon { width: 1.35rem; height: 1.35rem; }
.sort-direction.is-ascending .material-icon { transform: rotate(180deg); }
.tag-chip { display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.55rem; border: 0; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: 0.78rem; text-decoration: none; }
.tag-chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; }
.deck-tags, .active-tags, .tag-chips, .deck-detail-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.deck-tags { margin: 0.4rem 0; }
.active-tags { margin: -0.4rem 0 1rem; }
.filter-chip { display: inline-flex; align-items: center; gap: 0.3rem; min-height: 30px; padding: 0.2rem 0.65rem; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); cursor: pointer; }
.keyword-chip .material-icon { color: var(--muted); }
.tag-filter-chip { border-color: #bfdbfe; background: #eff6ff; color: #1d4ed8; }
.result-count { color: var(--muted); font-size: 0.85rem; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.8rem; margin-top: 1.2rem; }
.page-numbers { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.page-number { min-width: 1.8rem; text-align: center; }
.page-size { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.tag-editor { display: grid; gap: 0.45rem; }
.deck-tag-editor { max-width: 560px; margin-top: 0.8rem; }
.deck-tag-summary { display: flex; align-items: center; gap: 0.25rem; min-height: 32px; }
.tag-edit-button { width: 32px; height: 32px; }
.empty-tag-state { color: var(--muted); font-size: 0.82rem; }
.tag-editor-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.field-error { min-height: 1.4em; margin: 0; color: var(--danger); font-size: 0.82rem; }
.metric { display: inline-flex; align-items: center; gap: 0.25rem; }

.deck-status-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #eef2f7;
  color: var(--muted);
}

.deck-status-thumb .processing-spinner {
  width: 2rem;
  height: 2rem;
  margin: 0;
}

.badge-processing { background: #dbeafe; color: #1d4ed8; }
.badge-error { background: #fee2e2; color: #b91c1c; }

/* アップロードフォーム */
.upload-form {
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.upload-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }

.upload-form input[type="text"],
.upload-form textarea {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
}

.upload-form fieldset { border: 1px solid var(--border); border-radius: 6px; }

.upload-form .radio { flex-direction: row; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.import-result { margin: 1rem 0; padding: 0.85rem 1rem; border: 1px solid #22c55e; border-radius: 8px; background: var(--surface-subtle); color: var(--text); }
.upload-results { margin: 1rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.upload-results h2 { margin-top: 0; font-size: 1.05rem; }
.upload-results ul, .upload-file-summary ul { margin: .5rem 0 0; padding-left: 1.25rem; }
.upload-results li { display: grid; grid-template-columns: minmax(10rem, 1fr) minmax(12rem, 2fr); gap: 1rem; padding: .4rem 0; }
.upload-result-success { color: var(--text); }
.upload-result-error { color: var(--danger); }
.upload-file-summary { margin-top: -.4rem; font-size: .85rem; color: var(--muted); }
.upload-file-summary p { margin: 0; font-weight: 600; }
@media (max-width: 640px) {
  .upload-results li { grid-template-columns: 1fr; gap: .1rem; }
}

.page-heading, .collection-view-header, .collection-selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-heading h1, .collection-view-header h1, .collection-selection-heading h2 { margin-bottom: .25rem; }
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.collection-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); transition: box-shadow .15s; }
.collection-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .1); }
.collection-card-link { display: block; color: inherit; text-decoration: none; }
.collection-card img, .collection-empty-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #e5e7eb; }
.collection-empty-thumb { display: grid; place-items: center; color: var(--muted); }
.collection-card-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; padding: 0 .9rem .9rem; }
.collection-deck-list { display: grid; gap: .75rem; padding: 0; list-style: none; }
.collection-deck-card { display: grid; grid-template-columns: 12rem 1fr; gap: 1rem; align-items: center; padding: .75rem; border: 1px solid var(--border); border-radius: 12px; color: inherit; text-decoration: none; background: var(--surface); }
.collection-deck-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; }
.collection-editor { display: grid; gap: 1rem; max-width: 70rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.collection-editor > label { display: grid; gap: .35rem; }
.collection-editor textarea { min-height: 7rem; }
.material-field { color: var(--muted); font-size: .9rem; }
.material-field input, .material-field textarea, .collection-share-row input { width: 100%; padding: .7rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--text); font: inherit; }
.material-field input:focus, .material-field textarea:focus, .collection-share-row input:focus { border-color: var(--accent); outline: 2px solid rgba(37, 99, 235, .18); outline-offset: 1px; }
.material-fieldset { display: grid; gap: .45rem; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.material-fieldset .radio { display: flex; align-items: center; gap: .5rem; min-height: 36px; }
.collection-share-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: .5rem; }
.collection-share-row label { display: grid; gap: .35rem; }
.collection-notices { padding: .75rem 1rem; border: 1px solid #f59e0b; border-radius: 10px; background: #fffbeb; }
.collection-notices h2 { margin-top: 0; font-size: 1rem; }
.collection-candidates { display: grid; gap: .5rem; }
.collection-candidate { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.collection-candidate > label { display: grid; grid-template-columns: auto 7rem minmax(0, 1fr); align-items: center; gap: .7rem; min-width: 0; flex: 1; }
.collection-candidate img { width: 7rem; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; }
.collection-candidate span span, .collection-candidate small { display: block; }
.collection-candidate .badge { display: inline-block; }
.collection-candidate .deck-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.collection-candidate .tag-chip { border: 0; cursor: pointer; }
.collection-order-buttons { display: flex; }
.collection-filter-panel { display: grid; gap: .6rem; padding: .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-subtle); }
.collection-filter-panel .deck-filters { width: 100%; }
.filter-menu { position: relative; }
.filter-menu summary { list-style: none; white-space: nowrap; }
.filter-menu summary::-webkit-details-marker { display: none; }
.filter-menu-panel { position: absolute; z-index: 20; top: calc(100% + .35rem); right: 0; display: grid; gap: .7rem; min-width: 15rem; padding: .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: 0 8px 24px rgba(15,23,42,.14); }
.filter-menu-panel label { display: grid; gap: .3rem; color: var(--muted); font-size: .82rem; }
.group-multiselect-field { display: grid; gap: .3rem; color: var(--muted); font-size: .82rem; }
.group-multiselect { position: relative; color: var(--text); font-size: 1rem; }
.group-multiselect summary { display: flex; align-items: center; min-width: 100%; list-style: none; cursor: pointer; }
.group-multiselect summary::-webkit-details-marker { display: none; }
.group-multiselect-options { position: absolute; z-index: 30; top: calc(100% + .25rem); right: 0; left: 0; display: grid; gap: .2rem; max-height: 14rem; padding: .4rem; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: 0 8px 24px rgba(15,23,42,.14); }
.group-multiselect-options label { display: flex; align-items: center; gap: .5rem; min-height: 2.25rem; padding: .25rem .4rem; border-radius: 6px; color: var(--text); cursor: pointer; }
.group-multiselect-options label:hover { background: var(--surface-subtle); }
.group-multiselect-options input { flex: 0 0 auto; margin: 0; accent-color: var(--accent); }
.filter-direction { display: flex; gap: .8rem; margin: 0; padding: .6rem 0 0; border: 0; border-top: 1px solid var(--border); }
.filter-direction legend { color: var(--muted); font-size: .82rem; }
.filter-direction label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: .3rem; color: var(--text); }
.collection-select-all { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; color: var(--muted); cursor: pointer; }
.collection-select-all input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.collection-form-actions { display: flex; flex-wrap: wrap; gap: .75rem; padding-top: .25rem; }
.collection-view-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.form-help { color: var(--muted); margin: 0; }
.form-error { color: var(--danger); min-height: 1.5rem; }
.collection-navigation { display: flex; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.collection-navigation > span { display: flex; gap: .5rem; }

@media (max-width: 640px) {
  .page-heading, .collection-view-header { align-items: flex-start; flex-direction: column; }
  .collection-deck-card { grid-template-columns: 7rem 1fr; }
  .collection-candidate > label { grid-template-columns: auto 5rem minmax(0, 1fr); }
  .collection-candidate img { width: 5rem; }
  .collection-order-buttons { flex-direction: column; }
  .collection-share-row { grid-template-columns: 1fr 1fr; }
  .collection-share-row label { grid-column: 1 / -1; }
  .collection-card-actions { flex-wrap: wrap; }
  .collection-view-actions { width: 100%; }
  .collection-view-actions .btn { flex: 1; }
  .collection-filter-panel .deck-filters { flex-wrap: nowrap; }
  .collection-navigation { align-items: stretch; flex-direction: column; }
  .collection-navigation > span { justify-content: space-between; }
}
.git-import-modes { display: grid; gap: 0.35rem; }

.hint { color: var(--muted); font-size: 0.85rem; }

/* ビューア */
.viewer {
  position: relative;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
}

.viewer-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}

.viewer.viewer-page-portrait .viewer-stage {
  align-items: flex-start;
  max-height: min(72vh, 720px);
  overflow-y: auto;
}

.viewer img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(72vh, 720px);
  object-fit: contain;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.viewer.viewer-page-portrait img {
  width: 100%;
  max-height: none;
}

.viewer.viewer-expanded {
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer.viewer-expanded .viewer-stage {
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
}

.viewer.viewer-expanded.viewer-page-portrait .viewer-stage {
  max-height: none;
  overflow-y: auto;
}

.viewer.viewer-expanded img {
  max-width: 100vw;
  max-width: 100dvw;
  max-height: 100vh;
  max-height: 100dvh;
}

.viewer.viewer-expanded.viewer-page-portrait img {
  width: 100%;
  max-height: none;
}

.viewer.viewer-expanded.viewer-slide-zoom img { transform-origin: center center; cursor: default; will-change: transform; }
.viewer.viewer-expanded.viewer-slide-is-zoomed img { cursor: grab; }
.viewer.viewer-expanded.viewer-slide-is-dragging img { cursor: grabbing; }
.viewer.viewer-expanded.viewer-slide-zooming-in img { cursor: zoom-in; }
.viewer.viewer-expanded.viewer-slide-zooming-out img { cursor: zoom-out; }

body.viewer-open { overflow: hidden; }

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 1.4rem;
  width: 2.6rem;
  height: 3.6rem;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

.viewer-prev { left: 0.5rem; }
.viewer-next { right: 0.5rem; }
.viewer-nav:focus-visible { opacity: 1; }
.viewer-nav:disabled { cursor: default; }

@media (hover: hover) {
  .viewer:hover .viewer-nav { opacity: 1; }
  .viewer:hover .viewer-nav:disabled { opacity: 0.15; }
}

.viewer-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  padding: 0.35rem 0.8rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  color: #fff;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.viewer:focus-within .viewer-bar, .viewer.viewer-controls-visible .viewer-bar { opacity: 1; pointer-events: auto; }
@media (hover: hover) { .viewer:hover .viewer-bar { opacity: 1; pointer-events: auto; } }

.viewer-title {
  margin-right: auto;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-fs {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 1.35rem;
  cursor: pointer;
}

.viewer-collapse-icon { display: none; }
.viewer-expanded .viewer-expand-icon { display: none; }
.viewer-expanded .viewer-collapse-icon { display: inline; }

/* 閲覧ページ */
.deck-view { display: flex; flex-direction: column; gap: 1.2rem; }
.viewer-shell { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.deck-info h1 { margin: 0 0 0.3rem; font-size: 1.4rem; }
.deck-desc { white-space: normal; }
.deck-description { margin: .7rem 0; }
.deck-description [data-description-display] { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.deck-description .deck-desc { margin: .55rem 0; color: var(--text); }
.markdown-content > :first-child { margin-top: 0; }
.markdown-content > :last-child { margin-bottom: 0; }
.markdown-content h1, .markdown-content h2, .markdown-content h3 { margin: 1rem 0 .45rem; line-height: 1.3; }
.markdown-content h1 { font-size: 1.35rem; }
.markdown-content h2 { font-size: 1.2rem; }
.markdown-content h3 { font-size: 1.05rem; }
.markdown-content p, .markdown-content ul, .markdown-content ol, .markdown-content blockquote, .markdown-content pre { margin: .55rem 0; }
.markdown-content ul, .markdown-content ol { padding-left: 1.5rem; }
.markdown-content blockquote { padding-left: .8rem; border-left: 3px solid var(--border); color: var(--muted); }
.markdown-content code { padding: .1em .3em; border-radius: 4px; background: var(--surface-subtle); }
.markdown-content pre { overflow-x: auto; padding: .75rem; border-radius: var(--radius); background: var(--surface-subtle); white-space: pre; }
.markdown-content pre code { padding: 0; background: transparent; }
.description-editor { display: grid; gap: .55rem; max-width: 48rem; }
.description-editor textarea { width: 100%; min-height: 8rem; padding: .65rem; resize: vertical; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; }
.description-editor > div { display: flex; justify-content: flex-end; gap: .5rem; }
.collection-owner { color: var(--muted); font-size: .88rem; }
.deck-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.8rem; }
.view-analytics { margin-top: 1.2rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.view-analytics-header { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.8rem; }
.view-analytics h2 { margin: 0; font-size: 1.1rem; }
.view-analytics-status { color: var(--muted); }
.view-analytics-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; }
.view-analytics-metrics > div { display: grid; gap: 0.2rem; padding: 0.7rem; border-radius: 6px; background: var(--surface-subtle); }
.view-analytics-metrics strong { font-size: 1.3rem; }
.view-analytics-metrics span, .view-analytics-list span { color: var(--muted); font-size: 0.8rem; }
.view-analytics-list { display: grid; gap: 0.5rem; margin: 0.8rem 0 0; padding: 0; list-style: none; }
.view-analytics-list li { display: flex; justify-content: space-between; gap: 0.8rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }

.comment-pins { position: absolute; inset: 0; pointer-events: none; }
.comment-pin {
  position: absolute;
  z-index: 3;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -100%);
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: #f59e0b;
  color: #111827;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.55;
}
.comment-pin:hover { opacity: 0.85; }
.comment-pin.is-active { opacity: 1; background: #fef08a; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.35); }
.comment-draft-pin {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border: 3px solid #fff;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  pointer-events: none;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.35);
}
.comment-picking { cursor: crosshair; outline: 3px solid #f59e0b; outline-offset: -3px; }
.comment-panel { max-height: min(72vh, 720px); overflow: auto; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.comment-panel-header { display: flex; align-items: center; justify-content: space-between; }
.comment-panel-header > div { display: flex; align-items: center; gap: 0.4rem; }
.comment-panel h2 { margin: 0; font-size: 1.1rem; }
.comment-count { min-width: 1.6rem; padding: 0.1rem 0.4rem; border-radius: 999px; background: var(--border); text-align: center; font-size: 0.8rem; }
.comment-status, .comment-login { color: var(--muted); font-size: 0.88rem; }
.comment-list { display: flex; flex-direction: column; gap: 0.65rem; padding: 0; list-style: none; }
.comment-item { padding: 0.65rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.comment-item.is-active { border-color: #f59e0b; background: #fffbeb; }
.comment-item-heading { display: grid; gap: 0.35rem; font-size: 0.82rem; }
.comment-item-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-item-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.comment-item-heading time { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.comment-page { padding: 0 0.4rem; border-radius: 999px; background: #dbeafe; color: #1d4ed8; white-space: nowrap; font-size: 0.72rem; }
.comment-item p { margin: 0.4rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-item-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.comment-item-actions button { min-height: 36px; border: 0; background: none; color: var(--accent); cursor: pointer; }
.comment-form { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }
.comment-form textarea { min-height: 5rem; resize: vertical; border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem; font: inherit; }
.comment-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
.comment-form-actions .btn { max-width: 100%; }
.comment-position { color: #92400e; font-size: 0.8rem; }
.comment-edit-form { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.comment-edit-form textarea { min-height: 5rem; resize: vertical; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.comment-edit-form > div { display: flex; justify-content: flex-end; gap: 0.5rem; }
.comment-edit-form > div > button { min-height: 40px; padding: 0.4rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); cursor: pointer; }
.comment-edit-form > div > .btn-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.comment-toggle { min-height: 36px; border: 0; background: none; color: var(--accent); cursor: pointer; }
.comment-panel.is-collapsed > :not(.comment-panel-header) { display: none; }
.comment-panel.is-collapsed { max-height: none; }
.viewer-comment-count, .viewer-view-count { white-space: nowrap; }
.slide-context-menu {
  position: fixed;
  z-index: 2000;
  width: 180px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.slide-context-menu button { display: block; width: 100%; min-height: 44px; padding: 0.6rem 0.8rem; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; }
.slide-context-menu button[hidden] { display: none; }
.slide-context-menu button:last-child { border-bottom: 0; }
.slide-context-menu button:hover { background: #eff6ff; color: var(--accent); }
.comment-preview {
  position: absolute;
  z-index: 8;
  right: 0.75rem;
  bottom: 4.25rem;
  width: min(320px, calc(100% - 1.5rem));
  padding: 0.8rem 2.4rem 0.8rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.94);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.comment-preview button { position: absolute; top: 0.3rem; right: 0.35rem; width: 36px; height: 36px; border: 0; background: none; color: #fff; font-size: 1.25rem; cursor: pointer; }
.comment-preview span { margin-left: 0.6rem; color: #bfdbfe; font-size: 0.8rem; }
.comment-preview p { margin: 0.45rem 0 0; white-space: pre-wrap; }
.comment-fullscreen-form {
  position: absolute;
  z-index: 9;
  right: 0.75rem;
  bottom: 4.25rem;
  display: grid;
  width: min(360px, calc(100% - 1.5rem));
  gap: 0.55rem;
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.96);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.comment-fullscreen-form[hidden] { display: none; }
.comment-fullscreen-form textarea { min-height: 6rem; resize: vertical; padding: 0.5rem; border: 0; border-radius: 6px; font: inherit; }
.comment-fullscreen-form > div { display: flex; justify-content: flex-end; gap: 0.5rem; }
.comment-fullscreen-form > div > button { min-height: 44px; padding: 0.45rem 0.8rem; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 6px; background: transparent; color: #fff; cursor: pointer; }
.comment-fullscreen-form > div > .btn-primary { border-color: var(--accent); background: var(--accent); }

/* 埋め込み */
.embed-body { background: #111; }
.viewer-embed { border-radius: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.viewer-embed img { max-height: 100vh; }
.viewer-embed .viewer-stage { height: 100vh; max-height: 100vh; }

.error-box { text-align: center; padding: 3rem 0; }

.processing-panel {
  max-width: 640px;
  margin: 12vh auto 0;
  text-align: center;
}

.processing-panel .deck-actions { justify-content: center; }

.processing-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1.2rem;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: processing-spin 0.8s linear infinite;
}

@keyframes processing-spin {
  to { transform: rotate(360deg); }
}

/* 認証ローディング */
body:has(.auth-loading) { overflow: hidden; background: #07111f; }
body:has(.auth-loading) .site-header,
body:has(.auth-loading) .site-footer { display: none; }
body:has(.auth-loading) main { max-width: none; padding: 0; }

.auth-loading {
  position: relative;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 50% 20%, rgba(37, 99, 235, 0.2), transparent 38%),
    linear-gradient(145deg, #07111f 0%, #0c1b31 55%, #071522 100%);
  color: #f8fafc;
}

.auth-loading::before {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  content: "";
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.auth-loading-glow { position: absolute; width: 22rem; height: 22rem; border-radius: 50%; filter: blur(80px); opacity: 0.2; }
.auth-loading-glow-one { top: -8rem; left: -6rem; background: #38bdf8; }
.auth-loading-glow-two { right: -7rem; bottom: -9rem; background: #6366f1; }

.auth-loading-card {
  position: relative;
  z-index: 1;
  width: min(100%, 31rem);
  padding: 2.25rem 2.4rem 2rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 24px;
  background: rgba(15, 29, 49, 0.72);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: center;
  backdrop-filter: blur(18px);
}

.auth-loading-brand { display: inline-flex; align-items: center; gap: 0.65rem; color: #f8fafc; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.02em; text-decoration: none; }
.auth-loading-mark { display: grid; width: 28px; height: 28px; padding: 5px; border-radius: 8px; background: linear-gradient(145deg, #38bdf8, #2563eb); box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35); }
.auth-loading-mark span { height: 2px; border-radius: 999px; background: #fff; }
.auth-loading-mark span:nth-child(1) { width: 70%; }
.auth-loading-mark span:nth-child(2) { width: 100%; }
.auth-loading-mark span:nth-child(3) { width: 55%; }

.auth-loading-visual { position: relative; width: 104px; height: 104px; margin: 2rem auto 1.25rem; }
.auth-loading-orbit { position: absolute; inset: 8px; border: 1px solid rgba(125, 211, 252, 0.28); border-top-color: #38bdf8; border-radius: 50%; animation: auth-orbit 1.5s linear infinite; }
.auth-loading-core { position: absolute; inset: 31px; border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 15px; background: linear-gradient(145deg, rgba(56, 189, 248, 0.32), rgba(37, 99, 235, 0.1)); box-shadow: 0 0 32px rgba(56, 189, 248, 0.22); transform: rotate(45deg); }
.auth-loading-dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #7dd3fc; box-shadow: 0 0 12px #38bdf8; }
.auth-loading-dot-one { top: 5px; left: 49px; animation: auth-pulse 1.1s ease-in-out infinite; }
.auth-loading-dot-two { right: 5px; bottom: 24px; animation: auth-pulse 1.1s ease-in-out 0.35s infinite; }

.auth-loading-eyebrow { margin: 0 0 0.55rem; color: #7dd3fc; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.2em; }
.auth-loading h1 { margin: 0; color: #fff; font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.35; }
.auth-loading-message { margin: 0.9rem 0 1.5rem; color: #aebdd0; font-size: 0.92rem; line-height: 1.8; }
.auth-loading-progress { height: 4px; overflow: hidden; border-radius: 999px; background: rgba(148, 163, 184, 0.16); }
.auth-loading-progress span { display: block; width: 45%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #38bdf8, #2563eb); box-shadow: 0 0 14px rgba(56, 189, 248, 0.7); animation: auth-progress 1.25s ease-in-out infinite; }
.auth-loading-status { margin: 0.85rem 0 0; color: #8fa3bb; font-size: 0.78rem; }
.auth-loading-retry { display: inline-block; margin-top: 1.2rem; color: #bae6fd; font-size: 0.82rem; text-underline-offset: 3px; }
.auth-loading-retry:hover { color: #fff; }

@keyframes auth-orbit { to { transform: rotate(360deg); } }
@keyframes auth-pulse { 50% { opacity: 0.35; transform: scale(0.7); } }
@keyframes auth-progress { from { transform: translateX(-110%); } to { transform: translateX(245%); } }

@media (prefers-reduced-motion: reduce) {
  .auth-loading-orbit, .auth-loading-dot, .auth-loading-progress span { animation-duration: 4s; }
  .action-toast { transition: none; }
}

@media (max-width: 640px) {
	.git-group-settings { grid-template-columns: 1fr; align-items: stretch; }
	.git-group-settings .setting-switch { justify-self: start; }
	.git-group-save { justify-items: stretch; }
	.auth-loading { padding: 1rem; }
	.auth-loading-card { padding: 1.8rem 1.25rem 1.5rem; border-radius: 20px; }
	.deck-list-header { align-items: stretch; flex-direction: column; }
	.deck-filters { flex-wrap: nowrap; justify-content: stretch; width: 100%; }
	.deck-search { flex: 1; min-width: 0; width: auto; }
	.deck-filters .search-submit { flex: 0 0 42px; }
	.deck-filters select { flex: 1; }
	.result-toolbar { align-items: center; }
	.pagination { justify-content: space-between; }
	.page-size { margin-left: 0; }
	.page-numbers { display: none; }
  .view-analytics-metrics { grid-template-columns: 1fr; }
  .view-analytics-list li { flex-direction: column; gap: 0.2rem; }
  .site-header {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.65rem 0.8rem;
  }
  .site-header nav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.45rem;
    width: 100%;
  }
  .site-header nav .btn { padding-inline: 0.7rem; }
  .user-name { align-self: center; max-width: 100%; text-align: center; }
  main { padding: 0.85rem; }
  .deck-list-header { align-items: stretch; flex-direction: column; }
  .deck-list-header h1 { font-size: 1.45rem; }
  .deck-search { flex: 1; min-width: 0; width: auto; }
  .deck-search input { min-height: 44px; font-size: 1rem; }
  .deck-card-body { padding: 0.85rem; }
  .deck-title { font-size: 1rem; }
  .deck-meta { flex-wrap: wrap; font-size: 0.8rem; }
  .deck-setting-row, .deck-danger-zone { align-items: stretch; flex-direction: column; }
  .setting-switch { align-self: flex-end; }
  .deck-setting-status { text-align: left; }
  .viewer img { max-height: min(65vh, 640px); max-height: min(65dvh, 640px); }
  .viewer-bar { gap: 0.35rem; padding: 0.3rem; }
  .viewer-title { display: none; }
  .viewer-fs { font-size: 1.25rem; }
  .viewer-shell { grid-template-columns: 1fr; }
  .comment-panel { max-height: 50vh; }
}

@media (min-width: 641px) and (max-width: 900px) {
  .viewer-shell { grid-template-columns: 1fr; }
  .comment-panel { max-height: 420px; }
}

@media (max-width: 360px) {
  .site-header nav .btn { padding-inline: 0.55rem; font-size: 0.82rem; }
  .user-name { font-size: 0.8rem; }
}
.import-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.git-version-info { display: grid; gap: .8rem; width: 100%; margin: 1rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.git-version-header { display: flex; align-items: center; justify-content: flex-start; gap: .55rem; }
.git-version-header > div { display: flex; align-items: center; gap: .45rem; min-width: 0; }
.git-version-label { font-weight: 600; }
.git-version-header code { overflow: hidden; text-overflow: ellipsis; }
.git-version-badge { flex: 0 0 auto; background: #dbeafe; color: #1d4ed8; }

:root[data-theme="dark"] .tag-chip,
:root[data-theme="dark"] .tag-filter-chip,
:root[data-theme="dark"] .badge-processing,
:root[data-theme="dark"] .comment-page,
:root[data-theme="dark"] .git-version-badge { background: #1e3a5f; color: #bfdbfe; border-color: #3b82f6; }
:root[data-theme="dark"] .comment-item.is-active,
:root[data-theme="dark"] .collection-notices { background: #422006; }
:root[data-theme="dark"] .slide-context-menu button:hover,
:root[data-theme="dark"] .deck-status-thumb { background: var(--surface-hover); }

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .tag-chip,
  :root[data-theme="system"] .tag-filter-chip,
  :root[data-theme="system"] .badge-processing,
  :root[data-theme="system"] .comment-page,
  :root[data-theme="system"] .git-version-badge { background: #1e3a5f; color: #bfdbfe; border-color: #3b82f6; }
  :root[data-theme="system"] .comment-item.is-active,
  :root[data-theme="system"] .collection-notices { background: #422006; }
  :root[data-theme="system"] .slide-context-menu button:hover,
  :root[data-theme="system"] .deck-status-thumb { background: var(--surface-hover); }
}
.git-version-date { color: var(--muted); font-size: .82rem; }
.git-version-message { margin: 0; }
.git-version-controls { display: grid; grid-template-columns: 7rem minmax(18rem, 32rem); align-items: center; justify-content: start; gap: .5rem; }
.git-version-controls label, .git-sync-interval-label { color: var(--muted); font-size: .82rem; }
.git-version-info select { min-width: 0; max-width: 100%; }
.git-sync-actions { display: flex; }
.git-sync-actions .btn { width: 9rem; }
.git-sync-settings summary { cursor: pointer; font-weight: 600; }
.git-sync-settings-body { display: grid; grid-template-columns: auto 3rem 12rem 6rem; align-items: center; justify-content: start; gap: .65rem; margin-top: .7rem; }
.git-sync-toggle { display: inline-flex; align-items: center; gap: .4rem; }
.git-sync-settings-body #git-sync-interval { width: 12rem; }
.git-sync-settings-body #git-settings-save { width: 6rem; }

@media (max-width: 640px) {
  .git-version-info { gap: .7rem; padding: .85rem; }
  .git-version-header { justify-content: space-between; }
  .git-version-controls { grid-template-columns: 1fr; gap: .3rem; }
  .git-version-controls .material-select { width: 100%; }
  .git-sync-actions .btn { width: 100%; }
  .git-sync-settings-body { grid-template-columns: auto minmax(0, 1fr); }
  .git-sync-toggle { grid-column: 1 / -1; }
  .git-sync-interval-label { align-self: center; }
  .git-sync-settings-body #git-sync-interval { width: 100%; }
  .git-sync-settings-body #git-settings-save { grid-column: 1 / -1; justify-self: end; }
}
.sharing-panel{margin:0 0 24px;padding:20px;border:1px solid var(--border);border-radius:16px;background:var(--surface)}
.sharing-panel h2{margin-top:0}.sharing-panel form{display:grid;gap:14px}.share-link-list{display:grid;gap:16px}
.share-link-item{padding:16px;border:1px solid var(--border);border-radius:12px}
.share-link-item.is-revoked{border-color:#ef4444;background:color-mix(in srgb,#ef4444 8%,var(--surface))}
.share-link-revoked-heading{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;margin-bottom:1rem}.share-link-status{display:inline-flex;padding:.3rem .65rem;border-radius:999px;font-weight:700}.share-link-status.revoked{background:#fee2e2;color:#991b1b}.share-link-label{margin:0;color:var(--text)}
.share-password-page{display:grid;min-height:calc(100vh - 10rem);min-height:calc(100dvh - 10rem);padding:2rem 0;place-items:center}
.share-password-card{width:min(100%,30rem);padding:clamp(1.5rem,5vw,2.25rem);border:1px solid var(--border);border-radius:20px;background:var(--surface);box-shadow:0 18px 48px rgba(15,23,42,.14);text-align:center}
.share-password-card h1{margin:0 0 .75rem}.share-password-card>p{margin:0 0 1.5rem;color:var(--muted)}
.share-password-card form{display:grid;gap:16px;text-align:left}.share-password-card form>.btn{width:100%;justify-content:center}
.password-input{display:grid;grid-template-columns:minmax(0,1fr) 48px;align-items:center;border:1px solid var(--border);border-radius:8px;background:var(--surface)}
.password-input:focus-within{border-color:var(--primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--primary) 18%,transparent)}
.password-input input{width:100%;border:0!important;box-shadow:none!important;background:transparent!important}
.password-input button{display:grid;width:48px;height:48px;padding:0;border:0;background:transparent;color:var(--muted);cursor:pointer;place-items:center}
.password-input button:hover{color:var(--text)}
.copy-input{display:grid;grid-template-columns:minmax(0,1fr) 48px;align-items:stretch;border:1px solid var(--border);border-radius:8px;background:var(--surface);overflow:hidden}.copy-input input{min-width:0;border:0;border-radius:0;background:transparent}.copy-input button{display:grid;width:48px;padding:0;border:0;border-left:1px solid var(--border);background:transparent;color:var(--muted);cursor:pointer;place-items:center}.copy-input button:hover{color:var(--text)}.copy-input button.is-copied{color:#15803d;background:#dcfce7}
.compact-expiry{margin-top:12px}.material-field[hidden]{display:none}
.share-link-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;margin-top:1rem}
.share-link-actions .btn-danger{margin-left:auto}
.share-link-password-form{margin-top:1rem;padding-top:1rem;border-top:1px solid var(--border)}
.btn.is-copied{border-color:#15803d;background:#dcfce7;color:#166534}
.action-toast{position:fixed;z-index:1000;top:1rem;left:50%;min-width:min(90vw,22rem);padding:.75rem 1rem;border:1px solid #2563eb;border-radius:10px;background:rgba(239,246,255,.96);color:#1e3a8a;box-shadow:0 10px 28px rgba(15,23,42,.16);text-align:center;opacity:0;transform:translate(-50%,-.75rem);transition:opacity .18s ease,transform .18s ease}
.action-toast[data-visible="true"]{opacity:1;transform:translate(-50%,0)}
.action-toast[data-type="create"]{border-color:#16a34a;background:rgba(240,253,244,.96);color:#166534}
.action-toast[data-type="delete"],.action-toast[data-type="error"]{border-color:#dc2626;background:rgba(254,242,242,.96);color:#991b1b}
.action-toast[hidden]{display:none}
.login-landing{min-height:calc(100vh - 12rem);display:grid;place-items:center;padding:2rem 1rem}.login-landing-card{width:min(100%,38rem);padding:clamp(2rem,6vw,4rem);border:1px solid var(--border);border-radius:24px;background:var(--surface);box-shadow:0 18px 50px rgba(15,23,42,.12);text-align:center}.login-landing-mark{font-size:3rem;color:var(--accent)}.login-landing-eyebrow{margin:.75rem 0 .5rem;color:var(--muted);font-size:.78rem;font-weight:700;letter-spacing:.16em}.login-landing-card h1{margin:.25rem 0 1rem}.login-landing-card>p:not(.login-landing-eyebrow){color:var(--muted);line-height:1.8}.login-landing-action{margin-top:1.25rem}
@media (max-width:640px){.share-link-actions{display:grid;grid-template-columns:1fr 1fr}.share-link-actions .btn{justify-content:center}.share-link-actions .btn-danger{grid-column:1/-1;width:100%;margin-left:0}}
