:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #2b2b2b;
  --text-muted: #8a8a8a;
  --border: #e4e0da;
  --accent: #3d7a5c;
  --accent-contrast: #ffffff;
  --danger: #b5462f;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 96px;
  min-height: 100vh;
}

h1 {
  font-size: 1.1rem;
  margin: 0;
}

#landing {
  padding-top: 20vh;
  text-align: center;
}
#landing p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 12px 0 24px;
}

button {
  font: inherit;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
}

#createListBtn,
.add-form button,
.import-actions #importBtn {
  background: var(--accent);
  color: var(--accent-contrast);
}

.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 16px;
}
.app-header h1 {
  flex: 1;
}
.header-actions {
  display: flex;
  gap: 8px;
}
.app-header .icon-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

#lastListLink {
  color: var(--accent);
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
.modal-overlay[hidden] {
  display: none;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}
@media (min-width: 520px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.modal-header h2 {
  font-size: 1rem;
  margin: 0;
}
.help-steps {
  font-size: 0.85rem;
  padding-left: 20px;
  margin: 8px 0 16px;
}
.help-steps li {
  margin-bottom: 6px;
}
.prompt-box {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.78rem;
  font-family: ui-monospace, monospace;
  margin: 8px 0 12px;
}
#copyPromptBtn {
  background: var(--accent);
  color: var(--accent-contrast);
  width: 100%;
}

.import-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.import-box summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.import-box .hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 8px 0;
}
.import-box textarea {
  width: 100%;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
}
.import-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.genre-block {
  margin-bottom: 18px;
}
.genre-block h2 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 8px;
  padding-left: 4px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
}

.item-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.item-name {
  overflow-wrap: anywhere;
}
.item-qty {
  color: var(--text-muted);
  white-space: nowrap;
}

.item-row.checked {
  opacity: 0.55;
}
.item-row.checked .item-name,
.item-row.checked .item-qty {
  text-decoration: line-through;
}

.item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.item-actions button {
  background: transparent;
  padding: 4px 6px;
  font-size: 0.9rem;
}

.add-form {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 6px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-width: 480px;
  margin: 0 auto;
}
.add-form input[type="text"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.9rem;
}
#addName { flex: 2; min-width: 0; }
#addQty { flex: 1; min-width: 0; }
.add-form select {
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0.95;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 32px 0;
}
