/* ============================================================
   Memo — styles
   Daily Scheduler / Minder と同じ質感でそろえる。
   ・色は「暖かいグレー1系統 ＋ 差し色1色」
   ・線は3段階（外枠 / 罫線 / 補助線）だけ
   ・触る場所は必ず 28px 以上（タッチ端末では 34px 以上）
   ============================================================ */

:root{
  /* 紙と地の色 */
  --paper: #ffffff;
  --bg:    #e8e6e0;
  --bg-2:  #dedbd3;

  /* 文字 */
  --ink:   #21211e;
  --ink-2: #55544e;
  --ink-3: #8a877f;
  --ink-4: #b4b1a8;

  /* 線 */
  --frame:     #26261f;
  --frame-2:   #c6c3b9;
  --rule:      #dcd9d1;
  --rule-soft: #efede7;

  /* 面 */
  --head-bg: #f5f4ef;
  --tint:    #faf9f5;
  --tint-2:  #f2f0ea;

  /* 差し色 */
  --accent:      #2c6a58;
  --accent-deep: #23543f;
  --accent-soft: #e8f0ec;
  --danger:      #a3453c;

  /* 動き */
  --ease: cubic-bezier(.22,.9,.28,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --t-fast: .16s;
  --t-base: .24s;

  /* 効果 */
  --ring: 0 0 0 2px #fff, 0 0 0 3.5px rgba(44,106,88,.55);
  --shadow-1: 0 1px 2px rgba(35,33,28,.06);
  --shadow-2: 0 4px 14px -4px rgba(35,33,28,.16), 0 1px 3px rgba(35,33,28,.07);
  --shadow-3: 0 18px 44px -14px rgba(35,33,28,.30), 0 3px 10px rgba(35,33,28,.08);

  --font: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo",
          "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --cap-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --tb-h: 52px;              /* 上のバーの高さ */
}

*{ box-sizing: border-box; }
[hidden]{ display: none !important; }

html, body{ margin:0; padding:0; height:100%; }

body{
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  background-image: linear-gradient(180deg, var(--bg) 0, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

input, textarea, select, button{ font-family: inherit; color: inherit; }
input[type="text"], input[type="password"], textarea{ appearance:none; -webkit-appearance:none; border-radius:0; }

:focus{ outline: none; }
button:focus-visible, input:focus-visible{ box-shadow: var(--ring); border-radius: 8px; }
/* 本文欄はいつも触る場所なので、輪郭は出さない */
.editor:focus, .editor:focus-visible{ box-shadow: none; }

/* ============================================================
   上のバー
   ============================================================ */
.toolbar{
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  height: calc(var(--tb-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0 10px;
  display: flex; align-items: center; gap: 6px;
  background: var(--head-bg);
  border-bottom: 1px solid var(--frame-2);
  box-shadow: var(--shadow-1);
}
.app-title{
  margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .04em;
}
.tb-spacer{ flex: 1; }
.tb-group{ display: flex; align-items: center; gap: 4px; }

.btn{
  min-height: 34px; padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--frame-2); border-radius: 9px;
  font-size: 14px; line-height: 1; cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:hover{ background: var(--tint); border-color: var(--ink-4); }
.btn:active{ background: var(--tint-2); }
.btn.icon{ width: 36px; min-width: 36px; padding: 0; font-size: 19px; }
.btn.icon.small{ width: 30px; min-width: 30px; min-height: 30px; font-size: 16px; }
.btn.primary{ background: var(--accent); border-color: var(--accent-deep); color: #fff; }
.btn.primary:hover{ background: var(--accent-deep); }
.btn.danger{ background: var(--danger); border-color: #86382f; color: #fff; }
.btn.danger:hover{ filter: brightness(.94); }

.saved{
  font-size: 11.5px; color: var(--ink-3); letter-spacing: .06em;
  padding: 3px 8px; border-radius: 999px; background: var(--tint-2);
  white-space: nowrap;
}
.saved.sync{ color: var(--accent); background: var(--accent-soft); }

/* ドロップダウン */
.menu-wrap{ position: relative; }
.menu{
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 50;
  min-width: 232px; padding: 5px;
  background: var(--paper);
  border: 1px solid var(--frame-2); border-radius: 12px;
  box-shadow: var(--shadow-3);
}
.menu-item{
  width: 100%; min-height: 38px; padding: 0 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: 0; border-radius: 8px;
  font-size: 14px; text-align: left; cursor: pointer;
}
.menu-item:hover{ background: var(--tint-2); }
.menu-item.danger{ color: var(--danger); }
.menu-item .ver{ font-size: 11.5px; color: var(--ink-3); font-family: var(--cap-font); }
.menu-sep{ height: 1px; margin: 5px 6px; background: var(--rule); }

/* ============================================================
   本体レイアウト
   ============================================================ */
.wrap{
  position: fixed;
  inset: calc(var(--tb-h) + env(safe-area-inset-top)) 0 0 0;
  display: grid;
  grid-template-columns: minmax(268px, 340px) 1fr;
}
.pane{ min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* --- 一覧 --- */
.list-pane{
  background: var(--tint);
  border-right: 1px solid var(--frame-2);
}
.list-head{
  flex: 0 0 auto; height: 34px; padding: 0 14px;
  display: flex; align-items: center;
  border-bottom: 1px solid var(--rule);
}
.count{ font-size: 11.5px; color: var(--ink-3); letter-spacing: .06em; font-family: var(--cap-font); }

.note-list{
  flex: 1 1 auto; margin: 0; padding: 0; list-style: none;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.note-item{
  position: relative;
  padding: 11px 40px 11px 14px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}
.note-item:hover{ background: var(--tint-2); }
.note-item.sel{ background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.note-title{
  font-size: 14.5px; font-weight: 600; line-height: 1.45;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-title.untitled{ color: var(--ink-4); font-weight: 500; }
.note-sub{
  margin-top: 3px; font-size: 12px; color: var(--ink-3); line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-sub .when{ font-family: var(--cap-font); margin-right: 8px; }

.empty{
  margin: 26px 16px; text-align: center;
  font-size: 13px; line-height: 1.9; color: var(--ink-3);
}

/* --- 本文 --- */
.edit-pane{ background: var(--paper); }
.edit-head{
  flex: 0 0 auto; height: 34px; padding: 0 10px 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--rule);
}
.stamp{ font-size: 11.5px; color: var(--ink-3); font-family: var(--cap-font); letter-spacing: .04em; }
.menu.right{ right: 0; }

.editor{
  flex: 1 1 auto; width: 100%;
  padding: 20px 22px calc(24px + env(safe-area-inset-bottom)) 22px;
  border: 0; background: transparent; resize: none;
  font-size: 16px; line-height: 1.95; color: var(--ink);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.editor::placeholder{ color: var(--ink-4); }
.edit-empty{ margin: auto; }

/* 何も選んでいないとき */
body.no-note .editor,
body.no-note .edit-head{ display: none; }
body:not(.no-note) .edit-empty{ display: none; }

/* ============================================================
   画面が狭いとき（スマホ）は1画面ずつ
   ============================================================ */
.back-only{ display: none; }

@media (max-width: 720px){
  .wrap{ grid-template-columns: 1fr; }
  .list-pane{ border-right: 0; }
  body.show-list .edit-pane{ display: none; }
  body.show-edit .list-pane{ display: none; }
  body.show-edit .back-only{ display: inline-flex; }
  .editor{ padding: 16px 16px calc(20px + env(safe-area-inset-bottom)) 16px; }
  .note-item{ padding-top: 13px; padding-bottom: 13px; }
}

@media (pointer: coarse){
  .btn{ min-height: 38px; }
  .btn.icon{ width: 40px; min-width: 40px; }
  .menu-item{ min-height: 44px; }
}

/* ============================================================
   ダイアログ
   ============================================================ */
.modal{
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(35,33,28,.34);
  animation: fade var(--t-fast) var(--ease-out);
}
@keyframes fade{ from{ opacity: 0 } }
.modal-card{
  width: 100%; max-width: 460px; padding: 20px;
  background: var(--paper); border: 1px solid var(--frame-2); border-radius: 16px;
  box-shadow: var(--shadow-3);
  animation: pop var(--t-base) var(--ease-out);
}
.modal-card.narrow{ max-width: 380px; }
@keyframes pop{ from{ opacity: 0; transform: translateY(10px) scale(.98) } }
.modal-card h2{ margin: 0 0 8px; font-size: 16px; }
.modal-card .note{ margin: 0 0 16px; font-size: 13px; line-height: 1.8; color: var(--ink-2); }
.field{ display: block; margin-bottom: 12px; }
.field span{ display: block; margin-bottom: 5px; font-size: 12px; color: var(--ink-3); }
.field input{
  width: 100%; min-height: 38px; padding: 0 10px;
  background: var(--tint); border: 1px solid var(--frame-2); border-radius: 9px;
  font-size: 14px;
}
.field input:focus{ background: var(--paper); border-color: var(--accent); }
.msg{ margin: 0 0 12px; font-size: 12.5px; line-height: 1.7; }
.msg.ok{ color: var(--accent); }
.msg.ng{ color: var(--danger); }
.modal-btns{ display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ============================================================
   短い知らせ
   ============================================================ */
.toast{
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 95; transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--frame); color: #f7f6f2;
  border-radius: 999px; font-size: 13px; white-space: nowrap;
  box-shadow: var(--shadow-3);
  animation: rise var(--t-base) var(--ease-out);
}
@keyframes rise{ from{ opacity: 0; transform: translate(-50%, 8px) } }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
