:root {
  color-scheme: dark;
  --bg: #0f1220;
  --bg-elevated: #161a2c;
  --panel: #1b2034;
  --panel-soft: #232942;
  --text: #edf1ff;
  --muted: #97a0c3;
  --line: rgba(153, 170, 255, 0.14);
  --accent: #4f8cff;
  --accent-strong: #6f6cff;
  --accent-soft: rgba(97, 118, 255, 0.18);
  --danger: #ff6b88;
  --danger-soft: rgba(255, 107, 136, 0.16);
  --shadow: 0 20px 48px rgba(4, 8, 20, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(92, 108, 255, 0.22), transparent 30%),
    radial-gradient(circle at top right, rgba(79, 140, 255, 0.16), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
[contenteditable] {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--line);
  background: rgba(14, 18, 31, 0.92);
  backdrop-filter: blur(18px);
  padding: 20px 18px;
}

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

.note-search {
  width: 100%;
  min-height: 42px;
  margin-bottom: 14px;
  border: 1px solid rgba(126, 140, 208, 0.16);
  border-radius: 12px;
  background: rgba(28, 34, 56, 0.96);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.note-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.icon-button {
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(79, 140, 255, 0.28);
}

.calculator-card {
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid rgba(134, 149, 255, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, #15182a 0%, #101320 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.calculator-mode {
  display: flex;
  gap: 4px;
  padding: 12px 14px 0;
  color: #8d95b7;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.calculator-mode span:first-child {
  color: #fff;
  border-bottom: 2px solid var(--accent);
}

.calculator-display {
  width: 100%;
  height: 72px;
  border: 0;
  background: transparent;
  color: #eef2ff;
  font-size: 42px;
  text-align: right;
  padding: 6px 16px 12px;
  outline: none;
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid rgba(134, 149, 255, 0.14);
}

.calculator-key {
  min-width: 0;
  height: 48px;
  border: 0;
  border-right: 1px solid rgba(134, 149, 255, 0.12);
  border-bottom: 1px solid rgba(134, 149, 255, 0.12);
  background: #171b2d;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

.calculator-key:nth-child(4n) {
  border-right: 0;
}

.calculator-key:hover {
  background: #202642;
}

.calculator-key.utility {
  background: #2b3150;
}

.calculator-key.operator,
.calculator-key.equals {
  background: linear-gradient(180deg, #5d84ff 0%, #7a5cff 100%);
}

.calculator-key.operator:hover,
.calculator-key.equals:hover {
  filter: brightness(1.08);
}

.notes-list {
  display: grid;
  gap: 12px;
  overflow-x: hidden;
}

.note-item {
  position: relative;
  width: 100%;
  min-height: 74px;
  border: 1px solid rgba(122, 132, 190, 0.18);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(38, 45, 72, 0.92), rgba(27, 33, 54, 0.98));
  color: var(--text);
  text-align: left;
  padding: 14px 14px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  overflow: visible;
}

.note-item::before,
.note-item::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 10px;
  border-radius: 10px 10px 6px 6px;
  background: rgba(96, 109, 168, 0.22);
  z-index: -1;
}

.note-item::before {
  top: -6px;
}

.note-item::after {
  top: -11px;
  left: 18px;
  right: 18px;
  opacity: 0.6;
}

.note-item:hover,
.note-item.active {
  border-color: rgba(108, 126, 255, 0.4);
  background: linear-gradient(180deg, rgba(55, 65, 104, 0.96), rgba(34, 40, 66, 1));
  transform: translateY(-1px);
}

.note-item.active {
  box-shadow:
    0 16px 36px rgba(15, 22, 48, 0.44),
    0 0 0 1px rgba(104, 123, 255, 0.25) inset;
}

.note-title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 700;
  padding-left: 26px;
  position: relative;
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-title::before {
  content: "🗂";
  position: absolute;
  left: 0;
  top: 0;
  font-size: 16px;
}

.note-date {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.note-pin {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: #b8c5ff;
  font-size: 11px;
  font-weight: 700;
}

.notes-empty,
.sidebar-footnote {
  padding: 14px;
  border: 1px dashed rgba(126, 140, 208, 0.2);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(22, 28, 46, 0.65);
}

.sidebar-footnote {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.45;
}

.sidebar-footnote p {
  margin: 0 0 6px;
}

.sidebar-footnote p:last-child {
  margin-bottom: 0;
}

.footnote-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
}

.footnote-links a {
  color: #b8c5ff;
  text-decoration: none;
}

.footnote-links a:hover {
  text-decoration: underline;
}

.editor-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 24px;
}

.landing-card,
.seo-copy {
  border: 1px solid rgba(126, 140, 208, 0.16);
  border-radius: 18px;
  background: rgba(22, 28, 46, 0.78);
  box-shadow: var(--shadow);
}

.landing-card {
  padding: 18px 20px;
}

.landing-eyebrow {
  margin: 0 0 8px;
  color: #9fb7ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.landing-card h2,
.seo-copy h2,
.seo-copy h3 {
  margin: 0;
}

.landing-card h2 {
  font-size: 24px;
  line-height: 1.2;
}

.landing-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.landing-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.landing-points span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(126, 140, 208, 0.16);
  border-radius: 999px;
  background: rgba(30, 36, 60, 0.92);
  color: #dfe6ff;
  font-size: 14px;
}

.editor-controls {
  position: sticky;
  top: 0;
  z-index: 25;
  display: grid;
  gap: 14px;
  margin: -24px -24px 0;
  padding: 24px 24px 10px;
  background: linear-gradient(180deg, rgba(15, 18, 32, 0.98) 0%, rgba(15, 18, 32, 0.92) 86%, rgba(15, 18, 32, 0) 100%);
  backdrop-filter: blur(18px);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto auto auto;
  gap: 10px;
  align-items: center;
}

.title-input,
.rich-editor {
  width: 100%;
  border: 1px solid rgba(126, 140, 208, 0.18);
  border-radius: 14px;
  background: rgba(25, 31, 52, 0.96);
  color: var(--text);
  outline: none;
}

.title-input:focus,
.rich-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.title-input {
  min-height: 46px;
  padding: 0 16px;
  font-size: 20px;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.rich-editor {
  min-height: 520px;
  overflow: auto;
  padding: 20px;
  line-height: 1.55;
  box-shadow: var(--shadow);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.format-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.format-button {
  min-width: 40px;
  height: 40px;
  border: 1px solid rgba(126, 140, 208, 0.16);
  border-radius: 12px;
  background: rgba(29, 35, 58, 0.95);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.format-button:hover {
  border-color: var(--accent);
  color: #fff;
  background: rgba(79, 140, 255, 0.18);
}

.format-button.active {
  border-color: rgba(111, 108, 255, 0.45);
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.26), rgba(111, 108, 255, 0.26));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(111, 108, 255, 0.18);
}

.media-block {
  position: relative;
  display: block;
  width: min(620px, 100%);
  margin: 14px 0;
  border: 1px solid rgba(126, 140, 208, 0.14);
  border-radius: 14px;
  background: rgba(28, 34, 56, 0.96);
  padding: 12px;
}

.media-block img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
}

.media-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: rgba(15, 20, 34, 0.88);
  color: #fff;
  cursor: pointer;
}

.media-caption {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.after-media-line {
  min-height: 24px;
  margin: 6px 0 12px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow);
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.primary-button:hover {
  filter: brightness(1.06);
}

.secondary-button {
  border: 1px solid rgba(126, 140, 208, 0.16);
  background: rgba(28, 34, 56, 0.96);
  color: var(--text);
}

.secondary-button:hover {
  border-color: rgba(94, 122, 255, 0.38);
  background: rgba(44, 52, 82, 0.98);
}

.delete-button {
  color: var(--danger);
  background: rgba(45, 25, 41, 0.92);
  border-color: rgba(255, 107, 136, 0.2);
}

.delete-button:hover {
  background: rgba(71, 28, 55, 0.96);
}

.button-label {
  display: inline-block;
}

.button-icon {
  font-size: 16px;
  line-height: 1;
}

.tool-button {
  width: 42px;
  padding: 0;
}

.tool-button.active {
  border-color: rgba(111, 108, 255, 0.45);
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.26), rgba(111, 108, 255, 0.26));
  color: #fff;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.seo-copy {
  padding: 20px;
  line-height: 1.7;
}

.seo-copy h2 {
  margin-bottom: 10px;
  font-size: 22px;
}

.seo-copy h3 {
  margin-top: 18px;
  margin-bottom: 8px;
  font-size: 18px;
}

.seo-copy p {
  margin: 0;
  color: var(--muted);
}

.seo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 18px;
}

.seo-links a {
  color: #b8c5ff;
  text-decoration: none;
}

.seo-links a:hover {
  text-decoration: underline;
}

.save-state {
  color: #b8c5ff;
  font-weight: 700;
}

.save-state[data-state="dirty"] {
  color: #ffd36b;
}

.save-state[data-state="saving"] {
  color: #9fb7ff;
}

.save-state[data-state="saved"] {
  color: #7ee2ae;
}

.save-state[data-state="error"] {
  color: #ff9ab0;
}

.hidden-file {
  display: none;
}

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

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .editor-controls {
    position: static;
    margin: 0;
    padding: 0;
    background: transparent;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .title-input {
    grid-column: 1 / -1;
  }

  .button-label {
    display: none;
  }
}
