:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fb;
  color: #172033;
}

* {
  box-sizing: border-box;
}

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

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea,
.rich-editor {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: #0f766e;
  color: white;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.97);
}

button.ghost,
.segments button {
  background: #e9edf3;
  color: #172033;
}

button.danger {
  background: #be123c;
}

button.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #172033;
  padding: 10px 12px;
}

input:focus,
select:focus,
.rich-editor:focus {
  border-color: #2b579a;
  outline: 3px solid rgb(43 87 154 / 0.16);
}

label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 760px);
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgb(15 23 42 / 0.08);
  padding: 20px;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar,
.topbar-actions,
.filters,
.note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar-actions {
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1;
}

.filters {
  margin: 16px 0;
}

.segments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segments button.active {
  background: #0f766e;
  color: white;
}

#search {
  max-width: 320px;
}

.notes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.note {
  border: 1px solid #e2e8f0;
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: white;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.note h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.note-body {
  color: #334155;
}

.note-body h1,
.note-body h2,
.note-body h3,
.note-body h4,
.note-body p,
.note-body div,
.note-body span,
.note-body ul,
.note-body ol {
  margin: 0;
}

.note-body h1 {
  font-size: 28px;
  line-height: 1.15;
}

.note-body h2 {
  font-size: 22px;
  line-height: 1.2;
}

.note-body h3 {
  font-size: 18px;
  line-height: 1.25;
}

.note-body ul,
.note-body ol {
  padding-left: 24px;
}

.note-body > * + * {
  margin-top: 8px;
}

.note-body p,
.note-body li,
.rich-editor li {
  line-height: 1.45;
}

.note p {
  white-space: pre-wrap;
  color: #334155;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #64748b;
  font-size: 12px;
}

.pill {
  border-radius: 999px;
  background: #f1f5f9;
  padding: 4px 8px;
}

.empty,
.error {
  color: #be123c;
  font-weight: 700;
}

.empty {
  text-align: center;
  color: #64748b;
}

.fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  box-shadow: 0 14px 30px rgb(15 23 42 / 0.22);
  font-size: 30px;
  line-height: 1;
  padding: 0;
  z-index: 20;
}

.editor-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #eef2f7;
}

.editor-panel {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  background: #eef2f7;
}

.editor-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #d9dee8;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
}

.editor-title-copy h1 {
  font-size: 22px;
  line-height: 1.1;
}

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

.icon-close {
  width: 40px;
  min-width: 40px;
  padding: 0;
  border: 1px solid #c8d0dc;
  background: #f8fafc;
  color: #334155;
  font-size: 24px;
  line-height: 1;
}

.note-fields {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(140px, 0.7fr) minmax(190px, 1fr);
  gap: 10px;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #d9dee8;
}

.note-fields label {
  gap: 4px;
}

.note-fields input,
.note-fields select {
  min-height: 34px;
  padding: 7px 10px;
}

.ribbon {
  background: #f6f7fb;
  border-bottom: 1px solid #c8d0dc;
}

.editor-toolbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 84px;
  overflow-x: auto;
  padding: 6px 16px 4px;
}

.toolbar-group {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 158px;
  padding: 0 10px 16px;
  border-right: 1px solid #d2d8e2;
}

.toolbar-group:first-child {
  padding-left: 0;
}

.toolbar-group:last-child {
  border-right: 0;
}

.toolbar-group-font {
  min-width: 322px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 27px;
}

.toolbar-caption {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.toolbar-select,
.editor-toolbar .icon-button {
  height: 26px;
  min-height: 26px;
  border: 1px solid #b9c2d0;
  border-radius: 3px;
  background: linear-gradient(#fff, #eef2f7);
  color: #111827;
  font-family: Calibri, Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.7) inset;
}

.toolbar-select {
  width: auto;
  padding: 3px 24px 3px 7px;
}

.toolbar-font {
  width: 214px;
}

.toolbar-size {
  width: 70px;
}

.toolbar-style {
  width: 172px;
}

.editor-toolbar .icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  padding: 0 6px;
  font-weight: 700;
  line-height: 1;
}

.editor-toolbar .icon-button:hover,
.toolbar-select:hover,
.editor-toolbar .icon-button.active {
  border-color: #7aa7d9;
  background: #e6f0ff;
}

