@charset "UTF-8";

/* ふせんメモ：イメージカラーは水色。PC は左に一覧・右に内容、スマホは一覧と内容を切り替える。 */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #1f3440;
  background: #f3f8fb;
  font-synthesis: none;
  --ink: #1f3440;
  --muted: #587080;
  --accent: #1d78a6;
  --accent-dark: #16628a;
  --sky: #8fd3f4;
  --soft: #e6f4fb;
  --line: #dde9f0;
  --paper: #ffffff;
  --danger: #ac4d43;
  --header: 64px;
}
* { box-sizing: border-box; }
body { margin: 0; -webkit-font-smoothing: antialiased; background: #f3f8fb; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .55; }
:focus-visible { outline: 3px solid #6fb7dc; outline-offset: 3px; }
svg { flex-shrink: 0; }
button svg { pointer-events: none; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: .03em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 20; left: 16px; top: -70px; padding: 12px 20px; background: var(--accent); color: #fff; border-radius: 8px; }
.skip-link:focus { top: 12px; }

/* タグの色。付箋の端・小さな丸・色選びで共通に使う。 */
.tc-red { --tc: #e0675a; }
.tc-orange { --tc: #ee9a45; }
.tc-yellow { --tc: #e2bd38; }
.tc-green { --tc: #57ad74; }
.tc-blue { --tc: #4a8fdc; }
.tc-purple { --tc: #9a6fd0; }
.tc-pink { --tc: #e27aa6; }
.tc-gray { --tc: #98a5ae; }

/* ヘッダー */
.app-header { height: var(--header); background: rgba(255,255,255,.8); border-bottom: 1px solid var(--line); }
.header-inner { height: 100%; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; gap: 11px; align-items: center; text-decoration: none; color: var(--ink); font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.brand-mark { height: 32px; width: 32px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 10px; box-shadow: 0 3px 8px #1d78a620; }
.brand-mark svg { height: 21px; width: 21px; }
.header-tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.storage-badge { font-size: 11px; color: #4f6a79; display: inline-flex; align-items: center; gap: 7px; border: 1px solid #d6e6ef; border-radius: 20px; padding: 6px 11px; background: #f8fcfe; white-space: nowrap; }
.storage-badge > span:first-child { width: 6px; height: 6px; border-radius: 50%; background: #5fb3dc; }
.user-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.role-badge { font-size: 11px; color: #6a5b2f; background: #f7f1df; border: 1px solid #e8dcb6; border-radius: 20px; padding: 4px 9px; white-space: nowrap; }
.text-button { background: transparent; text-decoration: underline; text-underline-offset: 4px; font-size: 12px; padding: 5px 0; flex-shrink: 0; }
.logout-button { color: var(--muted); }

.error-banner { display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid #edd9d3; background: #fff7f3; color: #a05443; padding: 10px 24px; }
.error-banner p { font-size: 12px; line-height: 1.8; margin: 0; }

/* 2列の画面。各列の中だけが縦に動く。 */
.memo-app { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - var(--header)); height: calc(100dvh - var(--header)); }
.error-banner:not([hidden]) + .visually-hidden + .memo-app { height: calc(100dvh - var(--header) - 46px); }

.sidebar { display: flex; flex-direction: column; min-height: 0; background: #eef6fa; border-right: 1px solid var(--line); }
.sidebar-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 20px 18px 12px; }
.sidebar-head h1 { font-size: 24px; line-height: 1.3; }
.memo-count { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 9px 15px; border-radius: 9px; font-size: 13px; font-weight: 600; line-height: 1.4; transition: background-color .15s; }
.primary-button { background: var(--accent); color: #fff; }
.primary-button:hover:not(:disabled) { background: var(--accent-dark); }
.secondary-button { background: #e7f0f5; color: #4c6574; }
.secondary-button:hover:not(:disabled) { background: #dbe8ef; }
.danger-button { background: #ac5c4d; color: #fff; }
.danger-button:hover:not(:disabled) { background: #944b3d; }
.new-button > span { font-size: 17px; font-weight: 400; line-height: 1; }

.search-box { position: relative; margin: 0 18px 10px; }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: #7d93a0; }
.search-box input { width: 100%; min-height: 38px; border: 1px solid #d5e4ec; border-radius: 10px; background: #fff; padding: 7px 12px 7px 34px; font-size: 14px; }
.search-box input:focus { outline: none; border-color: #7dbbdc; box-shadow: 0 0 0 3px #1d78a614; }

.tag-filter-row { display: flex; align-items: flex-start; gap: 10px; padding: 0 18px 10px; border-bottom: 1px solid var(--line); }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.manage-tags { color: var(--accent); padding-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 30px; padding: 4px 10px; border-radius: 15px; border: 1px solid #d5e4ec; background: #fff; font-size: 12px; color: #48606e; }
.chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover:not(:disabled) { border-color: #a9cfe3; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tc, #c8d6de); flex-shrink: 0; }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 1.5px #fff; }

/* 一覧：端が色付きの付箋 */
.memo-list { list-style: none; margin: 0; padding: 12px 14px 24px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 9px; }
.memo-card { position: relative; display: block; width: 100%; text-align: left; background: var(--paper); border-radius: 4px 10px 10px 4px; padding: 11px 14px 11px 22px; box-shadow: 0 1px 2px #1f344012, 0 2px 8px #1f344008; border: 1px solid #e3edf2; transition: transform .12s, box-shadow .12s, border-color .12s; }
.memo-card:hover { border-color: #b8d9ea; box-shadow: 0 2px 10px #1f344014; }
.memo-card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 3px 12px #1d78a61f; }
.edge { position: absolute; left: 0; top: 0; bottom: 0; width: 9px; display: flex; flex-direction: column; border-radius: 4px 0 0 4px; overflow: hidden; background: #d3e2ea; }
.edge > i { flex: 1; background: var(--tc); }
.card-title { margin: 0; font-size: 14px; font-weight: 650; line-height: 1.55; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { margin: 3px 0 0; display: flex; gap: 8px; font-size: 12px; line-height: 1.6; color: var(--muted); min-width: 0; }
.card-date { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.card-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: #7a8e9a; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 0; padding: 0; list-style: none; }
.card-tags li { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: #5f7582; max-width: 100%; }
.card-tags .dot { width: 7px; height: 7px; }
.list-empty { padding: 36px 24px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.9; }
.list-empty p { margin: 0; }
.list-empty-title { font-size: 14px; font-weight: 600; color: #4c6574; margin-bottom: 6px !important; }

/* 右：内容 */
.detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #fbfdfe; }
.detail-toolbar { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 22px; border-bottom: 1px solid var(--line); background: #fff; }
.back-button { display: none; align-items: center; gap: 2px; background: transparent; color: var(--accent); font-size: 15px; font-weight: 600; padding: 6px 8px 6px 0; }
.back-button svg { width: 20px; height: 20px; }
.detail-meta { flex: 1; min-width: 0; margin: 0; font-size: 12px; color: var(--muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: transparent; color: #7b8d98; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover:not(:disabled) { background: #fcf0ec; color: var(--danger); }
.detail-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: 13px; padding: 24px; text-align: center; }
.detail-empty p { margin: 0; }
.empty-note { position: relative; width: 84px; height: 96px; background: #fff; border: 1px solid #dbe9f1; border-radius: 4px 10px 10px 4px; box-shadow: 0 4px 14px #1f34400d; }
.empty-note::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: var(--sky); border-radius: 4px 0 0 4px; }
.empty-note span, .empty-note span::before, .empty-note span::after { position: absolute; left: 26px; right: 14px; height: 3px; border-radius: 2px; background: #e1edf3; }
.empty-note span { top: 30px; }
.empty-note span::before, .empty-note span::after { content: ""; left: 0; right: 0; }
.empty-note span::before { top: 14px; }
.empty-note span::after { top: 28px; right: 18px; }

.memo-sheet { flex: 1; overflow-y: auto; padding: 22px clamp(20px, 5vw, 64px) 40px; min-height: 0; }
.sheet-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.sheet-tags:empty { display: none; }
.sheet-tags li { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 12px; background: #fff; border: 1px solid #dce9f0; font-size: 12px; color: #48606e; }
.memo-body { border-radius: 10px; padding: 4px 2px; min-height: 50%; }
.memo-body.is-editable { cursor: text; }
.memo-body.is-editable:hover { background: #f2f9fc; box-shadow: 0 0 0 8px #f2f9fc; }
.memo-text { margin: 0; font-size: 15px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
/* 1行目（タイトル）を少し大きく */
.memo-text::first-line { font-size: 19px; font-weight: 700; }

.memo-form { display: flex; flex-direction: column; gap: 12px; }
.tag-picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.tag-picker legend { font-size: 12px; color: var(--muted); margin-bottom: 8px; padding: 0; }
.tag-picker-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tag-picker .text-button { color: var(--accent); }
.memo-input { flex: 1; width: 100%; min-height: 260px; resize: vertical; border: 1px solid #d5e4ec; border-radius: 10px; background: #fff; padding: 14px 16px; font-size: 15px; line-height: 1.9; }
.memo-input:focus { outline: none; border-color: #7dbbdc; box-shadow: 0 0 0 3px #1d78a614; }
.memo-input::placeholder { color: #8ba0ab; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.field-hint { margin: 0; font-size: 11px; color: var(--muted); }
.form-actions { display: flex; gap: 8px; margin-left: auto; }
.memo-conflict { border: 1px solid #e8dcb6; background: #f7f1df; color: #6a5b2f; border-radius: 10px; padding: 12px 14px; }
.memo-conflict p { font-size: 12px; line-height: 1.7; margin: 0; }
.memo-conflict .memo-latest { margin-top: 8px; padding: 10px 12px; background: #fff; border-radius: 8px; color: var(--ink); font-size: 13px; max-height: 220px; overflow-y: auto; }
.memo-conflict .memo-latest::first-line { font-size: inherit; }

/* ダイアログ */
dialog { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #fff; box-shadow: 0 24px 90px #1f344026; }
dialog::backdrop { background: #12303f55; backdrop-filter: blur(2px); }
.dialog-content { padding: 26px; }
.dialog-content h2 { font-size: 16px; margin-bottom: 14px; }
.dialog-quote { font-size: 14px; line-height: 1.8; color: #50636e; margin: 0 0 12px; padding: 12px; border-radius: 8px; background: #f2f7fa; overflow-wrap: anywhere; white-space: pre-wrap; max-height: 150px; overflow-y: auto; }
.dialog-description { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 0 0 20px; }
.dialog-actions { display: flex; gap: 9px; justify-content: flex-end; flex-wrap: wrap; }
.field { margin: 0 0 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input { width: 100%; min-height: 42px; border: 1px solid #d5e4ec; border-radius: 8px; padding: 8px 12px; font-size: 15px; background: #fbfdfe; }
.field input:focus { outline: none; border-color: #7dbbdc; box-shadow: 0 0 0 3px #1d78a614; }
.color-field { border: 0; padding: 0; margin: 0 0 14px; }
.color-field legend { font-size: 13px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.color-options { display: flex; flex-wrap: wrap; gap: 8px; }
.color-option { position: relative; }
.color-option input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.color-option span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--tc); border: 3px solid #fff; box-shadow: 0 0 0 1px #d5e4ec; }
.color-option input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
.color-option input:checked + span::after { content: ""; width: 10px; height: 6px; border: solid #fff; border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.color-option input:focus-visible + span { outline: 3px solid #6fb7dc; outline-offset: 2px; }
.tag-error { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: #fff7f3; border: 1px solid #edd9d3; color: #a05443; font-size: 12px; line-height: 1.7; }
.tag-list-heading { font-size: 13px; margin: 22px 0 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.tag-manage-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.tag-manage-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #edf3f6; }
.tag-manage-list .tag-name { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.tag-manage-list .dot { width: 12px; height: 12px; }
.tag-manage-list .tag-uses { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tag-manage-list button { font-size: 12px; padding: 6px 4px; }
.tag-manage-list .tag-delete { color: var(--danger); }
.tag-manage-empty { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.dialog-close-row { margin-top: 18px; }

/* ログイン画面 */
.login-page { min-height: 100vh; display: grid; place-items: center; background: #f3f8fb; }
.login-main { width: 100%; padding: 24px 16px; }
.panel { border: 1px solid #dfeaf0; background: #fff; border-radius: 16px; box-shadow: 0 5px 22px #1f344006; }
.login-card { max-width: 400px; margin: 0 auto; padding: 30px 28px 28px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.login-brand h1 { font-size: 22px; }
.login-description { font-size: 13px; color: var(--muted); line-height: 1.8; margin: 0 0 4px; }
.login-error { margin: 14px 0 0; padding: 10px 14px; border: 1px solid #edd9d3; background: #fff7f3; color: #a05443; border-radius: 8px; font-size: 13px; line-height: 1.7; }
.login-card .field { margin: 18px 0 0; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.login-card input { display: block; width: 100%; min-height: 44px; border: 1px solid #d5e4ec; border-radius: 8px; background: #fbfdfe; padding: 9px 12px; font-size: 15px; color: var(--ink); }
.login-card input:focus { border-color: #7dbbdc; box-shadow: 0 0 0 3px #1d78a614; outline: none; }
.login-button { width: 100%; margin-top: 22px; min-height: 46px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

@media (max-width: 900px) {
  .memo-app { grid-template-columns: 290px minmax(0, 1fr); }
}

/* スマホ：一覧と内容を切り替える（body に show-detail が付くと内容を表示）。 */
@media (max-width: 720px) {
  :root { --header: 58px; }
  .header-inner { padding: 0 16px; gap: 8px; }
  .brand { font-size: 15px; gap: 9px; }
  .brand-mark { width: 29px; height: 29px; border-radius: 9px; }
  .storage-badge { display: none; }
  .header-tools { gap: 8px; }
  .user-name { max-width: 110px; }
  .role-badge { font-size: 10px; padding: 3px 7px; }
  .header-tools:has(.role-badge:not([hidden])) .user-name { max-width: 64px; }
  .error-banner { padding: 10px 16px; align-items: flex-start; }
  .memo-app { display: block; height: auto; min-height: calc(100dvh - var(--header)); }
  .error-banner:not([hidden]) + .visually-hidden + .memo-app { height: auto; }
  .sidebar { border-right: 0; min-height: calc(100dvh - var(--header)); background: #f3f8fb; }
  .memo-list { overflow: visible; padding: 12px 16px 32px; }
  .sidebar-head, .tag-filter-row { padding-left: 16px; padding-right: 16px; }
  .search-box { margin-left: 16px; margin-right: 16px; }
  .search-box input, .field input, .login-card input { font-size: 16px; }
  .detail { display: none; min-height: calc(100dvh - var(--header)); }
  .show-detail .sidebar { display: none; }
  .show-detail .detail { display: flex; }
  .back-button { display: inline-flex; }
  .detail-toolbar { position: sticky; top: 0; z-index: 2; padding: 6px 12px 6px 10px; }
  .detail-meta { text-align: right; font-size: 11px; }
  .memo-sheet { overflow: visible; padding: 18px 18px 40px; }
  .memo-text, .memo-input { font-size: 16px; }
  .memo-text::first-line { font-size: 19px; }
  .memo-input { min-height: 55dvh; }
  .form-footer { position: sticky; bottom: 0; background: #fbfdfe; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
  .dialog-content { padding: 22px; }
}
