*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg: #0d1117;
  --color-surface: #161b22;
  --color-surface-hover: #1c2330;
  --color-border: #30363d;
  --color-text: #e6edf3;
  --color-text-muted: #8b949e;
  --color-accent: #a78bfa;
  --color-accent-hover: #c4b5fd;
  --color-accent-soft: rgba(167, 139, 250, 0.15);
  --color-danger: #f87171;
  --color-danger-hover: #fca5a5;
  --color-success: #4ade80;
  --color-success-bg: rgba(74, 222, 128, 0.12);
  --color-info-bg: rgba(167, 139, 250, 0.12);
  --sidebar-width: 28rem;
  --header-height: auto;
  --fab-size: 5.6rem;
  --radius-sm: 0.6rem;
  --radius-md: 1rem;
  --radius-lg: 1.2rem;
  --shadow-fab: 0 0.4rem 2rem rgba(167, 139, 250, 0.35);
  --shadow-modal: 0 0.8rem 3.2rem rgba(0, 0, 0, 0.45);
}

html {
  font-size: 10px;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.6rem;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 140rem;
  margin: 0 auto;
}

.header {
  padding: 2rem 2.4rem 1.6rem;
  border-bottom: 0.1rem solid var(--color-border);
  background-color: var(--color-bg);
}

.header__title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1.6rem;
}

.header__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
}

.search {
  position: relative;
  flex: 1;
  min-width: 20rem;
  max-width: 48rem;
}

.search__label {
  position: absolute;
  width: 0.1rem;
  height: 0.1rem;
  padding: 0;
  margin: -0.1rem;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search__icon {
  position: absolute;
  left: 1.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.8rem;
  height: 1.8rem;
  pointer-events: none;
  background-color: var(--color-text-muted);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

.search__input {
  width: 100%;
  padding: 1rem 1.4rem 1rem 4.2rem;
  font-size: 1.5rem;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 0.1rem solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search__input::placeholder {
  color: var(--color-text-muted);
}

.search__input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 0.3rem var(--color-accent-soft);
}

.lang-switch {
  display: flex;
  flex-shrink: 0;
  gap: 0.4rem;
  width: auto;
  background-color: var(--color-surface);
  border: 0.1rem solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
}

.lang-switch__btn {
  font-size: 1.3rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 0.4rem;
  background-color: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.lang-switch__btn:hover {
  color: var(--color-text);
  background-color: var(--color-surface-hover);
}

.lang-switch__btn:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.2rem;
}

.lang-switch__btn--active {
  background-color: var(--color-accent);
  color: var(--color-bg);
}

.header__tags-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.2rem;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  min-height: 0;
  flex: 1;
}

.tag-filters:empty {
  display: none;
}

.header__tags-bar:has(.tag-filters:empty) {
  justify-content: flex-end;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 1.2rem;
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 0.1rem solid var(--color-border);
  border-radius: 10rem;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.tag-pill:hover {
  color: var(--color-text);
  border-color: var(--color-accent);
}

.tag-pill:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.2rem;
}

.tag-pill--active {
  color: var(--color-bg);
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.tag-pill--static {
  cursor: default;
  pointer-events: none;
}

.tag-pill--removable {
  gap: 0.6rem;
  padding-right: 0.8rem;
}

.tag-pill__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.tag-pill__remove:hover {
  color: var(--color-danger);
  background-color: rgba(248, 113, 113, 0.15);
}

.tag-pill__remove:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.1rem;
}

.tags-editor__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  min-height: 0;
  margin-bottom: 1rem;
}

.tags-editor__list:empty {
  display: none;
}

.tags-editor__input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}

.tags-editor__input {
  flex: 1;
  min-width: 14rem;
}

.tags-editor__add {
  flex-shrink: 0;
}

.note-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 2rem;
}

.note-detail__action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.2rem;
  font-size: 1.3rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.note-detail__action-btn--edit {
  color: var(--color-accent);
  background-color: var(--color-accent-soft);
  border: 0.1rem solid var(--color-accent);
}

.note-detail__action-btn--edit:hover {
  background-color: var(--color-accent);
  color: var(--color-bg);
}

.note-detail__action-btn--delete {
  color: var(--color-danger);
  background-color: rgba(248, 113, 113, 0.08);
  border: 0.1rem solid var(--color-danger);
}

