:root {
  --bg: #f5f4f2;
  --surface: #ffffff;
  --text: #1b1b1f;
  --text-muted: #6b6b70;
  --border: #e3e1dd;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --danger: #b3423e;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #202226;
    --text: #ecebe9;
    --text-muted: #9a9a9e;
    --border: #313338;
    --accent: #4caf7d;
    --accent-text: #0d1310;
    --danger: #e0685f;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.view {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.app-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.app-bar h1 {
  font-size: 1.25rem;
  margin: 0;
  font-weight: 700;
}

.app-bar-spacer {
  flex: 1;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

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

.notes-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 12px 88px;
}

.note-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 8px 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.note-card:hover {
  border-color: var(--accent);
}

.note-title {
  font-weight: 600;
  font-size: 1.02rem;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-preview {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-date {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  margin-top: 20vh;
  padding: 0 24px;
}

.app-version {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.7;
  pointer-events: none;
}

.fab {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1.8rem;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:active {
  transform: scale(0.96);
}

.editor-main {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
}

.editor-textwrap {
  position: relative;
  flex: 1;
}

.editor-highlight,
#editor-textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  border: none;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.5;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
}

.editor-highlight {
  color: var(--text);
  background: var(--bg);
  pointer-events: none;
}

.editor-highlight .pink-easter-egg {
  color: #ff4fa3;
  font-weight: 600;
}

#editor-textarea {
  resize: none;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.dialog {
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.dialog p {
  margin: 0 0 18px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}
