/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   SimpleNote — Style (ColorNote dark)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

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

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

:root {
  --bg:          #1a1a1a;
  --surface:     #242424;
  --surface2:    #2e2e2e;
  --border:      #383838;
  --text:        #f0f0f0;
  --text-muted:  #888;
  --accent:      #ffca28;
  --danger:      #e53935;
  --radius:      12px;
  --font:        'Inter', sans-serif;
  --shadow:      0 4px 20px rgba(0,0,0,.4);
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Auth ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #1a1a1a 0%, #111 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon {
  font-size: 52px;
  display: block;
  margin-bottom: 8px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

.auth-tab.active {
  background: var(--accent);
  color: #111;
  font-weight: 700;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}

.field input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: #111;
  width: 100%;
  margin-top: 8px;
  font-size: 16px;
  padding: 14px;
}

.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:active { transform: scale(.98); }

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

.btn-ghost:hover { background: var(--border); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  transition: all .15s;
}

.btn-icon:hover { background: var(--surface2); color: var(--text); }

.error-msg {
  background: rgba(229,57,53,.15);
  border: 1px solid rgba(229,57,53,.4);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: #ef9a9a;
  margin-top: 12px;
  display: none;
}

/* ── Main App ── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: max(env(safe-area-inset-top, 0px), 0px) 16px 0;
  min-height: calc(60px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-bar-logo span { font-size: 26px; }

.search-wrap {
  flex: 1;
  max-width: 340px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 36px 8px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

.search-wrap input:focus { border-color: var(--accent); }

.search-wrap .search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

/* ── Notes Grid ── */
.notes-area {
  padding: 20px 16px;
  flex: 1;
}

.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px 4px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.note-card {
  border-radius: var(--radius);
  padding: 14px 12px;
  cursor: pointer;
  position: relative;
  min-height: 110px;
  transition: transform .15s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

.note-card:active { transform: scale(.98); }

.note-card .note-type-badge {
  font-size: 14px;
  margin-bottom: 6px;
}

.note-card .note-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(0,0,0,.85);
  line-height: 1.3;
  margin-bottom: 6px;
  word-break: break-word;
}

.note-card .note-preview {
  font-size: 12px;
  color: rgba(0,0,0,.6);
  line-height: 1.5;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.note-card .note-date {
  font-size: 11px;
  color: rgba(0,0,0,.45);
  margin-top: 8px;
}

.notes-list .note-card {
  min-height: auto;
  padding: 10px 14px;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.notes-list .note-title {
  margin-bottom: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-list .note-preview {
  display: none;
}

.notes-list .note-date {
  margin-top: 0;
  position: static;
  white-space: nowrap;
}

.note-card .pin-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 14px;
  opacity: .7;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 64px; display: block; margin-bottom: 16px; }
.empty-state p { font-size: 16px; }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 28px;
  right: 24px;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 50%;
  width: 58px;
  height: 58px;
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255,202,40,.35);
  transition: all .2s;
  z-index: 200;
}

.fab:hover { transform: scale(1.08); }
.fab:active { transform: scale(.95); }

/* ── Modal ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 18px;
  width: 100%;
  max-width: 540px;
  margin: auto;
  border: 1px solid var(--border);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.modal-body { padding: 20px; }

.modal-footer {
  padding: 12px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

/* ── Note Editor ── */
.note-color-strip {
  height: 6px;
  width: 100%;
}

.note-editor-title {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  outline: none;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.note-editor-content {
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  resize: none;
  min-height: 200px;
  line-height: 1.7;
}

/* ── Checklist ── */
.checklist-items { list-style: none; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.checklist-item:last-child { border-bottom: none; }

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

.checklist-item .item-text {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
}

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

.checklist-item .del-item {
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .15s;
}

.checklist-item .del-item:hover { background: var(--surface2); color: var(--danger); }

.add-item-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 0;
  transition: color .15s;
}

.add-item-btn:hover { color: var(--accent); }

/* ── Color Picker ── */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 4px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform .15s, border-color .15s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: white; }

/* ── Type Toggle ── */
.type-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.type-btn {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.type-btn.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 700;
}

/* ── Share modal ── */
.share-link-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  word-break: break-all;
  color: var(--text-muted);
  margin: 12px 0;
}

.qr-wrap { text-align: center; margin: 12px 0; }
.qr-wrap img { border-radius: 10px; }

/* ── Menu ── */
.user-menu-wrap { position: relative; }

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 180px;
  box-shadow: var(--shadow);
  z-index: 999;
  overflow: hidden;
  display: none;
}

.user-menu.open { display: block; }

.user-menu a, .user-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-family: var(--font);
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  transition: background .12s;
}

.user-menu a:hover, .user-menu button:hover { background: var(--surface2); }
.user-menu .danger { color: #ef9a9a; }

/* ── Shared view ── */
.shared-wrap {
  max-width: 600px;
  margin: 40px auto;
  padding: 0 16px;
}

.shared-card {
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn .25s ease;
  white-space: nowrap;
}

.toast.success { background: #1b5e20; border-color: #2e7d32; }
.toast.error   { background: #b71c1c; border-color: #c62828; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .notes-grid { grid-template-columns: repeat(2, 1fr); }
  .search-wrap { max-width: 160px; }
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 380px) {
  .notes-grid { grid-template-columns: 1fr; }
}
