:root {
  /* Light scheme */
  --md-sys-color-primary: #6750A4;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #EADDFF;
  --md-sys-color-on-primary-container: #21005D;
  --md-sys-color-secondary: #625B71;
  --md-sys-color-secondary-container: #E8DEF8;
  --md-sys-color-on-secondary-container: #1D192B;
  --md-sys-color-tertiary: #7D5260;
  --md-sys-color-tertiary-container: #FFD8E4;
  --md-sys-color-on-tertiary-container: #31111D;
  --md-sys-color-surface: #FEF7FF;
  --md-sys-color-surface-dim: #DED8E1;
  --md-sys-color-surface-bright: #FEF7FF;
  --md-sys-color-surface-container-lowest: #FFFFFF;
  --md-sys-color-surface-container-low: #F7F2FA;
  --md-sys-color-surface-container: #F3EDF7;
  --md-sys-color-surface-container-high: #ECE6F0;
  --md-sys-color-surface-container-highest: #E6E0E9;
  --md-sys-color-on-surface: #1D1B20;
  --md-sys-color-on-surface-variant: #49454F;
  --md-sys-color-outline: #79747E;
  --md-sys-color-outline-variant: #CAC4D0;
  --md-sys-color-inverse-surface: #322F35;
  --md-sys-color-inverse-on-surface: #F5EFF7;
  --md-sys-color-inverse-primary: #D0BCFF;
  --md-sys-color-shadow: #000000;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --md-sys-color-primary: #D0BCFF;
  --md-sys-color-on-primary: #381E72;
  --md-sys-color-primary-container: #4F378B;
  --md-sys-color-on-primary-container: #EADDFF;
  --md-sys-color-secondary: #CCC2DC;
  --md-sys-color-secondary-container: #4A4458;
  --md-sys-color-on-secondary-container: #E8DEF8;
  --md-sys-color-tertiary: #EFB8C8;
  --md-sys-color-tertiary-container: #633B48;
  --md-sys-color-on-tertiary-container: #FFD8E4;
  --md-sys-color-surface: #141218;
  --md-sys-color-surface-dim: #141218;
  --md-sys-color-surface-bright: #3B383E;
  --md-sys-color-surface-container-lowest: #0F0D13;
  --md-sys-color-surface-container-low: #1D1B20;
  --md-sys-color-surface-container: #211F26;
  --md-sys-color-surface-container-high: #2B2930;
  --md-sys-color-surface-container-highest: #36343B;
  --md-sys-color-on-surface: #E6E0E9;
  --md-sys-color-on-surface-variant: #CAC4D0;
  --md-sys-color-outline: #938F99;
  --md-sys-color-outline-variant: #49454F;
  --md-sys-color-inverse-surface: #E6E0E9;
  --md-sys-color-inverse-on-surface: #322F35;
  --md-sys-color-inverse-primary: #6750A4;
  --md-sys-color-shadow: #000000;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-family: 'Roboto', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--md-sys-color-surface-container);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  padding: 12px 20px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.app-bar__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand__icon {
  color: var(--md-sys-color-primary);
}

.brand__title {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.1px;
}

.brand__count {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 6px;
}

.app-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--md-sys-color-surface-container-high);
  border-radius: 28px;
  padding: 0 16px;
  height: 44px;
  min-width: 220px;
  border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease;
}

.search-wrap:focus-within {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
}

.search-icon {
  color: var(--md-sys-color-on-surface-variant);
  margin-right: 6px;
  flex-shrink: 0;
}

.search-input {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  width: 100%;
  height: 100%;
  padding: 0 4px;
}

.search-input::placeholder {
  color: var(--md-sys-color-on-surface-variant);
}

.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 20px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}

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

.editor,
.notes {
  background: var(--md-sys-color-surface-container-low);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor__head {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.title-field {
  width: 100%;
}

.editor__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.content-field {
  width: 100%;
}

.editor__meta {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  gap: 6px;
}

.meta-label {
  color: var(--md-sys-color-on-surface-variant);
}

.meta-value {
  color: var(--md-sys-color-on-surface);
  font-weight: 500;
}

.notes__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notes__title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.notes__hint {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}

.note-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 70dvh;
  padding-right: 4px;
}

.note-item {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: transform .08s ease, background-color .15s ease, border-color .15s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.note-item:hover {
  background: var(--md-sys-color-surface-container-high);
}

.note-item--active {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
}

.note-item__title {
  font-weight: 500;
  font-size: 15px;
  color: var(--md-sys-color-on-surface);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.note-item__preview {
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-item__time {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  justify-content: space-between;
}

.note-item__pin {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  margin-right: 6px;
}

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--md-sys-color-on-surface-variant);
}

.empty-state md-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
  color: var(--md-sys-color-outline);
}

.snackbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  z-index: 50;
  max-width: calc(100% - 32px);
}

.snackbar--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

md-filled-text-field,
md-outlined-text-field {
  width: 100%;
}

textarea::part(container) {
  background: transparent;
}

.hidden { display: none; }