.note-detail__action-btn--delete:hover {
  background-color: rgba(248, 113, 113, 0.18);
  color: var(--color-danger-hover);
}

.note-detail__action-btn:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.2rem;
}

.btn--compact {
  padding: 0.5rem 1.2rem;
  font-size: 1.3rem;
}

.tags-manage__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.6rem;
  max-height: 24rem;
  overflow-y: auto;
}

.tags-manage__item {
  width: 100%;
  padding: 1rem 1.2rem;
  font-size: 1.4rem;
  font-weight: 500;
  text-align: left;
  color: var(--color-text);
  background-color: var(--color-bg);
  border: 0.1rem solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.tags-manage__item:hover {
  border-color: var(--color-accent);
  background-color: var(--color-surface-hover);
}

.tags-manage__item--selected {
  border-color: var(--color-accent);
  background-color: var(--color-accent-soft);
}

.tags-manage__item:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.2rem;
}

.tags-manage__empty {
  font-size: 1.4rem;
  color: var(--color-text-muted);
  text-align: center;
  padding: 1.6rem 0;
  margin-bottom: 1.6rem;
}

.tags-manage__panel {
  padding-top: 1.6rem;
  margin-bottom: 1.6rem;
  border-top: 0.1rem solid var(--color-border);
}

.tags-manage__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.tags-manage__confirm {
  margin-bottom: 1.6rem;
  padding: 1.2rem;
  background-color: var(--color-bg);
  border: 0.1rem solid var(--color-border);
  border-radius: var(--radius-sm);
}

.feedback {
  font-size: 1.4rem;
  padding: 1rem 1.2rem;
  border-radius: var(--radius-sm);
  margin-top: 1.2rem;
}

.feedback--success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.feedback--info {
  background-color: var(--color-info-bg);
  color: var(--color-accent);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  flex: 1;
  min-height: 0;
}

.sidebar {
  border-right: 0.1rem solid var(--color-border);
  background-color: var(--color-bg);
  overflow-y: auto;
  padding: 1.2rem 0;
}

.sidebar__list {
  list-style: none;
}

.sidebar__empty {
  padding: 2.4rem 2rem;
  font-size: 1.4rem;
  color: var(--color-text-muted);
  text-align: center;
}

.note-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem 2rem;
  cursor: pointer;
  border-left: 0.3rem solid transparent;
  transition: background-color 0.2s, border-color 0.2s;
}

.note-item:hover {
  background-color: var(--color-surface-hover);
}

.note-item--active {
  background-color: var(--color-surface);
  border-left-color: var(--color-accent);
}

.note-item__indicator {
  flex-shrink: 0;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background-color: transparent;
}

.note-item--active .note-item__indicator {
  background-color: var(--color-accent);
}

.note-item__title {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item--active .note-item__title {
  color: var(--color-text);
  font-weight: 600;
}

.note-view {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 3.2rem 4rem;
  background-color: var(--color-bg);
}

.note-view__back {
  align-self: flex-start;
  margin-bottom: 1.6rem;
  padding: 0.6rem 1.2rem;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--color-accent);
  background: none;
  border: 0.1rem solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.note-view__back:hover {
  background-color: var(--color-surface);
  border-color: var(--color-accent);
}

.note-view__back:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.2rem;
}

.note-view__content {
  flex: 1;
}

.note-view__placeholder {
  font-size: 1.6rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 8rem;
}

.note-detail__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.6rem;
  margin-bottom: 2.4rem;
}

