:root {
  --primary: #075ea8;
  --primary-dark: #064b84;
  --primary-soft: #eaf4ff;
  --accent: #f2b544;
  --surface: #ffffff;
  --page: #f5f7fa;
  --text: #172033;
  --muted: #667085;
  --border: #d6deea;
  --danger: #b42318;
  --success: #087443;
  --shadow: 0 12px 32px rgba(19, 43, 73, 0.1);
  --radius: 14px;
  --container: 1180px;
}

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

html { color-scheme: light; scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: "Noto Sans JP", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  line-height: 1.6;
}

button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

:focus-visible {
  outline: 3px solid rgba(7, 94, 168, 0.28);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.app-container { width: min(calc(100% - 40px), var(--container)); margin-inline: auto; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(214, 222, 234, 0.9);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
}

.header-inner { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 16px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 900;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #0b73c9, #064b84);
  box-shadow: 0 5px 12px rgba(7, 94, 168, 0.22);
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid #b8d5ef;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.local-badge > span { color: var(--success); font-size: 0.62rem; }

.privacy-note { border-bottom: 1px solid #eee0bd; color: #72551d; background: #fff9e9; }
.privacy-note-inner { display: flex; min-height: 38px; align-items: center; gap: 9px; font-size: 0.78rem; }
.privacy-note p { margin: 0; }

.board { padding-block: 34px 56px; }

.board-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
}

.eyebrow, .dialog-kicker {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

h1 { margin: 0; font-size: clamp(1.65rem, 4vw, 2.35rem); line-height: 1.25; letter-spacing: -0.03em; }
.lead { margin: 7px 0 0; color: var(--muted); font-size: 0.94rem; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 800;
  line-height: 1.25;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.button:hover { transform: translateY(-1px); }
.button-primary { border-color: var(--primary); color: #fff; background: var(--primary); box-shadow: 0 6px 14px rgba(7, 94, 168, 0.18); }
.button-primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.button-secondary { border-color: var(--border); color: #344054; background: #fff; }
.button-secondary:hover { border-color: #a9bad0; background: #f9fbfd; }
.add-button { flex: 0 0 auto; padding-inline: 20px; }

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(150px, 220px) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(19, 43, 73, 0.05);
}

.field-label { display: block; margin-bottom: 5px; color: #475467; font-size: 0.74rem; font-weight: 800; }
.search-input-wrap { position: relative; display: flex; align-items: center; }
.search-input-wrap > span { position: absolute; left: 13px; color: #7d8a9d; font-size: 1.35rem; transform: rotate(-12deg); pointer-events: none; }

.search-field input, .filter-field select, .form-field input, .form-field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7d1df;
  border-radius: 9px;
  color: var(--text);
  background: #fff;
}

.search-field input { padding: 9px 42px 9px 42px; }
.filter-field select { padding: 8px 34px 8px 12px; }
.search-field input::placeholder, .form-field input::placeholder, .form-field textarea::placeholder { color: #98a2b3; }
.search-field input:focus, .filter-field select:focus, .form-field input:focus, .form-field textarea:focus { border-color: var(--primary); outline: 3px solid rgba(7, 94, 168, 0.12); }

.clear-search {
  position: absolute;
  right: 7px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: #667085;
  background: transparent;
}

.clear-search:hover { background: #eef2f7; }
.toolbar-buttons { display: flex; gap: 8px; }
.button-filter { border-color: var(--border); color: #475467; background: #fff; }
.button-filter[aria-pressed="true"] { border-color: #e5b136; color: #765312; background: #fff7dc; }
.button-filter[aria-pressed="true"] > span:first-child { color: #d99300; }

.result-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 17px 2px 10px; color: var(--muted); font-size: 0.78rem; }
.result-bar p { margin: 0; }
.result-bar [data-result-count] { color: #344054; font-weight: 800; }

.snippet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 15px; align-items: stretch; }

.snippet-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 260px;
  flex-direction: column;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 17px rgba(19, 43, 73, 0.055);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.snippet-card:hover, .snippet-card:focus-within { border-color: #aecce8; box-shadow: var(--shadow); transform: translateY(-2px); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-heading { min-width: 0; }
.category-chip { display: inline-block; max-width: 100%; overflow: hidden; color: var(--primary-dark); font-size: 0.7rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.card-title { margin: 2px 0 0; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.45; }
.card-actions { display: flex; flex: 0 0 auto; gap: 3px; }

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 9px;
  color: #667085;
  background: transparent;
  font-size: 1.05rem;
}

.icon-button:hover { color: var(--primary); background: var(--primary-soft); }
.favorite-button.is-favorite { color: #d28a00; background: #fff8e2; }
.delete-button:hover { color: var(--danger); background: #fff0ef; }

.snippet-body {
  display: -webkit-box;
  min-height: calc(1.65em * 4);
  margin: 0;
  overflow: hidden;
  color: #475467;
  font-size: 0.86rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.snippet-card.is-expanded .snippet-body { display: block; max-height: none; }
.expand-button { align-self: flex-start; margin: 7px 0 12px; padding: 4px 0; border: 0; color: var(--primary); background: transparent; font-size: 0.76rem; font-weight: 800; }
.expand-button:hover { text-decoration: underline; }
.card-spacer { flex: 1; min-height: 14px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 13px; border-top: 1px solid #edf0f4; }
.updated-at { color: #8490a1; font-size: 0.68rem; white-space: nowrap; }
.copy-button { min-width: 122px; }
.copy-button.is-copied { border-color: var(--success); background: var(--success); }

.empty-state { display: grid; min-height: 330px; place-items: center; align-content: center; gap: 7px; padding: 28px; border: 1px dashed #b8c5d5; border-radius: var(--radius); color: var(--muted); text-align: center; background: rgba(255,255,255,0.7); }
.empty-state h2, .empty-state p { margin: 0; }
.empty-state h2 { color: #344054; font-size: 1.05rem; }
.empty-state p { margin-bottom: 10px; font-size: 0.85rem; }
.empty-icon { font-size: 2rem; color: #9cb5cd; }

.toast {
  position: fixed;
  top: 76px;
  right: 18px;
  z-index: 100;
  display: flex;
  max-width: min(390px, calc(100% - 36px));
  align-items: center;
  gap: 14px;
  padding: 11px 12px 11px 15px;
  border: 1px solid #a8dcc5;
  border-radius: 11px;
  color: #065c37;
  background: #edfcf5;
  box-shadow: var(--shadow);
  font-size: 0.83rem;
  font-weight: 700;
}

.toast.is-error { border-color: #f2bbb5; color: #8f1d14; background: #fff1f0; }
.toast button { width: 30px; height: 30px; border: 0; border-radius: 7px; color: inherit; background: transparent; font-size: 1.1rem; }

.app-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: min(90dvh, 820px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  background: transparent;
  box-shadow: 0 28px 80px rgba(15, 32, 55, 0.28);
}

.app-dialog::backdrop { background: rgba(13, 25, 42, 0.52); backdrop-filter: blur(2px); }
.dialog-card { display: flex; max-height: min(90dvh, 820px); flex-direction: column; background: #fff; }
.dialog-card-small { max-width: 520px; margin-inline: auto; }
.dialog-header { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 19px 21px; border-bottom: 1px solid #e5eaf0; }
.dialog-header h2 { margin: 0; font-size: 1.18rem; }
.dialog-close { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 9px; color: #667085; background: #f2f4f7; font-size: 1.35rem; }
.dialog-close:hover { color: #344054; background: #e7ebf0; }
.dialog-body { display: grid; gap: 17px; padding: 20px 21px; overflow-y: auto; }
.dialog-footer { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 9px; padding: 14px 21px; border-top: 1px solid #e5eaf0; background: #fbfcfd; }

.form-field { display: block; }
.form-field > span { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; color: #344054; font-size: 0.82rem; font-weight: 800; }
.form-field strong { color: var(--primary); font-size: 0.68rem; }
.form-field input, .form-field textarea { display: block; padding: 10px 12px; }
.form-field textarea { min-height: 190px; resize: vertical; line-height: 1.6; }
.form-field small, .data-action small, .import-option small { display: block; margin-top: 4px; color: var(--muted); font-size: 0.72rem; font-weight: 400; }
.favorite-check { display: flex; min-height: 46px; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; color: #475467; font-size: 0.84rem; font-weight: 700; }
.favorite-check input { width: 19px; height: 19px; accent-color: var(--primary); }
.favorite-check > span { color: #d28a00; }
.form-error { margin: 0; padding: 9px 11px; border-radius: 8px; color: #8f1d14; background: #fff1f0; font-size: 0.78rem; }

.data-help { margin: 0; color: var(--muted); font-size: 0.82rem; }
.data-actions { display: grid; gap: 9px; }
.data-action { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 11px; align-items: center; width: 100%; min-height: 68px; padding: 11px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-align: left; background: #fff; }
.data-action:hover { border-color: #9fc4e5; background: #f8fbff; }
.data-action-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 9px; color: var(--primary); background: var(--primary-soft); font-size: 1.25rem; font-weight: 900; }
.data-action strong { font-size: 0.86rem; }

.import-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.import-summary div { padding: 10px; border: 1px solid var(--border); border-radius: 9px; text-align: center; background: #f9fbfd; }
.import-summary dt { color: var(--muted); font-size: 0.68rem; }
.import-summary dd { margin: 2px 0 0; color: var(--primary-dark); font-weight: 900; }
.import-options { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
.import-options legend { margin-bottom: 6px; color: #344054; font-size: 0.8rem; font-weight: 800; }
.import-option { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 11px; border: 1px solid var(--border); border-radius: 9px; }
.import-option:has(input:checked) { border-color: #82b6e3; background: #f1f8ff; }
.import-option input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.import-option-danger:has(input:checked) { border-color: #e1a7a1; background: #fff4f3; }

@media (max-width: 820px) {
  .toolbar { grid-template-columns: 1fr 180px; }
  .toolbar-buttons { grid-column: 1 / -1; }
  .toolbar-buttons .button { flex: 1; }
}

@media (max-width: 620px) {
  .app-container { width: min(calc(100% - 28px), var(--container)); }
  .header-inner { min-height: 56px; }
  .brand { font-size: 0.94rem; }
  .brand-mark { width: 31px; height: 31px; }
  .local-badge { padding: 4px 8px; font-size: 0.68rem; }
  .privacy-note-inner { align-items: flex-start; padding-block: 7px; line-height: 1.45; }
  .board { padding-block: 23px 42px; }
  .board-intro { align-items: stretch; flex-direction: column; gap: 16px; margin-bottom: 18px; }
  .lead { font-size: 0.84rem; }
  .add-button { width: 100%; }
  .toolbar { grid-template-columns: 1fr; padding: 12px; }
  .toolbar-buttons { grid-column: auto; }
  .toolbar-buttons .button { min-width: 0; padding-inline: 9px; font-size: 0.78rem; }
  .filter-field select { width: 100%; }
  .sort-note { display: none; }
  .snippet-grid { grid-template-columns: minmax(0, 1fr); }
  .snippet-card { min-height: 245px; padding: 15px; }
  .card-header { gap: 6px; }
  .card-footer { align-items: stretch; flex-direction: column-reverse; }
  .copy-button { width: 100%; min-height: 48px; }
  .updated-at { text-align: right; }
  .toast { top: 68px; right: 14px; }
  .app-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); }
  .dialog-card { max-height: calc(100dvh - 20px); }
  .dialog-header, .dialog-body { padding-inline: 16px; }
  .dialog-footer { padding: 12px 16px; }
  .dialog-footer .button { flex: 1; min-width: 0; }
  .form-field textarea { min-height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
