:root {
  --ink: #1f2523;
  --muted: #65736f;
  --line: #d5ded9;
  --surface: #fbfcfa;
  --panel: #eef4f1;
  --accent: #2f7d68;
  --accent-strong: #205d4c;
  --accent-soft: #dbece6;
  --danger: #b73535;
  --danger-bg: #f8e6e1;
  --focus: #1d6fa5;
  --shadow: 0 18px 48px rgba(23, 42, 38, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(31, 37, 35, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 37, 35, 0.045) 1px, transparent 1px),
    #dfe7e4;
  background-size: 28px 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
select {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  width: min(1180px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(39, 74, 66, 0.16);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 22px 16px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  font-size: 28px;
  line-height: 1;
}

.icon-button:hover {
  background: var(--accent-strong);
}

.search-wrap {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  margin: 0 22px;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(251, 252, 250, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.note-stats {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px 10px;
  color: var(--muted);
  font-size: 13px;
}

.note-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding: 0 14px 18px;
}

.note-item {
  display: grid;
  width: 100%;
  grid-template-rows: auto auto auto auto;
  gap: 5px;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

.note-item:hover {
  background: rgba(251, 252, 250, 0.72);
}

.note-item.is-active {
  background: var(--surface);
  border-color: rgba(47, 125, 104, 0.34);
}

.note-item-title {
  overflow: hidden;
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item-preview {
  display: -webkit-box;
  min-height: 37px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-item-tags {
  min-height: 18px;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item-tags:empty {
  display: none;
}

.note-item-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.empty-list {
  margin: 8px;
  color: var(--muted);
  font-size: 14px;
}

.editor {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto auto auto 1fr;
  background:
    linear-gradient(90deg, transparent 0 54px, rgba(183, 53, 53, 0.14) 54px 55px, transparent 55px),
    repeating-linear-gradient(#fbfcfa 0 38px, #dfe8e3 39px 40px);
}

.editor-toolbar,
.writing-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(251, 252, 250, 0.95);
  border-bottom: 1px solid var(--line);
}

.editor-toolbar {
  min-height: 64px;
  padding: 14px 24px;
}

.writing-tools {
  min-height: 54px;
  padding: 9px 24px;
}

.current-meta,
.toolbar-actions,
.tool-group,
.template-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.current-meta {
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.tool-button,
.danger-button,
.format-button,
.template-wrap select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.tool-button,
.danger-button {
  padding: 0 14px;
}

.tool-button,
.format-button,
.template-wrap select {
  color: var(--accent-strong);
  background: #fff;
}

.tool-button.is-active,
.format-button:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.danger-button {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(183, 53, 53, 0.22);
}

.format-button {
  min-width: 38px;
  padding: 0 10px;
}

.template-wrap {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.template-wrap select {
  min-width: 128px;
  padding: 0 34px 0 12px;
}

.title-input,
.content-input,
.tag-wrap input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.title-input {
  padding: 28px 36px 10px 76px;
  font-size: 34px;
  font-weight: 850;
  line-height: 1.18;
}

.tag-wrap {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  margin: 0 36px 4px 76px;
  padding: 8px 0 12px;
  color: var(--accent-strong);
  border-bottom: 1px solid rgba(47, 125, 104, 0.18);
  font-size: 14px;
  font-weight: 800;
}

.tag-wrap input {
  color: var(--muted);
  font-weight: 700;
}

.content-input {
  min-height: 0;
  resize: none;
  padding: 13px 36px 40px 76px;
  font-size: 18px;
  line-height: 40px;
}

.title-input::placeholder,
.content-input::placeholder,
.tag-wrap input::placeholder {
  color: rgba(101, 115, 111, 0.72);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 3px solid rgba(29, 111, 165, 0.35);
  outline-offset: 2px;
}

.app-shell.is-focus-mode {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-shell.is-focus-mode .sidebar {
  overflow: hidden;
  border-right: 0;
}

@media (max-width: 860px) {
  .editor-toolbar,
  .writing-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions,
  .tool-group,
  .template-wrap {
    width: 100%;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tool-group {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .template-wrap select {
    flex: 1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(230px, 34vh) 1fr;
    width: 100vw;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .app-shell.is-focus-mode {
    grid-template-columns: 1fr;
    grid-template-rows: 0 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-header {
    padding: 18px 16px 12px;
  }

  .search-wrap {
    margin: 0 16px;
  }

  .note-stats {
    padding: 12px 16px 8px;
  }

  .note-list {
    padding: 0 10px 14px;
  }

  .editor-toolbar,
  .writing-tools {
    padding: 12px 16px;
  }

  .toolbar-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-group {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tool-button,
  .danger-button {
    padding: 0 10px;
  }

  .title-input {
    padding: 20px 20px 8px 34px;
    font-size: 28px;
  }

  .tag-wrap {
    margin: 0 20px 4px 34px;
  }

  .content-input {
    padding: 11px 20px 32px 34px;
    font-size: 17px;
  }

  .editor {
    background:
      linear-gradient(90deg, transparent 0 22px, rgba(183, 53, 53, 0.14) 22px 23px, transparent 23px),
      repeating-linear-gradient(#fbfcfa 0 38px, #dfe8e3 39px 40px);
  }
}


.editor {
  grid-template-rows: auto auto auto auto auto minmax(220px, 1fr);
}

.writing-tools {
  align-items: stretch;
  flex-wrap: wrap;
}

.writing-tool-stack,
.image-tool-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.writing-tool-stack {
  flex: 1 1 560px;
  flex-wrap: wrap;
}

.image-tool-group {
  flex-wrap: wrap;
}

.image-tool-group .template-wrap select {
  min-width: 118px;
}

.image-board[hidden] {
  display: none;
}

.image-board {
  display: flex;
  min-height: 0;
  max-height: min(44vh, 430px);
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 14px 36px 12px 76px;
  background: rgba(251, 252, 250, 0.78);
  border-bottom: 1px solid rgba(47, 125, 104, 0.16);
}

.image-block {
  display: grid;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(47, 125, 104, 0.22);
  border-radius: 8px;
}

.image-block-toolbar,
.image-block-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.image-block-toolbar {
  justify-content: space-between;
}

.image-block-title {
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-block-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.image-control-select,
.image-action-button {
  min-height: 32px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.image-control-select {
  max-width: 116px;
  padding: 0 26px 0 10px;
}

.image-action-button {
  display: grid;
  width: 32px;
  place-items: center;
  padding: 0;
}

.image-action-button:hover:not(:disabled) {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.image-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.image-block-body {
  display: grid;
  gap: 12px;
}

.image-block--side .image-block-body {
  grid-template-columns: minmax(190px, 38%) minmax(0, 1fr);
  align-items: stretch;
}

.image-media {
  overflow: hidden;
  background: #e6ece9;
  border-radius: 8px;
}

.image-media img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

.image-block--cover .image-media {
  aspect-ratio: 16 / 5;
}

.image-block--cover .image-media img,
.image-block--side .image-media img,
.image-grid-item img {
  width: 100%;
  height: 100%;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  padding: 8px;
}

.image-grid-item {
  aspect-ratio: 4 / 3;
  margin: 0;
  overflow: hidden;
  border-radius: 7px;
}

.image-text-panel {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.image-caption-input,
.image-note-input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: rgba(251, 252, 250, 0.86);
  border: 1px solid rgba(101, 115, 111, 0.24);
  border-radius: 8px;
  outline: 0;
}

.image-caption-input {
  min-height: 38px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 850;
}

.image-note-input {
  min-height: 84px;
  resize: vertical;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.55;
}

.image-caption-input::placeholder,
.image-note-input::placeholder {
  color: rgba(101, 115, 111, 0.72);
}

.image-style--paper {
  background: #fffdf6;
  border-color: #d8c990;
}

.image-style--paper .image-media {
  padding: 8px;
  background: #f6ecd0;
}

.image-style--marker {
  background: #f7fbff;
  border-left: 5px solid #e4a126;
}

.image-style--marker .image-caption-input {
  border-color: rgba(228, 161, 38, 0.38);
}

.image-style--shadow {
  background: #ffffff;
  border-color: #c5d0df;
  box-shadow: 0 12px 28px rgba(34, 54, 76, 0.14);
}

.content-input {
  min-height: 220px;
}

@media (max-width: 860px) {
  .writing-tool-stack,
  .image-tool-group {
    width: 100%;
  }

  .image-tool-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .image-tool-group .template-wrap,
  .image-tool-group .tool-button {
    width: 100%;
  }

  .image-tool-group .template-wrap select {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .image-board {
    max-height: 46vh;
    padding: 10px 20px 12px 34px;
  }

  .image-block-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .image-block-controls {
    justify-content: stretch;
  }

  .image-control-select {
    max-width: none;
    flex: 1 1 110px;
  }

  .image-block--side .image-block-body {
    grid-template-columns: 1fr;
  }

  .image-tool-group {
    grid-template-columns: 1fr;
  }
}


/* Public site structure */
.skip-link {
  position: absolute;
  left: 16px;
  top: 10px;
  z-index: 30;
  padding: 10px 14px;
  color: #fff;
  background: #1f2523;
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 10px max(18px, calc((100vw - 1180px) / 2));
  background: rgba(251, 252, 250, 0.96);
  border-bottom: 1px solid rgba(39, 74, 66, 0.16);
  backdrop-filter: blur(14px);
}

.site-brand {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
}

.site-nav,
.site-footer nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.site-nav {
  justify-content: flex-end;
  overflow-x: auto;
}

.site-nav a,
.site-footer a,
.guide-card a,
.text-button {
  color: var(--accent-strong);
  font-weight: 850;
  text-decoration: none;
}

.site-nav a {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--accent-soft);
}

.app-shell {
  min-height: calc(100vh - 96px);
  scroll-margin-top: 82px;
}

.site-content {
  display: grid;
  gap: 0;
}

.content-band {
  padding: 58px max(18px, calc((100vw - 1180px) / 2));
  background: #fbfcfa;
  border-top: 1px solid rgba(39, 74, 66, 0.12);
}

.content-band:nth-child(even) {
  background: #f3f7f4;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 1.08fr);
  align-items: center;
  gap: 34px;
}

.section-kicker {
  margin: 0 0 8px;
  color: #805700;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.content-band h2,
.article-content h1,
.article-content h2 {
  color: var(--ink);
  letter-spacing: 0;
}

.content-band h2 {
  max-width: 760px;
  margin: 0 0 16px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.12;
}

.content-band p,
.article-content p {
  color: #3e4b47;
}

.content-band p {
  max-width: 760px;
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.75;
}

.feature-image {
  margin: 0;
}

.feature-image img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid rgba(39, 74, 66, 0.16);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(23, 42, 38, 0.14);
}

.feature-image figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.section-heading {
  max-width: 820px;
  margin-bottom: 26px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.guide-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 210px;
  padding: 22px;
  background: #fff;
  border: 1px solid rgba(39, 74, 66, 0.16);
  border-radius: 8px;
}

.guide-card h3,
.principle-list h3,
.contact-panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.guide-card p {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
}

.guide-card a {
  align-self: end;
}

.principle-list {
  display: grid;
  gap: 20px;
}

.principle-list article {
  padding: 0 0 0 18px;
  border-left: 4px solid #2f7d68;
}

.principle-list p {
  margin-bottom: 0;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 30px max(18px, calc((100vw - 1180px) / 2));
  color: #43504c;
  background: #e8efec;
  border-top: 1px solid rgba(39, 74, 66, 0.16);
}

.site-footer p {
  margin: 6px 0 0;
}

.site-footer nav {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-footer a {
  padding: 4px 0;
}

.article-shell {
  min-height: calc(100vh - 190px);
  padding: 58px max(18px, calc((100vw - 860px) / 2));
  background: #fbfcfa;
}

.article-content {
  max-width: 860px;
}

.article-content h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.08;
}

.article-content .lead {
  margin: 0 0 36px;
  color: #33403c;
  font-size: 20px;
  line-height: 1.7;
}

.article-content section {
  padding: 28px 0;
  border-top: 1px solid rgba(39, 74, 66, 0.14);
}

.article-content h2 {
  margin: 0 0 12px;
  font-size: 26px;
  line-height: 1.25;
}

.article-content p {
  margin: 0 0 16px;
  font-size: 17px;
  line-height: 1.85;
}

.contact-panel {
  padding: 22px;
  background: #eef4f1;
  border: 1px solid rgba(39, 74, 66, 0.16);
  border-radius: 8px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
}

.text-button:hover {
  background: var(--accent-strong);
}

@media (max-width: 960px) {
  .content-grid,
  .guide-grid {
    grid-template-columns: 1fr;
  }

  .guide-card {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    min-height: 76px;
    padding: 10px 14px;
  }

  .site-nav {
    width: 100%;
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  .site-nav a {
    padding: 7px 9px;
    font-size: 13px;
  }

  .app-shell {
    min-height: calc(100vh - 76px);
    scroll-margin-top: 86px;
  }

  .content-band,
  .article-shell {
    padding: 40px 18px;
  }

  .content-band h2,
  .article-content h1 {
    font-size: 32px;
  }

  .content-band p,
  .article-content p {
    font-size: 16px;
  }

  .article-content .lead {
    font-size: 18px;
  }

  .site-footer {
    flex-direction: column;
    padding: 24px 18px;
  }

  .site-footer nav {
    justify-content: flex-start;
  }
}