.editor-toolbar .icon-button.active {
  box-shadow: inset 0 0 0 1px #7aa7d9;
}

.toolbar-strong {
  font-weight: 900 !important;
}

.toolbar-italic {
  font-style: italic;
}

.toolbar-underline {
  text-decoration: underline;
}

.toolbar-strike {
  text-decoration: line-through;
}

.big-a {
  font-size: 17px;
}

.small-a {
  font-size: 12px;
}

.color-button {
  position: relative;
}

.color-button::after {
  position: absolute;
  right: 6px;
  bottom: 4px;
  left: 6px;
  height: 3px;
  content: "";
}

.text-blue {
  color: #2563eb !important;
}

.text-blue::after {
  background: #2563eb;
}

.text-red {
  color: #dc2626 !important;
}

.text-red::after {
  background: #dc2626;
}

.highlight-yellow {
  background: linear-gradient(#fff, #fff7c2) !important;
  color: #111827 !important;
}

.highlight-yellow::after {
  background: #facc15;
}

.clear-format {
  color: #7c3aed !important;
}

.align-left,
.align-center,
.align-right {
  gap: 2px;
}

.align-left span,
.align-center span,
.align-right span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: #111827;
}

.align-left span {
  width: 18px;
  justify-self: start;
}

.align-left span:nth-child(2) {
  width: 13px;
}

.align-center span {
  width: 18px;
  justify-self: center;
}

.align-center span:nth-child(2) {
  width: 12px;
}

.align-right span {
  width: 18px;
  justify-self: end;
}

.align-right span:nth-child(2) {
  width: 13px;
}

.document-stage {
  min-height: 0;
  overflow: auto;
  padding: 14px 18px 34px;
  background:
    linear-gradient(90deg, rgb(15 23 42 / 0.04) 1px, transparent 1px),
    linear-gradient(#eef2f7, #e9edf5);
  background-size: 32px 32px, auto;
}

.rich-editor {
  width: min(860px, 100%);
  min-height: calc(100vh - 250px);
  margin: 0 auto;
  border: 1px solid #d3d9e4;
  border-radius: 2px;
  background: #fff;
  color: #172033;
  padding: 38px 52px;
  box-shadow: 0 14px 32px rgb(15 23 42 / 0.13);
  font-family: Calibri, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.rich-editor:empty::before {
  color: #94a3b8;
  content: attr(data-placeholder);
}

.rich-editor h1,
.rich-editor h2,
.rich-editor h3,
.rich-editor h4,
.rich-editor p,
.rich-editor div,
.rich-editor ul,
.rich-editor ol {
  margin: 0;
}

.rich-editor h1 {
  font-size: 32px;
  line-height: 1.15;
}

.rich-editor h2 {
  font-size: 25px;
  line-height: 1.2;
}

.rich-editor h3 {
  font-size: 20px;
  line-height: 1.25;
}

.rich-editor h4 {
  font-size: 17px;
  line-height: 1.3;
}

.rich-editor ul,
.rich-editor ol {
  padding-left: 28px;
}

.rich-editor > * + * {
  margin-top: 8px;
}

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

  .topbar,
  .topbar-actions,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  #search {
    max-width: none;
  }

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

  .editor-titlebar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .editor-title-copy h1 {
    font-size: 22px;
  }

  .editor-window-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 40px;
    width: 100%;
  }

  .editor-window-actions button {
    min-height: 34px;
  }

  .note-fields {
    grid-template-columns: 1fr 1fr;
    padding: 8px 10px;
  }

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

  .editor-toolbar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .editor-toolbar {
    flex-wrap: nowrap;
    min-height: 82px;
    overflow-x: auto;
  }

  .toolbar-group {
    min-width: 150px;
    width: auto;
    border-right: 0;
    border-bottom: 0;
    padding: 0 9px 16px;
  }

  .toolbar-group:last-child {
    border-bottom: 0;
  }

  .toolbar-row {
    flex-wrap: nowrap;
  }

  .toolbar-group-font {
    min-width: 280px;
  }

  .toolbar-font,
  .toolbar-style {
    width: min(100%, 210px);
  }

  .document-stage {
    padding: 10px 8px 24px;
  }

  .rich-editor {
    min-height: calc(100vh - 315px);
    padding: 24px 18px;
  }
}
