:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --text: #121212;
  --muted: #6b6b6b;
  --line: rgba(18, 18, 18, 0.08);
  --accent: #121212;
  --danger: #b24141;
  --shadow: 0 18px 48px rgba(18, 18, 18, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", system-ui, sans-serif;
  background:
    radial-gradient(circle at top, rgba(18, 18, 18, 0.05), transparent 36%),
    linear-gradient(180deg, #fcfbf8 0%, var(--bg) 100%);
  color: var(--text);
}

body {
  display: flex;
  justify-content: center;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  padding: 16px 14px 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.folder-nav {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.folder-nav::-webkit-scrollbar {
  display: none;
}

.folder-list {
  display: flex;
  gap: 8px;
}

.folder-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.86rem;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.folder-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 1.4rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.icon-btn--ghost {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
}

.search-bar {
  margin-bottom: 12px;
  position: sticky;
  top: 10px;
  z-index: 1;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.search-bar input,
.note-form input,
.note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-solid);
  color: var(--text);
  font: inherit;
  outline: none;
}

.search-bar input {
  padding: 14px 16px;
  font-size: 1rem;
  box-shadow: var(--shadow);
}

.search-bar input:focus,
.note-form input:focus,
.note-form textarea:focus {
  border-color: rgba(18, 18, 18, 0.22);
}

.notes-list {
  display: grid;
  gap: 8px;
}

.note-card {
  display: flex;
  flex-direction: column;
  min-height: 68px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 13px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.note-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.note-card__header .note-title {
  min-width: 0;
}

.view-media {
  display: block;
  width: 100%;
  margin-top: 12px;
  margin-bottom: 14px;
}

.view-media img,
.view-media iframe {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.view-media iframe {
  min-height: 320px;
  background: #fff;
}

.view-content {
  color: #222;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1rem;
}

.view-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  place-items: center;
  padding: 18px;
}

.image-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.zoom-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.note-title {
  font-size: 0.95rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.note-content {
  color: #2f2f2f;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.note-folder {
  margin-top: auto;
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.delete-btn,
.edit-btn {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 5px 8px;
  line-height: 1;
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.folder-picker {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.folder-picker::-webkit-scrollbar {
  display: none;
}

.folder-picker:empty {
  display: none;
}

.folder-picker button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: #f7f6f2;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.folder-picker button.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.edit-btn {
  color: var(--text);
}

.delete-btn {
  color: var(--danger);
}

.delete-btn,
.edit-btn {
  font-size: 0.76rem;
}

.note-card .note-actions {
  gap: 8px;
}

.note-card .note-actions button {
  padding: 6px 9px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.modal {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 720px);
  max-height: calc(100dvh - 16px);
  background: var(--panel-solid);
  border-radius: 20px 20px 0 0;
  padding: 14px 14px 16px;
  box-shadow: 0 -16px 48px rgba(18, 18, 18, 0.14);
  z-index: 20;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

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

.note-form {
  display: grid;
  gap: 12px;
}

.note-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.note-form input,
.note-form textarea {
  padding: 13px 14px;
}

.note-form textarea {
  resize: vertical;
  min-height: 140px;
}

.primary-btn {
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.hidden {
  display: none !important;
}

body.modal-open .search-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
}

body.modal-open .notes-list {
  filter: blur(1px);
}

body.modal-open .topbar {
  opacity: 0.35;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 22px;
  }

  .modal {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    border-radius: 20px;
    width: min(92vw, 540px);
    max-height: min(92dvh, 720px);
    padding: 16px 16px 18px;
  }
}
