/* ==========================================================================
   notes — 静かなメモ帳
   軽量・文字中心・ライト/ダーク対応
   ========================================================================== */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --text: #1f1d1a;
  --text-muted: #7a756d;
  --border: #e7e3da;
  --accent: #4a5d4e;
  --accent-soft: #e7ede8;
  --radius: 6px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

[data-theme="dark"] {
  --bg: #1b1b18;
  --surface: #232320;
  --text: #edebe6;
  --text-muted: #9a948a;
  --border: #34322c;
  --accent: #8fb093;
  --accent-soft: #2a332b;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font-family: inherit;
  font-size: 15px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- header ---- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border);
}

.app-header__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle__icon {
  font-size: 10px;
}

/* ---- toolbar ---- */

.toolbar {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.toolbar__search {
  flex: 1;
  min-width: 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

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

.toolbar__search:disabled,
.toolbar__new-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toolbar__new-button {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- main layout (mobile-first: stacked) ---- */

.app-main {
  display: block;
}

.note-list-pane {
  border-bottom: 1px solid var(--border);
}

.note-view-pane {
  padding: var(--space-4);
}

/* ---- note list ---- */

.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.note-list__item {
  border-bottom: 1px solid var(--border);
}

.note-list__button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  cursor: pointer;
}

.note-list__button:hover {
  background: var(--accent-soft);
}

.note-list__item--active .note-list__button {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.note-list__title {
  font-weight: 600;
  margin: 0 0 var(--space-1);
}

.note-list__meta {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  color: var(--text-muted);
  font-size: 13px;
}

.note-list__date {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.note-list__summary {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-list__tags {
  margin-top: var(--space-1);
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.note-list__tag {
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px var(--space-2);
}

/* ---- note view ---- */

.note-view__title {
  margin: 0 0 var(--space-2);
  font-size: 20px;
  font-weight: 600;
}

.note-view__meta {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.note-view__date {
  font-family: var(--font-mono);
  font-size: 12px;
}

.note-view__tags {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.note-view__tag {
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px var(--space-2);
}

.note-view__content {
  white-space: pre-wrap;
  font-size: 16px;
  line-height: 1.8;
}

/* ---- note view: action buttons (edit / delete) ---- */

.note-view__actions {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.note-view__action-button {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}

.note-view__action-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.note-view__action-button--danger:hover {
  border-color: #b3564a;
  color: #b3564a;
}

/* ---- note form (create / edit) ---- */

.note-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 640px;
}

.note-form__label {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: 13px;
  color: var(--text-muted);
}

.note-form__input,
.note-form__textarea {
  font-family: inherit;
  font-size: 16px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

.note-form__textarea {
  min-height: 220px;
  line-height: 1.7;
}

.note-form__buttons {
  display: flex;
  gap: var(--space-2);
}

.note-form__submit,
.note-form__cancel {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

.note-form__submit {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.note-form__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.note-form__cancel {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

/* ---- inline feedback (トースト禁止のため画面内に表示) ---- */

.form-feedback {
  font-size: 13px;
  margin: 0;
}

.form-feedback[data-tone="error"] {
  color: #b3564a;
}

.form-feedback[data-tone="success"] {
  color: var(--accent);
}

/* ---- status / empty / error messages ---- */

.pane-status {
  color: var(--text-muted);
  padding: var(--space-4);
  margin: 0;
  font-size: 14px;
}

.pane-status[data-tone="error"] {
  color: var(--accent);
}

/* ---- desktop: two columns ---- */

@media (min-width: 800px) {
  .app-main {
    display: grid;
    grid-template-columns: 320px 1fr;
    align-items: start;
    min-height: calc(100vh - 120px);
  }

  .note-list-pane {
    border-bottom: none;
    border-right: 1px solid var(--border);
    height: calc(100vh - 120px);
    overflow-y: auto;
  }

  .note-view-pane {
    height: calc(100vh - 120px);
    overflow-y: auto;
    padding: var(--space-6);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .note-list__button {
    transition: background-color 0.12s ease, border-color 0.12s ease;
  }
}