.note-detail__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.note-detail__date {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.note-detail__title {
  font-size: 3.2rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
  margin-bottom: 2.4rem;
}

.note-detail__body {
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.note-detail__paragraph {
  font-size: 1.6rem;
  line-height: 1.7;
  color: var(--color-text-muted);
}

.note-detail__quote {
  padding-left: 1.6rem;
  border-left: 0.3rem solid var(--color-accent);
  font-size: 1.6rem;
  font-style: italic;
  line-height: 1.7;
  color: var(--color-text-muted);
}

.fab {
  position: fixed;
  right: 3.2rem;
  bottom: 3.2rem;
  width: var(--fab-size);
  height: var(--fab-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-md);
  background-color: var(--color-accent);
  color: var(--color-bg);
  cursor: pointer;
  box-shadow: var(--shadow-fab);
  transition: background-color 0.2s, transform 0.2s;
  z-index: 50;
}

.fab:hover {
  background-color: var(--color-accent-hover);
  transform: scale(1.05);
}

.fab:focus-visible {
  outline: 0.3rem solid var(--color-text);
  outline-offset: 0.3rem;
}

.fab__icon {
  width: 2.4rem;
  height: 2.4rem;
  background-color: currentColor;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

.btn {
  font-size: 1.4rem;
  font-weight: 600;
  padding: 0.9rem 1.8rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, opacity 0.2s;
}

.btn:focus-visible {
  outline: 0.2rem solid var(--color-accent);
  outline-offset: 0.2rem;
}

.btn--primary {
  background-color: var(--color-accent);
  color: var(--color-bg);
}

.btn--primary:hover {
  background-color: var(--color-accent-hover);
}

.btn--secondary {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 0.1rem solid var(--color-border);
}

.btn--secondary:hover {
  background-color: var(--color-surface-hover);
}

.btn--danger {
  background-color: transparent;
  color: var(--color-danger);
  border: 0.1rem solid var(--color-danger);
}

.btn--danger:hover {
  background-color: rgba(248, 113, 113, 0.12);
  color: var(--color-danger-hover);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.6rem;
}

.modal[hidden] {
  display: none;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
}

.modal__dialog {
  position: relative;
  width: 100%;
  max-width: 52rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.4rem;
  background-color: var(--color-surface);
  border: 0.1rem solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
}

.modal__title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 2rem;
}

.modal__text {
  font-size: 1.5rem;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: flex-end;
}

.form__group {
  margin-bottom: 1.6rem;
}

.form__label {
  display: block;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.6rem;
}

.form__input,
.form__textarea {
  width: 100%;
  padding: 1rem 1.2rem;
  font-size: 1.5rem;
  font-family: inherit;
  color: var(--color-text);
  background-color: var(--color-bg);
  border: 0.1rem solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form__textarea {
  resize: vertical;
  min-height: 12rem;
}

.form__input:focus,
.form__textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 0.3rem var(--color-accent-soft);
}

.form__input--error,
.form__textarea--error {
  border-color: var(--color-danger);
}

.form__error {
  font-size: 1.3rem;
  color: var(--color-danger);
  margin-top: 0.4rem;
}

.form__hint {
  font-size: 1.3rem;
  color: var(--color-text-muted);
  margin-top: 0.4rem;
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.6rem;
  border-top: 0.1rem solid var(--color-border);
}

.form__actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-left: auto;
}

.form__actions--end {
  justify-content: flex-end;
}

.layout--mobile-detail .sidebar {
  display: none;
}

.layout--mobile-detail .note-view {
  display: flex;
}

@media (max-width: 768px) {
  .header {
    padding: 1.6rem;
  }

  .header__title {
    font-size: 1.8rem;
    text-align: center;
  }

  .header__controls {
    justify-content: center;
  }

  .lang-switch {
    align-self: center;
  }

  .header__tags-bar {
    justify-content: center;
  }

  .tag-filters {
    justify-content: center;
    flex: none;
    width: 100%;
  }

  .header__tags-bar .btn--compact {
    width: auto;
  }

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

  .sidebar {
    border-right: none;
    min-height: calc(100vh - 16rem);
  }

  .layout:not(.layout--mobile-detail) .note-view {
    display: none;
  }

  .layout--mobile-detail .sidebar {
    display: none;
  }

  .layout--mobile-detail .note-view {
    display: flex;
  }

  .note-view {
    padding: 2rem 1.6rem 10rem;
  }

  .note-detail__title {
    font-size: 2.4rem;
  }

  .fab {
    right: 2rem;
    bottom: 2rem;
  }
}

@media (max-width: 480px) {
  .header__controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    max-width: none;
    width: 100%;
  }

  .lang-switch {
    align-self: center;
    width: auto;
  }

  .header__tags-bar {
    justify-content: center;
  }

  .tag-filters {
    justify-content: center;
  }

  .tags-editor__input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .tags-editor__add {
    width: 100%;
  }

  .form__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form__actions-right {
    margin-left: 0;
    flex-direction: column;
  }

  .form__actions-right .btn,
  .modal__actions .btn {
    width: 100%;
  }

  .modal__actions {
    flex-direction: column;
  }
}
