:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --ink: #1e2420;
  --muted: #667065;
  --line: #d8ded2;
  --paper: #fffdf2;
  --paper-2: #e8f4ff;
  --paper-3: #f4e9ff;
  --accent: #176b5b;
  --accent-strong: #0c4c40;
  --shadow: 0 24px 70px rgba(31, 45, 35, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    linear-gradient(90deg, rgba(30, 36, 32, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(30, 36, 32, 0.045) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100dvh;
}

.auth-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 48px;
  align-items: center;
  width: min(1120px, calc(100% - 40px));
  min-height: 100dvh;
  margin: 0 auto;
}

.brand-block h1 {
  max-width: 720px;
  margin: 10px 0 18px;
  font-size: clamp(44px, 8vw, 94px);
  line-height: 0.94;
  letter-spacing: 0;
}

.lede {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

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

.login-panel {
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.login-panel label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.login-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.16);
}

.register-fields {
  display: grid;
  gap: 12px;
}

.login-panel button,
.secondary-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.google-auth-block {
  display: grid;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.google-auth-block span {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.google-auth-block span::before,
.google-auth-block span::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.login-panel .google-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.login-panel .google-btn::before {
  content: "G";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 999px;
  background: conic-gradient(#4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0 100%);
  color: #fff;
  font-weight: 900;
}

.login-panel .outline-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.auth-message.error {
  color: #9f2f2f;
}

.workspace-view {
  min-height: 100dvh;
  padding: 22px;
}

.topbar,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1280px, 100%);
  margin: 0 auto;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 34px;
  line-height: 1;
}

.topbar-actions,
.toolbar {
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-label,
.save-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.ghost-btn,
.tool-btn,
.workspace-select {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font-weight: 800;
}

.workspace-select {
  min-width: 180px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 14px center / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) right 10px center / 6px 6px no-repeat,
    rgba(255, 255, 255, 0.72);
  padding-right: 30px;
}

.tool-btn.active {
  border-color: rgba(23, 107, 91, 0.42);
  background: rgba(23, 107, 91, 0.12);
  color: var(--accent-strong);
}

.toolbar {
  justify-content: flex-start;
  margin-top: 18px;
}

.notes-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.notes-layer .note {
  pointer-events: auto;
}

.note {
  position: absolute;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  width: min(var(--w, 400px), calc(100vw - 16px));
  height: min(var(--h, 500px), calc(100vh - 16px));
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(30, 36, 32, 0.1);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 22px 56px rgba(31, 45, 35, 0.18);
  transform: translate3d(var(--x), var(--y), 0);
  transition:
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.note[data-color="blue"] {
  background: var(--paper-2);
}

.note[data-color="green"] {
  background: #e8f8ec;
}

.note[data-color="pink"] {
  background: #ffe9f1;
}

.note[data-color="violet"] {
  background: var(--paper-3);
}

.note[data-color="orange"] {
  background: #fff0df;
}

.note[data-color="gray"] {
  background: #eef1ef;
}

.note.pinned {
  z-index: 20;
  box-shadow: 0 22px 54px rgba(12, 76, 64, 0.22);
}

.note.hidden-pin {
  opacity: 0;
  pointer-events: none;
}

.note.dragging {
  z-index: 40;
  box-shadow: 0 30px 80px rgba(31, 45, 35, 0.22);
}

.note-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(30, 36, 32, 0.08);
  background: rgba(242, 201, 76, 0.48);
  cursor: move;
  touch-action: none;
}

.header-color-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(30, 36, 32, 0.08);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.header-color-btn::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 1px solid rgba(30, 36, 32, 0.18);
  border-radius: 999px;
  background:
    conic-gradient(#f2c94c 0 25%, #7ccfa0 0 50%, #7ab6e8 0 75%, #e89abe 0 100%);
}

.note[data-color="blue"] .note-header {
  background: rgba(166, 209, 246, 0.55);
}

.note[data-color="green"] .note-header {
  background: rgba(154, 220, 171, 0.55);
}

.note[data-color="pink"] .note-header {
  background: rgba(247, 180, 206, 0.55);
}

.note[data-color="violet"] .note-header {
  background: rgba(211, 180, 242, 0.55);
}

.note[data-color="orange"] .note-header {
  background: rgba(246, 190, 124, 0.55);
}

.note[data-color="gray"] .note-header {
  background: rgba(193, 202, 195, 0.6);
}

.note-header-title {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-title {
  width: 100%;
  min-height: 54px;
  padding: 16px 14px 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.2;
  outline: none;
}

.note-tools,
.color-row {
  display: flex;
  gap: 5px;
  padding: 8px 10px;
}

.note-tools {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid rgba(30, 36, 32, 0.06);
}

.color-row {
  flex-wrap: wrap;
}

.format-btn {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: rgba(30, 36, 32, 0.08);
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.font-size-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(30, 36, 32, 0.08);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.font-size-input {
  width: 48px;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  outline: none;
}

.font-size-control:focus-within {
  box-shadow: inset 0 0 0 1px rgba(23, 107, 91, 0.32);
}

.format-btn.italic {
  font-style: italic;
}

.format-btn.underline {
  text-decoration: underline;
}

.format-btn.strike {
  text-decoration: line-through;
}

.format-btn.active {
  background: rgba(23, 107, 91, 0.18);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(23, 107, 91, 0.32);
}

.color-row {
  display: none;
  padding-top: 0;
}

.note.show-colors .color-row {
  display: flex;
}

.color-swatch {
  min-width: 0;
  min-height: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid rgba(30, 36, 32, 0.18);
  border-radius: 999px;
  background: #fffdf2;
}

.color-swatch[data-color="blue"] {
  background: #e8f4ff;
}

.color-swatch[data-color="green"] {
  background: #e8f8ec;
}

.color-swatch[data-color="pink"] {
  background: #ffe9f1;
}

.color-swatch[data-color="violet"] {
  background: #f4e9ff;
}

.color-swatch[data-color="orange"] {
  background: #fff0df;
}

.color-swatch[data-color="gray"] {
  background: #eef1ef;
}

.color-swatch.active {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 2px rgba(23, 107, 91, 0.16);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: rgba(30, 36, 32, 0.08);
  color: var(--ink);
  font-weight: 900;
}

.icon-btn.active {
  border-color: rgba(23, 107, 91, 0.38);
  background: rgba(23, 107, 91, 0.14);
  color: var(--accent-strong);
}

.note-body {
  min-height: 0;
  overflow: hidden;
}

.note-editor {
  width: 100%;
  min-height: 0;
  height: 100%;
  padding: 14px 24px 18px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--note-font-size, 15px);
  line-height: 1.45;
  outline: none;
  overflow: auto;
}

.note-editor p,
.note-editor div {
  margin: 0 0 10px;
}

.note-editor h2,
.note-editor h3 {
  margin: 0 0 10px;
  line-height: 1.12;
}

.note-editor ul,
.note-editor ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.note.collapsed {
  height: auto;
}

.note.collapsed .note-tools,
.note.collapsed .color-row,
.note.collapsed .note-body {
  display: none;
}

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 0 0 10px 0;
  background:
    linear-gradient(135deg, transparent 0 48%, rgba(30, 36, 32, 0.28) 50%, transparent 52%) 7px 9px / 13px 13px no-repeat,
    transparent;
  cursor: nwse-resize;
}

.note.collapsed .resize-handle {
  display: none;
}

.workspace-view.mini {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  width: min(420px, calc(100vw - 24px));
  min-height: 560px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 28px 80px rgba(31, 45, 35, 0.24);
}

.workspace-view.mini .topbar,
.workspace-view.mini .toolbar {
  width: 100%;
}

.workspace-view.mini .topbar {
  align-items: flex-start;
}

.workspace-view.mini .user-label,
.workspace-view.mini .ghost-btn {
  display: none;
}

.workspace-view.mini .note {
  width: min(var(--w, 340px), calc(100vw - 58px));
}

@media (max-width: 760px) {
  .auth-view {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 28px;
    padding: 28px 0;
  }

  .brand-block h1 {
    font-size: 46px;
  }

  .workspace-view {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

}
