:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --card-border: #e4e6eb;
  --text: #1f2330;
  --muted: #6b7280;
  --accent: #5b8def;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.hero {
  text-align: center;
  padding: 56px 24px 24px;
  background: #ebeef2;
}
.hero h1 {
  margin: 0 0 12px;
  font-size: 40px;
  font-weight: 400;
  letter-spacing: 0.5px;
}
.hero p {
  margin: 0 auto;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.6;
}
.hero code {
  background: #d8dde4;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 32px auto 8px;
  max-width: 900px;
  padding: 0 24px;
}
#search {
  flex: 1;
  max-width: 640px;
  padding: 12px 16px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.sort {
  border: 1px solid var(--card-border);
  background: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
}

.count {
  text-align: center;
  color: var(--muted);
  margin: 6px 0 18px;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  padding: 0 24px 48px;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.card-create {
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: #fafbfc;
  border: 1px dashed #c8cdd6;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  min-height: 280px;
}
.card-create .plus { font-size: 22px; line-height: 1; }

.card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  gap: 8px;
}
.card-title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.menu {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.menu:hover { background: #eef0f3; }

.card-thumb {
  display: block;
  margin: 0 14px;
  border-radius: 8px;
  overflow: hidden;
  background:
    repeating-conic-gradient(#e4e6eb 0% 25%, #f4f5f7 0% 50%) 0 / 16px 16px;
  aspect-ratio: 16 / 9;
}
.card-thumb canvas { width: 100%; height: 100%; display: block; }

.card footer {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--card-border);
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.card-meta .label {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #9aa1ad;
}
.card-modified { color: var(--text); font-size: 13px; margin-top: 2px; }

.menu-popover {
  position: absolute;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 4px;
  z-index: 100;
  min-width: 140px;
}
.menu-popover button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.menu-popover button:hover { background: #f4f5f7; }
.menu-popover button.danger { color: #c33; }
