:root {
  color-scheme: dark;
  --canvas: #171512;
  --surface: #221f1b;
  --surface-2: #2b2722;
  --ink: #f1ece3;
  --muted: #a79e92;
  --line: #37322b;
  --line-strong: #4a4339;
  --accent: #e0a458;
  --accent-dark: #b5792f;
  --sans: "Yu Gothic Medium", "游ゴシック体", "Yu Gothic", YuGothic, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0 auto;
  max-width: 1100px;
  background: linear-gradient(180deg, #1c1a16 0%, var(--canvas) 100%);
  color: var(--ink);
  font: 15px/1.65 var(--sans);
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 9px;
  transform: translateY(-180%);
}
.skip-link:focus { transform: none; }

.topbar { padding: 18px 20px 8px; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: -0.04em; color: var(--accent); }

.search-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 14px;
  background: rgba(23, 21, 18, 0.86);
  backdrop-filter: blur(10px);
}
.search-field {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-width: 0;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 12px;
}
.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(224, 164, 88, 0.16);
}
.search-icon { display: grid; place-items: center; color: var(--muted); }
.search-icon svg { width: 20px; height: 20px; }
.search-field input {
  width: 100%;
  min-width: 0;
  padding: 13px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}
.search-field input::placeholder { color: #7d7669; }
.search-shortcut {
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 1px 7px;
  font-size: 11px;
}
.clear-button {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  padding: 9px;
}

main { padding: 0 20px 20px; }
.favorites { margin: 4px 0 18px; }
.favorite-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.favorites .tool-grid { margin-top: 10px; }

.purposes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.purpose-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  text-align: left;
  color: var(--ink);
}
.purpose-card.write { background: #402029; }
.purpose-card.prompt { background: #1f2440; }
.purpose-card.review { background: #182a38; }
.purpose-card.learn { background: #233018; }
.purpose-card.build { background: #163330; }
.purpose-card.work { background: #2a2140; }
.purpose-card:hover { transform: translateY(-2px); }
.purpose-card.is-active,
.purpose-card[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.purpose-card__top {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.purpose-card__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.25);
}
.purpose-card__count { font-size: 12px; color: var(--muted); font-weight: 650; }
.purpose-card strong { font-size: 16px; letter-spacing: -0.02em; }
.purpose-card__desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.list-toolbar p { margin: 0; font-weight: 650; color: var(--muted); }
.view-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.view-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 9px;
}
.view-button[aria-pressed="true"] {
  background: rgba(224, 164, 88, 0.18);
  color: var(--accent);
  font-weight: 750;
}

.tool-sections { display: flex; flex-direction: column; gap: 28px; }
.tool-category__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
}
.category-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--tone-soft, #2b2722);
  color: var(--tone, #e0a458);
}
.tool-category__head h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.section-count { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 650; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.tool-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.tool-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 19px;
  bottom: 19px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tone, #e0a458);
}
.tool-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.tool-card__link {
  display: flex;
  height: 100%;
  padding: 20px 48px 20px 22px;
}
.tool-card__content { display: block; min-width: 0; }
.tool-card__top { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.tool-card__kind {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--tone-soft, #2b2722);
  color: var(--tone, #e0a458);
  font-size: 11px;
  font-weight: 700;
}
.tool-card__name {
  font-size: 15px;
  font-weight: 750;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.tool-card:hover .tool-card__name { color: var(--accent); }
.tool-card__desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
  margin-top: 7px;
}
.tool-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 11px;
}
.tool-card__format {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
}
.tool-card__open { color: var(--accent); font-weight: 700; }
.favorite-button {
  position: absolute;
  z-index: 2;
  right: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #6f685c;
  font-size: 20px;
  line-height: 1;
}
.favorite-button:hover { background: var(--surface-2); color: var(--accent); }
.favorite-button[aria-pressed="true"] { background: rgba(224, 164, 88, 0.2); color: var(--accent); }

.tool-sections.is-list .tool-grid { grid-template-columns: 1fr; gap: 8px; }
.tool-sections.is-list .tool-card__desc { -webkit-line-clamp: 1; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: var(--surface);
}
.empty-state h2 { font-size: 18px; margin: 0; }
.empty-state p { color: var(--muted); margin: 7px 0 17px; }
.empty-state button {
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #1b1611;
  font-weight: 700;
  padding: 10px 17px;
}

.plist-footer {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  padding: 18px 20px 28px;
}
.plist-footer span { margin-right: auto; font-weight: 750; color: var(--muted); }
.plist-footer a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 800px) {
  .purposes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-grid { grid-template-columns: 1fr; }
  .search-shortcut { display: none; }
}
@media (max-width: 520px) {
  .purposes { grid-template-columns: 1fr; }
  .view-switch { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
