:root {
  --bg: #f3f4f6; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --primary: #111827; --primary-h: #1f2937; --accent: #2563eb; --danger: #b91c1c;
  --ok-bg: #ecfdf5; --ok-fg: #047857; --warn-bg: #fffbeb; --warn-fg: #92400e; --none-bg: #f3f4f6; --none-fg: #6b7280;
  --cat-homepage-bg: #dbeafe; --cat-homepage-fg: #1e40af;
  --cat-lp-bg: #fce7f3;       --cat-lp-fg: #9d174d;
  --cat-mockup-bg: #ede9fe;   --cat-mockup-fg: #5b21b6;
  --cat-other-bg: #e5e7eb;    --cat-other-fg: #374151;
  --cat-none-bg: #f9fafb;     --cat-none-fg: #9ca3af;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; font-size: 14px; line-height: 1.6; }
a { color: var(--accent); }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.inline { display: inline; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(100%, 380px); }
.login h1 { margin-bottom: 4px; }
.login label { display: block; margin: 14px 0 0; font-size: 13px; color: #374151; }
.login input { display: block; width: 100%; margin-top: 6px; }
.login .btn { margin-top: 20px; }

/* ---- layout (左サイドバー + サイト一覧) ---- */
.layout { margin-bottom: 16px; }
.layout > .card { margin-bottom: 0; }
.layout.has-sidebar { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.sidebar { position: sticky; top: 68px; max-height: calc(100vh - 84px); overflow: auto; border-radius: 12px; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1920px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.container { max-width: 1920px; margin: 0 auto; padding: 16px 20px 60px; }
.card { background: var(--card); border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.03); margin-bottom: 16px; }
.section-head { margin-bottom: 12px; }
.section-head p { margin: 0; }
.count { display: inline-block; background: var(--none-bg); color: var(--muted); border-radius: 999px; padding: 0 9px; font-size: 12px; margin-left: 6px; vertical-align: middle; }
.empty { color: var(--muted); padding: 20px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; margin: 0; }

/* ---- controls ---- */
input[type=text], input[type=password], input[type=search], select { font: inherit; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; outline: none; background: #fff; color: var(--text); }
input[type=text]:focus, input[type=password]:focus, input[type=search]:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.btn { font: inherit; font-size: 13.5px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; background: #e5e7eb; color: var(--text); display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; line-height: 1.4; }
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.ghost { background: transparent; border-color: #d1d5db; }
.btn.danger { color: var(--danger); }
.btn.danger.ghost { border-color: #fecaca; }
.btn.small { font-size: 12px; padding: 4px 9px; }
.btn.xs { font-size: 11px; padding: 1px 7px; border-radius: 6px; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; line-height: 1.5; }
.tag.ok { background: var(--ok-bg); color: var(--ok-fg); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); }
.tag.none { background: var(--none-bg); color: var(--none-fg); }
.tag.t { background: #eef2ff; color: #3730a3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.alert.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: #a7f3d0; }
.alert.info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---- category badge ---- */
.cat { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 6px; white-space: nowrap; line-height: 1.6; }
.cat-homepage { background: var(--cat-homepage-bg); color: var(--cat-homepage-fg); }
.cat-lp       { background: var(--cat-lp-bg);       color: var(--cat-lp-fg); }
.cat-mockup   { background: var(--cat-mockup-bg);   color: var(--cat-mockup-fg); }
.cat-other    { background: var(--cat-other-bg);    color: var(--cat-other-fg); }
.cat-none     { background: var(--cat-none-bg);     color: var(--cat-none-fg); border: 1px dashed #d1d5db; }

/* ---- filters ---- */
.filters { background: var(--card); border-radius: 12px; padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.03); }
.filter-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-row + .filter-row { margin-top: 8px; }
.filter-lbl { margin: 14px 0 6px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.filter-text { flex: 1 1 100%; min-width: 0; padding: 7px 10px; font-size: 13px; }
.filter-sort { flex: 1 1 auto; min-width: 0; padding: 6px 8px; font-size: 13px; }
.filter-cats { flex-direction: column; align-items: stretch; gap: 4px; }
.filter-cats .pill { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 8px; border: 1px solid #d1d5db; background: #fff; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 4px; text-align: left; }
.filter-cats .pill .n { font-size: 11px; color: var(--muted); }
.filter-cats .pill:hover { border-color: #9ca3af; }
.filter-cats .pill.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.filter-cats .pill.active .n { color: #d1d5db; }
.filter-tags { gap: 4px; }
.filter-tags .chip { font: inherit; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; border: 1px solid #c7d2fe; background: #eef2ff; color: #3730a3; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.filter-tags .chip .n { font-size: 10.5px; opacity: .7; }
.filter-tags .chip:hover { background: #e0e7ff; }
.filter-tags .chip.active { background: #3730a3; border-color: #3730a3; color: #fff; }
.filter-count { margin: 12px 0 0; padding-top: 8px; border-top: 1px solid var(--line); }

/* ---- sites grid（幅に応じて列数を自動調整。1920px 幅で 5 列） ---- */
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.site { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 10px; background: #fff; display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 12.5px; position: relative; }
.site:hover { border-color: #cbd5e1; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.site.busy { opacity: .5; pointer-events: none; }
.site.hidden { display: none; }
.site-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.site-mtime { color: var(--muted); font-size: 11px; white-space: nowrap; }
.site-name { margin: 0; font-size: 14.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-name a { color: var(--text); text-decoration: none; }
.site-name a:hover { color: var(--accent); text-decoration: underline; }
.site-url { display: block; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.site-url:hover { color: var(--accent); text-decoration: underline; }
.meta-view { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; min-height: 22px; }
.site-tags { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; }
.site-props { margin: 2px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.prop { display: flex; gap: 8px; align-items: flex-start; }
.prop dt { flex: 0 0 64px; color: var(--muted); font-size: 11px; line-height: 1.9; }
.prop dd { margin: 0; flex: 1; min-width: 0; }
.prop code { font-size: 11.5px; }
.entry-view, .pw-view, .status { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.inline-form input[type=text] { flex: 1 1 120px; min-width: 0; padding: 4px 8px; font-size: 12.5px; }
.site-actions { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); }
.site-actions .js-delete { margin-left: auto; }

/* ---- meta form (category + tags) ---- */
.meta-form { flex-direction: column; align-items: stretch; gap: 6px; background: #f9fafb; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.meta-form .mini { display: block; font-size: 11px; color: var(--muted); }
.meta-form select { display: block; width: 100%; margin-top: 2px; padding: 4px 8px; font-size: 12.5px; }
.meta-form .form-actions { display: flex; gap: 6px; }

/* ---- tag editor ---- */
.tag-editor { position: relative; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border: 1px solid #d1d5db; border-radius: 8px; padding: 4px 6px; background: #fff; margin-top: 2px; cursor: text; }
.tag-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.tag-editor .chips { display: contents; }
.tag-editor .chip { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; padding: 0 4px 0 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; max-width: 100%; }
.tag-editor .chip .x { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 13px; line-height: 1; padding: 0 3px; opacity: .6; }
.tag-editor .chip .x:hover { opacity: 1; }
.tag-editor input.tag-input { flex: 1 1 120px; min-width: 100px; border: 0 !important; box-shadow: none !important; padding: 2px 4px !important; font-size: 12.5px; background: transparent; }
.tag-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; background: #fff; border: 1px solid #d1d5db; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: 200px; overflow: auto; padding: 4px; }
.tag-suggest .opt { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.tag-suggest .opt .n { color: var(--muted); font-size: 11px; }
.tag-suggest .opt:hover, .tag-suggest .opt.sel { background: #eef2ff; }
.tag-suggest .opt.new { color: var(--accent); }
.tag-suggest .none { padding: 6px 8px; color: var(--muted); font-size: 12px; }

/* ---- upload ---- */
.upload { margin-bottom: 14px; }
.dropzone { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; border: 2px dashed #cbd5e1; border-radius: 10px; padding: 6px 12px; background: #fafafa; transition: .15s; outline: none; }
.dropzone.over { border-color: var(--accent); background: #eff6ff; }
.dropzone:focus-visible { border-color: var(--accent); }
.dz-icon { font-size: 20px; line-height: 1; }
.dz-text { font-size: 13px; }
.dz-limits { margin-left: auto; }
.upload-panel { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.upload-summary .label { color: var(--muted); }
.file-list { margin-top: 6px; }
.file-list summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.file-list ul { max-height: 220px; overflow: auto; margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #374151; }
.upload-options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin-top: 14px; }
.field { display: block; font-size: 13px; color: #374151; }
.field input, .field select { display: block; width: 100%; margin-top: 6px; }
.field .tag-editor { margin-top: 6px; padding: 6px 8px; }
fieldset.modes { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0; font-size: 13px; }
fieldset.modes legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
fieldset.modes label { display: block; margin: 4px 0; }
.upload-actions { display: flex; gap: 8px; margin-top: 14px; }
.progress { margin-top: 14px; }
.bar { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-log { margin-top: 10px; font-size: 12.5px; max-height: 160px; overflow: auto; background: #f9fafb; border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.upload-log .err { color: var(--danger); }

/* ---- forms ---- */
.cards-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.cards-row > .card { margin-bottom: 0; height: 100%; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.row-form input { flex: 1 1 240px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; max-width: 720px; }
.grid-form .span2 { grid-column: 1 / -1; }
.notes ul { margin: 8px 0 0; padding-left: 20px; }
.notes li { margin: 4px 0; color: #374151; }

@media (max-width: 1200px) {
  .layout.has-sidebar { grid-template-columns: 220px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .layout.has-sidebar { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .filter-cats { flex-direction: row; flex-wrap: wrap; }
  .filter-tags { max-height: 120px; overflow: auto; }
}
@media (max-width: 720px) {
  .card { padding: 18px 16px; }
  .upload-options, .grid-form, .cards-row { grid-template-columns: 1fr; }
  .sites-grid { grid-template-columns: 1fr; }
}
