/* ポータル — ライト/ダーク両対応。配色は CSS 変数で一元管理 */

:root {
  --bg: #f4f6fb;
  --bg-blob-1: rgba(99, 102, 241, 0.14);
  --bg-blob-2: rgba(16, 185, 129, 0.10);
  --bg-blob-3: rgba(236, 72, 153, 0.08);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #1e293b;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --green: #10b981;
  --violet: #8b5cf6;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
  --shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.06), 0 16px 40px -16px rgba(15, 23, 42, 0.22);
}

[data-theme='dark'] {
  --bg: #0b0e16;
  --bg-blob-1: rgba(99, 102, 241, 0.18);
  --bg-blob-2: rgba(16, 185, 129, 0.10);
  --bg-blob-3: rgba(236, 72, 153, 0.09);
  --surface: #121726;
  --surface-2: #161c2e;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px -14px rgba(0, 0, 0, 0.65);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b0e16;
    --bg-blob-1: rgba(99, 102, 241, 0.18);
    --bg-blob-2: rgba(16, 185, 129, 0.10);
    --bg-blob-3: rgba(236, 72, 153, 0.09);
    --surface: #121726;
    --surface-2: #161c2e;
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.26);
    --text: #e2e8f0;
    --text-2: #94a3b8;
    --text-3: #64748b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px -14px rgba(0, 0, 0, 0.65);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Noto Sans JP', 'Yu Gothic UI', Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* 背景の装飾ブロブ */
.blobs {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.blobs::before,
.blobs::after,
.blobs .blob {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
}
.blobs::before { width: 480px; height: 480px; top: -160px; left: -120px; background: var(--bg-blob-1); }
.blobs::after  { width: 420px; height: 420px; top: 120px; right: -140px; background: var(--bg-blob-2); }
.blobs .blob   { width: 380px; height: 380px; bottom: -180px; left: 30%; background: var(--bg-blob-3); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- ヘッダー ---------- */
header.site-header {
  padding: 56px 0 8px;
}
.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
h1.site-title {
  margin: 0;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.site-title .title-text {
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 70%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.site-title .title-emoji { -webkit-text-fill-color: initial; }
.site-sub {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 14px;
}
.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  font-size: 17px;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); transform: translateY(-1px); }

#stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 8px;
}
.stat {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stat-num {
  font-weight: 800;
  font-size: 16px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12px; color: var(--text-2); }

/* ---------- セクション ---------- */
main { padding-bottom: 72px; }
.section { margin-top: 40px; }
.section-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
}
.section-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-3);
}

/* ---------- カード ---------- */
.grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.card[data-id] { cursor: default; }
.card:has(.card-actions .open-link) { cursor: pointer; }
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: hsla(var(--hue, 230), 80%, 60%, 0.45);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-tile {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 13px;
  background: linear-gradient(135deg,
    hsla(var(--hue, 230), 85%, 60%, 0.18),
    hsla(calc(var(--hue, 230) + 40), 85%, 55%, 0.14));
  border: 1px solid hsla(var(--hue, 230), 70%, 55%, 0.25);
}
.card-titles {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.card-titles h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1.5px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-public    { color: #047857; background: rgba(16, 185, 129, 0.12); }
.badge-tailscale { color: #6d28d9; background: rgba(139, 92, 246, 0.13); }
.badge-repo      { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
[data-theme='dark'] .badge-public    { color: #34d399; }
[data-theme='dark'] .badge-tailscale { color: #a78bfa; }

.card-desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  font-size: 11px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 8px;
}

.card-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-host {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.host-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.host-text.muted { font-family: inherit; }
.card-actions { display: flex; align-items: center; gap: 10px; }
.open-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.open-link:hover { text-decoration: underline; }
.repo-link {
  color: var(--text-3);
  display: inline-flex;
  transition: color 0.15s, transform 0.15s;
}
.repo-link:hover { color: var(--text); transform: translateY(-1px); }

/* ステータスドット */
.status-dot {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text-3);
}
.status-dot.checking { background: var(--text-3); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.up { background: var(--green); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.status-dot.down { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* ---------- フッター ---------- */
footer.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 34px;
  font-size: 12.5px;
  color: var(--text-3);
}
footer.site-footer a { color: var(--text-2); text-decoration: none; font-weight: 600; }
footer.site-footer a:hover { color: var(--accent); }

@media (max-width: 560px) {
  header.site-header { padding-top: 36px; }
  .header-row { flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .card:hover { transform: none; }
}

/* ---------- ログイン画面 ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-wrap { width: 100%; padding: 24px; }
.login-card {
  max-width: 380px;
  margin: 0 auto;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-hover);
  text-align: center;
}
.login-icon { font-size: 40px; }
.login-title {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 70%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-sub { margin: 0; font-size: 13px; color: var(--text-2); }
.login-error {
  margin: 0;
  font-size: 12.5px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 6px 10px;
}
.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.login-input {
  padding: 11px 14px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.login-btn {
  margin-top: 4px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px rgba(99, 102, 241, 0.6); }

/* ---------- 配布ファイル ---------- */
.file-list {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px dashed var(--border);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--surface-2); }
.file-icon { flex-shrink: 0; font-size: 18px; }
.file-name {
  font-weight: 600;
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-meta {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.file-dl {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.files-empty {
  padding: 22px 18px;
  font-size: 13px;
  color: var(--text-3);
}

@media (max-width: 560px) {
  .file-meta { display: none; }
  .file-row { justify-content: space-between; }
}
