@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg: #0c0c0e;
  --surface: #161618;
  --surface-hover: #1e1e21;
  --surface-elevated: #222225;
  --border: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(255, 255, 255, 0.15);
  --accent: #c8a2f8;
  --accent-glow: rgba(200, 162, 248, 0.15);
  --accent-solid: #a47ad4;
  --text: #f0eff1;
  --text-secondary: #8e8c94;
  --text-tertiary: #5c5a63;
  --text-checked: #4a484f;
  --success: #6ee7a0;
  --success-bg: rgba(110, 231, 160, 0.12);
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --transition: cubic-bezier(0.22, 1, 0.36, 1);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 20px;
  overflow: hidden;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  flex-shrink: 0;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  gap: 2px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  transition: background 0.2s var(--transition);
  color: var(--text-secondary);
}

.icon-btn:active {
  background: var(--surface);
  transform: scale(0.95);
}

/* ─── Input ───────────────────────────────────────────────────────────────── */
.input-area {
  position: relative;
  flex-shrink: 0;
  margin-bottom: 16px;
}

.input-wrapper {
  display: flex;
  gap: 10px;
}

#item-input {
  flex: 1;
  padding: 14px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.25s var(--transition), box-shadow 0.25s var(--transition);
}

#item-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#item-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.add-btn {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-solid) 100%);
  color: #0c0c0e;
  border: none;
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s var(--transition), box-shadow 0.15s;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(200, 162, 248, 0.25);
}

.add-btn:active {
  transform: scale(0.92);
  box-shadow: 0 1px 6px rgba(200, 162, 248, 0.15);
}

/* ─── Suggestions ─────────────────────────────────────────────────────────── */
.suggestions {
  position: absolute;
  top: 58px;
  left: 0;
  right: 60px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.suggestions.hidden {
  display: none;
}

.suggestion-item {
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggestion-item:active,
.suggestion-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.suggestion-item .s-emoji {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.suggestion-item .highlight {
  color: var(--accent);
  font-weight: 600;
}

/* ─── List ────────────────────────────────────────────────────────────────── */
.list-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
  mask-image: linear-gradient(to bottom, black calc(100% - 16px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 16px), transparent 100%);
}

.list-item {
  display: flex;
  align-items: center;
  padding: 7px 4px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
  transition: opacity 0.3s var(--transition), background 0.15s;
  user-select: none;
  gap: 10px;
}

.list-item:active {
  background: rgba(255, 255, 255, 0.03);
}

.list-item.checked {
  opacity: 0.4;
}

/* Checkbox */
.item-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--text-tertiary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s var(--transition);
}

.list-item.checked .item-checkbox {
  border-color: var(--success);
  background: var(--success);
}

.item-checkbox::after {
  content: '';
  display: none;
}

.list-item.checked .item-checkbox::after {
  content: '';
  display: block;
  width: 4px;
  height: 8px;
  border: 1.5px solid var(--bg);
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* Item content */
.item-emoji {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.item-text {
  flex: 1;
  font-size: 14px;
  font-weight: 400;
  min-width: 0;
  word-break: break-word;
}

.list-item.checked .item-text {
  text-decoration: line-through;
  color: var(--text-checked);
}

.item-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}

.list-item:hover .item-delete,
.list-item:active .item-delete {
  opacity: 0.6;
}

.item-delete:active {
  opacity: 1;
  color: var(--danger);
}

@media (hover: none) {
  .item-delete {
    opacity: 0.3;
  }
}

/* ─── Divider ─────────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 8px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider.hidden {
  display: none;
}

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-tertiary);
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 64px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 14px;
  font-weight: 450;
  letter-spacing: -0.1px;
}

/* ─── Counter pill ────────────────────────────────────────────────────────── */
.counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
  flex-shrink: 0;
}

.counter .done {
  color: var(--success);
}

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.2s ease;
}

.modal.hidden {
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-up 0.3s var(--transition);
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.history-list {
  overflow-y: auto;
  flex: 1;
}

.history-entry {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.history-date {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.history-items {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.history-empty {
  text-align: center;
  color: var(--text-tertiary);
  padding: 48px 0;
  font-size: 14px;
}

.history-entry-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.restore-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.2px;
}

.restore-btn:active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
}

/* ─── Animations ──────────────────────────────────────────────────────────── */

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
.list-container::-webkit-scrollbar,
.history-list::-webkit-scrollbar,
.suggestions::-webkit-scrollbar {
  width: 3px;
}

.list-container::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track,
.suggestions::-webkit-scrollbar-track {
  background: transparent;
}

.list-container::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb,
.suggestions::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}
