:root {
  --bg: #eef1f5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #222;
}

#canvas {
  min-height: 100vh;
  padding-bottom: 140px;
  background-image: radial-gradient(circle, #dfe3e8 1px, transparent 1px);
  background-size: 24px 24px;
}

#input-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 24px 16px 16px;
  background: linear-gradient(var(--bg) 70%, rgba(238,241,245,0));
}

#thought-input {
  width: min(600px, 90vw);
  max-height: 240px;
  resize: none;
  border: none;
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 16px;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  background: #fff;
  outline: none;
  font-family: inherit;
}

#notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 20px;
  max-width: 1400px;
  margin: 16px auto 0;
  padding: 0 32px;
}

.sticky-note {
  position: relative;
  height: 190px;
  padding: 16px;
  border-radius: 4px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
}

.sticky-note:hover {
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px) scale(1.02) !important;
}

.note-text {
  font-size: 14px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  word-break: break-word;
  white-space: pre-wrap;
}

.indicator {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
}

.indicator.pending {
  background: #bdbdbd;
  animation: pulse 1s infinite ease-in-out;
}

.indicator.synced {
  background: #4caf50;
}

.indicator.error {
  background: #e53935;
  cursor: pointer;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#modal-overlay.hidden {
  display: none;
}

#modal {
  width: min(520px, 92vw);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  outline: none;
}

#modal-textarea {
  width: 100%;
  min-height: 160px;
  max-height: 60vh;
  overflow-y: auto;
  resize: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 12px;
  font-size: 16px;
  line-height: 1.5;
  font-family: inherit;
  background: transparent;
  color: inherit;
}

/* Only looks/behaves like an input once editing is active (space bar toggles this). */
#modal-textarea:not([readonly]) {
  border-color: rgba(0, 0, 0, 0.25);
  background: rgba(255, 255, 255, 0.55);
  cursor: text;
}

#modal-textarea[readonly] {
  cursor: default;
}

#modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

#modal-confirm {
  display: none;
  border: none;
  background: #4caf50;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

#modal.editing #modal-confirm {
  display: inline-flex;
}

#modal-confirm:hover {
  background: #43a047;
}

#modal-nav-hint {
  font-size: 12px;
  color: #888;
  text-align: center;
}

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  min-width: 180px;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  color: #fff;
  background: #555;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.pending {
  background: #5f6368;
}

.toast.success {
  background: #2e7d32;
}

.toast.error {
  background: #c62828;
}
