:root {
  --surface-0: #faf9f7;
  --surface-1: #f1efe8;
  --surface-2: #ffffff;
  --text-primary: #1f1e1c;
  --text-secondary: #5f5e5a;
  --text-muted: #888780;
  --text-success: #0f6e56;
  --border: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-0: #1a1a18;
    --surface-1: #242422;
    --surface-2: #2c2c2a;
    --text-primary: #f1efe8;
    --text-secondary: #b4b2a9;
    --text-muted: #888780;
    --text-success: #5dcaa5;
    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.24);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1.25rem 3rem;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.shell {
  max-width: 1040px;
  margin: 0 auto;
  background: var(--surface-1);
  border-radius: 12px;
  padding: 1.5rem;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

h1 { font-size: 20px; font-weight: 500; margin: 0; }
.sub { font-size: 13px; color: var(--text-secondary); margin: 2px 0 0; }

.gen {
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s;
}
.gen:hover:not(:disabled) { background: var(--surface-2); }
.gen:active:not(:disabled) { transform: scale(0.98); }
.gen:disabled { opacity: 0.55; cursor: default; }
.gen.loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.row { display: flex; align-items: flex-start; gap: 4px; }
.row + .row { margin-top: 6px; }

.title { font-size: 14px; font-weight: 500; margin: 0; line-height: 1.4; flex: 1; }
.desc { font-size: 13px; color: var(--text-secondary); margin: 0; line-height: 1.5; flex: 1; }

.copy {
  flex-shrink: 0;
  padding: 2px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  line-height: 1;
}
.copy:hover { color: var(--text-primary); background: var(--surface-1); }
.copy.done { color: var(--text-success); }

.inspired {
  font-size: 11px;
  color: var(--text-muted);
  margin: 10px 0 0;
  line-height: 1.4;
}

.mine {
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 1.5rem;
}

.mine-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

#draft {
  width: 100%;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 0.5px solid var(--border-strong);
  background: var(--surface-0);
  color: var(--text-primary);
  resize: vertical;
  min-height: 76px;
}
#draft:focus {
  outline: none;
  border-color: var(--text-secondary);
}
#draft::placeholder { color: var(--text-muted); }

.mine-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 10px;
}
.chars { font-size: 12px; color: var(--text-muted); }
.chars.near-limit { color: #993c1d; }
@media (prefers-color-scheme: dark) {
  .chars.near-limit { color: #f5c4b3; }
}

#polished:not(:empty) { margin-top: 12px; }
.card.polished { border-color: var(--border-strong); }
.dismiss { margin-top: 10px; padding-left: 0; padding-right: 0; }
.dismiss:hover { border-color: transparent; text-decoration: underline; }

.warn {
  font-size: 11px;
  color: #7a4a08;
  background: #faeeda;
  border-radius: 6px;
  padding: 6px 8px;
  margin: 10px 0 0;
  line-height: 1.4;
}
@media (prefers-color-scheme: dark) {
  .warn { color: #f0cf9a; background: #3d2a08; }
}

.section-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.history { margin-top: 1.75rem; }

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 10px;
}
.history-head h2 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0;
}

.ghost {
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 0.5px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.ghost:hover { color: var(--text-primary); border-color: var(--border-strong); }

.batch { border-top: 0.5px solid var(--border); }

.batch summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}
.batch summary::-webkit-details-marker { display: none; }
.batch summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.4px solid currentColor;
  border-bottom: 1.4px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.batch[open] summary::before { transform: rotate(45deg); }
.batch summary:hover { color: var(--text-primary); }
.batch .count { color: var(--text-muted); font-size: 12px; }
.batch .cards { padding: 2px 0 14px; }

.empty, .error {
  font-size: 14px;
  padding: 1.25rem;
  border-radius: 12px;
  text-align: center;
}
.empty { color: var(--text-secondary); background: var(--surface-2); border: 0.5px dashed var(--border-strong); }
.error {
  color: #993c1d;
  background: #faece7;
  border: 0.5px solid #f0997b;
  text-align: left;
  margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  .error { color: #f5c4b3; background: #4a1b0c; border-color: #993c1d; }
}
