* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: #f5f7fa;
  color: #2c3e50;
  line-height: 1.6;
  min-height: 100vh;
}
body.dashboard { display: flex; }
.sidebar {
  width: 240px;
  background: #1f2937;
  color: #e5e7eb;
  padding: 24px 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-header {
  padding: 0 24px 20px;
  border-bottom: 1px solid #374151;
  margin-bottom: 16px;
}
.sidebar-header h1 { font-size: 1.05rem; color: #fff; font-weight: 600; }
.sidebar-header .domain { font-size: 0.75rem; color: #9ca3af; margin-top: 4px; }
.sidebar-header .user-badge {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 8px;
  padding: 4px 8px;
  background: #374151;
  border-radius: 4px;
  display: inline-block;
}
.sidebar-nav { padding: 0 12px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #d1d5db;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.92rem;
  margin-bottom: 2px;
  transition: background 0.15s;
}
.sidebar-nav a:hover { background: #374151; color: #fff; }
.sidebar-nav a.active { background: #4a90e2; color: #fff; }
.sidebar-nav .admin-link {
  margin-top: 20px;
  border-top: 1px solid #374151;
  padding-top: 16px;
  color: #9ca3af;
  font-size: 0.85rem;
}
.sidebar-nav .nav-icon { width: 18px; text-align: center; }
.sidebar-nav .nav-divider {
  padding: 12px 14px 6px;
  margin-top: 8px;
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  border-top: 1px solid #374151;
}
.main {
  margin-left: 240px;
  flex: 1;
  padding: 40px;
  max-width: calc(100vw - 240px);
}
.page-header {
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
}
.page-header h2 { font-size: 1.5rem; color: #1a2733; }
.page-header p { color: #7a8a9a; font-size: 0.9rem; margin-top: 4px; }

/* === ビュー切り替えタブ === */
.view-tabs { display: flex; gap: 4px; }
.view-tabs .tab {
  padding: 8px 16px;
  text-decoration: none;
  color: #7a8a9a;
  font-size: 0.9rem;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  transition: all 0.15s;
}
.view-tabs .tab:hover { border-color: #4a90e2; color: #4a90e2; }
.view-tabs .tab.active {
  background: #4a90e2;
  color: #fff;
  border-color: #4a90e2;
}

.category { margin-bottom: 40px; scroll-margin-top: 20px; }
.category-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1a2733;
  display: flex;
  align-items: center;
  gap: 10px;
}
.category-title::before {
  content: "";
  width: 4px;
  height: 18px;
  background: #4a90e2;
  border-radius: 2px;
}
.category-desc {
  color: #7a8a9a;
  font-size: 0.85rem;
  margin-bottom: 16px;
  margin-left: 14px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

/* === カード + アクション === */
.card-wrap { position: relative; }
.card {
  background: #fff;
  padding: 18px;
  padding-right: 40px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-color: #4a90e2;
}
.card-icon { font-size: 1.5rem; margin-bottom: 8px; }
.card-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.card-desc { font-size: 0.8rem; color: #7a8a9a; }
.card-cat {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed #e5e7eb;
}
.external .card-title::after {
  content: " \2197";
  color: #4a90e2;
  font-size: 0.85em;
}

.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.inline-form { display: inline; margin: 0; }
.fav-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 1rem;
  color: #d1d5db;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.fav-btn:hover { background: rgba(74,144,226,0.1); color: #4a90e2; }
.fav-btn.star-on { color: #f59e0b; }
.fav-btn.star-on:hover { color: #d97706; background: rgba(245,158,11,0.1); }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: #7a8a9a;
  background: #fff;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
}
.empty-state p { margin-bottom: 8px; }
.empty-state a { color: #4a90e2; }

body.admin {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}
.admin-header h1 { font-size: 1.4rem; color: #1a2733; }
.admin-header .back-link {
  color: #4a90e2;
  text-decoration: none;
  font-size: 0.9rem;
}
.admin-header .back-link:hover { text-decoration: underline; }
.info-box {
  padding: 12px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #1e40af;
  font-size: 0.85rem;
  margin-bottom: 24px;
}
.flash {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  font-size: 0.9rem;
}
.flash.success { background: #d1f7e0; color: #14532d; border: 1px solid #86efac; }
.flash.error { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.admin-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
}
.admin-section h2 { font-size: 1.1rem; margin-bottom: 16px; color: #1a2733; }
.category-block {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fafbfc;
}
.category-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}
.category-block-title { font-weight: 600; font-size: 1rem; color: #1a2733; }
.category-block-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-row {
  display: grid;
  grid-template-columns: 40px 1fr 1.5fr 2fr 60px 100px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed #e5e7eb;
}
.tool-row:last-child { border-bottom: none; }
.tool-row .icon { font-size: 1.3rem; text-align: center; }
.tool-row .title { font-weight: 500; font-size: 0.9rem; }
.tool-row .desc { color: #7a8a9a; font-size: 0.85rem; }
.tool-row .url {
  color: #4a90e2;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-row .ext-badge {
  font-size: 0.7rem;
  background: #e0e7ff;
  color: #3730a3;
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
}
.tool-row .actions { display: flex; gap: 4px; justify-content: flex-end; }
input[type="text"], input[type="url"], textarea, select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #4a90e2;
  box-shadow: 0 0 0 2px rgba(74,144,226,0.15);
}
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}
.form-grid {
  display: grid;
  grid-template-columns: 80px 1fr 1.5fr 2fr 100px;
  gap: 8px;
  align-items: end;
}
.checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.btn {
  padding: 7px 14px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  color: #374151;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: #4a90e2; color: #fff; border-color: #4a90e2; }
.btn-primary:hover { background: #3b7dd1; }
.btn-danger { background: #fff; color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 4px 8px; font-size: 0.75rem; }
.btn-icon { padding: 4px 8px; font-size: 0.85rem; min-width: 32px; justify-content: center; }
footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  color: #aab5c0;
  font-size: 0.8rem;
}
@media (max-width: 768px) {
  body.dashboard { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; padding: 16px 0; }
  .main { margin-left: 0; padding: 24px 16px; max-width: 100vw; }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-nav a { font-size: 0.85rem; padding: 8px 12px; }
  .tool-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .view-tabs { width: 100%; }
  .view-tabs .tab { flex: 1; text-align: center; }
}
