:root {
  --bg: #fffaf5;
  --surface: #ffffff;
  --primary: #f97316;
  --primary-light: #fff7ed;
  --primary-dark: #ea580c;
  --text: #292524;
  --text-sub: #78716c;
  --border: #e7e5e4;
  --danger: #ef4444;
  --success: #22c55e;
  --cat-place: #3b82f6;
  --cat-food: #ef4444;
  --cat-activity: #8b5cf6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* Auth / Nickname screens */
.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
}

.card-center {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  text-align: center;
  width: 100%;
  max-width: 360px;
}

.logo { width: 120px; height: 120px; margin-bottom: .5rem; }
.app-title { font-size: 1.75rem; font-weight: 700; margin-bottom: .25rem; }
.subtitle { color: var(--text-sub); margin-bottom: 1.5rem; font-size: .95rem; }

.form { display: flex; flex-direction: column; gap: .75rem; }
.form input[type="text"],
.form input[type="password"],
.form input[type="url"],
.form textarea {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
  background: var(--surface);
  font-family: inherit;
}
.form input:focus, .form textarea:focus {
  border-color: var(--primary);
}
.form label {
  text-align: left;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-sub);
}

.error { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin-top: .5rem; }

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: .75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.98); }

.btn {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  padding: .5rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: #f5f5f4; }

.btn-done {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
  padding: .4rem .75rem;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.btn-done:hover { background: var(--primary); color: #fff; }

.btn-sm {
  background: none;
  border: 1px solid var(--border);
  padding: .35rem .6rem;
  border-radius: 6px;
  font-size: .8rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-sm:hover { background: #f5f5f4; }
.btn-sm.btn-danger:hover { background: #fef2f2; color: var(--danger); border-color: var(--danger); }

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-title { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: .35rem; }
.header-icon { width: 28px; height: 28px; }
.header-user {
  font-size: .85rem;
  color: var(--text-sub);
  background: var(--primary-light);
  padding: .25rem .75rem;
  border-radius: 20px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
}
.tab {
  flex: 1;
  padding: .75rem;
  border: none;
  background: none;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all .15s;
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab:hover:not(.active) { color: var(--text); }

/* Filters */
.filters {
  display: flex;
  gap: .5rem;
  padding: .75rem 1rem;
}
.filters select {
  flex: 1;
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
  font-family: inherit;
}
.filters select:focus { border-color: var(--primary); }

/* Item list */
.items {
  padding: .75rem 1rem;
  padding-bottom: 5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Card */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  transition: transform .1s;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .5rem;
}
.cat-badge { font-size: 1.1rem; }
.desire { font-size: .9rem; letter-spacing: 2px; }

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: .5rem;
  line-height: 1.4;
}

.card-link {
  display: inline-block;
  font-size: .8rem;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: .5rem;
}
.card-link:hover { text-decoration: underline; }

.card-memo {
  font-size: .85rem;
  color: var(--text-sub);
  background: var(--primary-light);
  padding: .5rem .75rem;
  border-radius: 8px;
  margin-bottom: .5rem;
  line-height: 1.5;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: .8rem;
  color: var(--text-sub);
  margin-bottom: .5rem;
}
.card-dates {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .1rem;
}

.card-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-sub);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .6; }
.empty-state p { line-height: 1.6; }

/* FAB */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(249,115,22,.4);
  transition: all .15s;
  z-index: 5;
}
.fab:hover { transform: scale(1.1); background: var(--primary-dark); }
.fab:active { transform: scale(.95); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 50;
  opacity: 1;
  transition: opacity .2s;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem;
  z-index: 51;
  max-height: 90dvh;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform .25s ease;
}
.modal.hidden { transform: translateY(100%); pointer-events: none; }
.modal h2 { font-size: 1.2rem; margin-bottom: 1rem; }

.modal-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

/* Category select */
.cat-select {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.cat-option {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}
.cat-option input[type="radio"] { display: none; }
.cat-option span {
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  transition: all .15s;
  width: 100%;
}
.cat-option input:checked + span {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

/* Desire select */
.desire-select {
  display: flex;
  gap: .75rem;
}
.desire-option {
  cursor: pointer;
  flex: 1;
  text-align: center;
}
.desire-option input[type="radio"] { display: none; }
.desire-option span {
  display: block;
  padding: .5rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  transition: all .15s;
}
.desire-option input:checked + span {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Celebration */
.celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}
.celebration.hidden { display: none; }
.confetti {
  position: absolute;
  font-size: 1.8rem;
  animation: confetti-fall 1.5s ease-in forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(-40px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100dvh) rotate(720deg); opacity: 0; }
}

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-sub);
}

/* Confirm dialog */
.confirm-text {
  font-size: .95rem;
  line-height: 1.6;
  margin-bottom: .5rem;
}

/* Responsive */
@media (min-width: 640px) {
  .items { max-width: 520px; margin: 0 auto; }
  header, .tabs, .filters { max-width: 520px; margin-left: auto; margin-right: auto; }
  .modal { left: 50%; right: auto; transform: translateX(-50%); max-width: 480px; border-radius: var(--radius); bottom: auto; top: 50%; }
  .modal:not(.hidden) { transform: translate(-50%, -50%); }
  .modal.hidden { transform: translate(-50%, 100dvh); }
}
