:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #141414;
  color: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #141414;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  --background: #141414;
  --surface: rgba(31, 31, 31, 0.94);
  --surface-strong: #1f1f1f;
  --text: #ffffff;
  --muted: #d7dde7;
  --border: rgba(255, 255, 255, 0.18);
  --primary: #00aba9;
  --primary-text: #ffffff;
  --tile-radius: 0;
  min-height: 100vh;
  padding: 18px;
  background: var(--background);
  color: var(--text);
}

.app-shell[data-theme="light"] {
  --background: #fefcf8;
  --surface: rgba(255, 251, 242, 0.96);
  --surface-strong: #fff7e8;
  --text: #111827;
  --muted: #374151;
  --border: rgba(17, 24, 39, 0.16);
  --primary: #2563eb;
  --primary-text: #ffffff;
  --tile-radius: 8px;
}

.app-shell[data-theme="dark"] {
  --background: #0e1117;
  --surface: rgba(24, 26, 32, 0.96);
  --surface-strong: #252a34;
  --text: #e8eaed;
  --muted: #c4cad6;
  --border: rgba(255, 255, 255, 0.16);
  --primary: #83a9ff;
  --primary-text: #092968;
  --tile-radius: 8px;
}

.app-shell[data-theme="color"] {
  background:
    linear-gradient(90deg, rgba(0, 171, 169, 0.15) 0 24%, transparent 24% 100%),
    linear-gradient(180deg, transparent 0 62%, rgba(240, 150, 9, 0.16) 62% 84%, transparent 84%),
    #141414;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p,
.panel-heading p,
.download-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  border-radius: 8px;
}

.theme-switch button,
.panel-heading button,
.folder-row,
.primary-button,
.download-button,
.download-card a {
  border: 0;
  cursor: pointer;
}

.theme-switch button {
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.theme-switch button.active {
  background: var(--primary);
  color: var(--primary-text);
}

.download-button,
.download-card a,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  color: #ffffff;
  background: #d80073;
  text-decoration: none;
  font-weight: 800;
  border-radius: var(--tile-radius);
}

.search-row,
.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

.search-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--tile-radius);
}

.search-box span {
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.workspace {
  display: grid;
  grid-template-columns: 230px minmax(360px, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--tile-radius);
  padding: 14px;
}

.panel-title {
  font-size: 16px;
  font-weight: 850;
}

.folder-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 11px 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
  border-radius: var(--tile-radius);
}

.folder-row.selected {
  background: var(--primary);
  color: var(--primary-text);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.blue { background: #2563eb; }
.teal { background: #00aba9; }
.magenta { background: #d80073; }
.lime { background: #8cbf26; }
.orange { background: #f09609; }

.download-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.download-card img {
  width: 48px;
  height: 48px;
}

.download-card h2 {
  margin: 0;
  font-size: 15px;
}

.download-card a {
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 6px;
  background: #2563eb;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--tile-radius);
  font-weight: 800;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.note-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 154px;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
  border-radius: var(--tile-radius);
  cursor: pointer;
}

.app-shell[data-theme="color"] .note-card {
  border: 0;
  color: #ffffff;
}

.note-card.active {
  outline: 3px solid var(--primary);
  outline-offset: 0;
}

.note-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: currentColor;
  opacity: 0.78;
}

.note-card-title {
  font-weight: 850;
  font-size: 16px;
  line-height: 1.25;
}

.note-card-body {
  color: currentColor;
  opacity: 0.76;
  line-height: 1.45;
  font-size: 14px;
}

.editor-form {
  display: grid;
  gap: 10px;
}

.title-input,
.folder-input,
.body-input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--text);
  border-radius: var(--tile-radius);
  outline: 0;
}

.title-input {
  padding: 14px;
  font-weight: 850;
  font-size: 21px;
}

.folder-input {
  min-height: 42px;
  padding: 0 12px;
}

.body-input {
  min-height: 230px;
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

.sketch-pad {
  position: relative;
  overflow: hidden;
  height: 82px;
  margin-top: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-strong) 70%, transparent);
  border-radius: var(--tile-radius);
}

.ink-line {
  position: absolute;
  left: 12%;
  top: 56%;
  width: 76%;
  height: 8px;
  background: var(--primary);
  transform: rotate(-14deg);
  opacity: 0.85;
}

.ink-circle {
  position: absolute;
  left: 24%;
  top: 18%;
  width: 42px;
  height: 42px;
  border: 8px solid var(--primary);
  border-radius: 50%;
  opacity: 0.28;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .editor-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions,
  .brand {
    justify-content: space-between;
  }

  .workspace,
  .notes-grid {
    grid-template-columns: 1fr;
  }

  .folders-panel {
    order: 2;
  }
}
