* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Roboto, sans-serif;
  background: #fff;
  color: #202124;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }
input, textarea { font-family: inherit; color: inherit; }

/* ===== ヘッダー ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 10px;
  background: #fff; border-bottom: 1px solid #e0e0e0;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 20px; color: #5f6368; white-space: nowrap; }
.searchbox {
  flex: 1; display: flex; align-items: center; gap: 6px;
  max-width: 640px; height: 42px; margin: 0 auto;
  background: #f1f3f4; border-radius: 8px; padding: 0 10px;
}
.searchbox input {
  flex: 1; min-width: 40px; border: none; outline: none; background: transparent; font-size: 15px;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.search-icon { display: flex; color: #5f6368; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: transparent; color: #5f6368; cursor: pointer; flex: none;
}
.icon-btn:hover { background: rgba(95, 99, 104, .1); }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.active { color: #202124; }
.text-btn {
  border: none; background: transparent; border-radius: 6px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; color: #202124; cursor: pointer;
}
.text-btn:hover { background: rgba(95, 99, 104, .1); }
.text-btn.primary { color: #1a73e8; }
.spacer { flex: 1; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinning svg { animation: spin 1s linear infinite; }

/* ===== サイドバー ===== */
.sidebar {
  position: fixed; top: 56px; left: 0; bottom: 0; z-index: 25;
  width: 280px; padding: 8px 0; background: #fff; overflow-y: auto;
  transform: translateX(-100%); transition: transform .18s ease;
}
.sidebar.open { transform: none; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.side-item {
  display: flex; align-items: center; gap: 18px; width: 100%;
  padding: 12px 12px 12px 24px; border: none; background: transparent;
  border-radius: 0 25px 25px 0; font-size: 14px; font-weight: 500;
  color: #202124; cursor: pointer; text-align: left;
}
.side-item svg { width: 22px; height: 22px; color: #5f6368; flex: none; }
.side-item:hover { background: #f1f3f4; }
.side-item.active { background: #feefc3; }
.side-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { position: fixed; inset: 56px 0 0 0; z-index: 20; background: rgba(0,0,0,.35); }

@media (min-width: 900px) {
  .sidebar { transform: none; border-right: 1px solid #e0e0e0; }
  .sidebar.closed-desktop { transform: translateX(-100%); border: none; }
  .main { margin-left: 280px; }
  .main.full { margin-left: 0; }
  .scrim { display: none; }
}

/* ===== メイン ===== */
.main { padding: 16px 16px 80px; transition: margin-left .18s ease; }
.section-title {
  font-size: 11px; font-weight: 600; color: #5f6368;
  text-transform: none; letter-spacing: .8px; margin: 14px 4px 8px;
}
.loading { display: flex; justify-content: center; padding: 48px; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid #e0e0e0; border-top-color: #fbbc04; animation: spin .8s linear infinite;
}

/* ===== 入力欄(コンポーザー) ===== */
.composer {
  max-width: 600px; margin: 8px auto 24px;
  border: 1px solid #e0e0e0; border-radius: 10px;
  box-shadow: 0 2px 6px rgba(60,64,67,.15); background: #fff;
}
.composer-collapsed { display: flex; align-items: center; padding: 4px 6px 4px 16px; cursor: text; }
.composer-collapsed .placeholder { flex: 1; color: #5f6368; font-size: 15px; font-weight: 500; }
.composer-expanded { padding: 10px 14px 6px; }

.note-head { display: flex; align-items: flex-start; gap: 4px; }
.title-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; font-weight: 600; padding: 4px 0; min-width: 0;
}
.body-input {
  width: 100%; border: none; outline: none; background: transparent;
  font-size: 14px; line-height: 1.5; resize: none; padding: 6px 0;
}
.note-footer { display: flex; align-items: center; gap: 2px; padding-top: 4px; flex-wrap: wrap; }
.pin-corner { flex: none; }
.updated-text { font-size: 12px; color: #5f6368; padding: 0 8px; }

/* ===== チェックリスト ===== */
.check-items { padding: 4px 0; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.check-row input[type="checkbox"] { width: 16px; height: 16px; flex: none; accent-color: #5f6368; cursor: pointer; }
.check-row .check-text {
  flex: 1; border: none; outline: none; background: transparent; font-size: 14px; padding: 4px 0; min-width: 0;
}
.check-row.done .check-text { text-decoration: line-through; color: #5f6368; }
.check-row .row-del { opacity: 0; }
.check-row:hover .row-del, .check-row:focus-within .row-del { opacity: 1; }
@media (hover: none) { .check-row .row-del { opacity: .7; } }
.check-add { display: flex; align-items: center; gap: 8px; padding: 2px 0 2px 1px; color: #5f6368; }
.check-add svg { width: 18px; height: 18px; flex: none; }
.check-add input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; padding: 4px 0; }

/* ===== カードグリッド ===== */
.grid { columns: 240px; column-gap: 12px; }
@media (max-width: 640px) { .grid { column-count: 2; column-width: auto; } }
.card {
  display: inline-block; width: 100%; margin: 0 0 12px;
  border: 1px solid #e0e0e0; border-radius: 10px;
  padding: 12px 14px 34px; background: #fff;
  break-inside: avoid; cursor: default; position: relative;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 2px 8px rgba(60,64,67,.3); }
.card.colored { border-color: transparent; }
.card-title { font-size: 15px; font-weight: 600; margin: 0 22px 6px 0; word-break: break-word; }
.card-body {
  font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  max-height: 240px; overflow: hidden; margin: 0;
}
.card .check-row { pointer-events: none; }
.card .check-row input { pointer-events: auto; }
.card .check-row .check-line { font-size: 13.5px; word-break: break-word; }
.card .check-row.done .check-line { text-decoration: line-through; color: #5f6368; }
.card-more { font-size: 12px; color: #5f6368; padding: 4px 0 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500; color: #3c4043;
  background: rgba(0,0,0,.06); border-radius: 12px; padding: 3px 10px;
}
.chip button { border: none; background: transparent; cursor: pointer; padding: 0; display: flex; color: #5f6368; }
.chip button svg { width: 12px; height: 12px; }

.card .pin-corner { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; }
.card .pin-corner svg { width: 18px; height: 18px; }
.card-toolbar {
  position: absolute; left: 6px; right: 6px; bottom: 2px;
  display: flex; align-items: center; gap: 2px;
  opacity: 0; transition: opacity .15s;
}
.card:hover .card-toolbar, .card:focus-within .card-toolbar { opacity: 1; }
@media (hover: none) { .card-toolbar, .card .pin-corner { opacity: .85 !important; } }
.card-toolbar .icon-btn { width: 32px; height: 32px; }
.card-toolbar .icon-btn svg { width: 17px; height: 17px; }

/* ===== ゴミ箱 ===== */
.trash-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: #5f6368; padding: 8px; margin-bottom: 8px;
}

/* ===== 空の状態 ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 80px 20px; color: #5f6368; font-size: 15px; text-align: center;
}
.empty-state svg { width: 90px; height: 90px; color: #e0e0e0; }

/* ===== モーダル ===== */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 12px 12px; overflow-y: auto;
}
.editor {
  width: 100%; max-width: 600px; background: #fff;
  border-radius: 10px; padding: 12px 16px 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.labels-dialog {
  width: 100%; max-width: 340px; background: #fff;
  border-radius: 10px; padding: 16px; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.labels-dialog h3 { margin: 0 0 12px; font-size: 16px; }
.label-new { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.label-new input, .pw-input {
  flex: 1; width: 100%; border: none; border-bottom: 1px solid #e0e0e0; outline: none;
  font-size: 14px; padding: 6px 2px;
}
.label-new input:focus, .pw-input:focus { border-bottom-color: #1a73e8; }
.label-list { max-height: 50vh; overflow-y: auto; }
.label-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.label-row svg { width: 18px; height: 18px; color: #5f6368; flex: none; }
.label-row input { flex: 1; border: none; outline: none; font-size: 14px; padding: 6px 2px; background: transparent; min-width: 0; }
.label-row input:focus { border-bottom: 1px solid #1a73e8; }
.dialog-footer { display: flex; justify-content: flex-end; padding-top: 12px; }
.pw-note { font-size: 13px; color: #5f6368; margin: 0 0 10px; }

/* ===== ポップオーバー ===== */
.popover {
  position: fixed; z-index: 60; background: #fff;
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.3); padding: 8px;
}
.color-pop { display: grid; grid-template-columns: repeat(6, 34px); gap: 6px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(0,0,0,.12); padding: 0;
}
.swatch:hover { border-color: #202124; }
.swatch.sel { border-color: #a142f4; box-shadow: 0 0 0 1px #a142f4 inset; }
.label-pop { min-width: 220px; }
.label-pop h4 { margin: 2px 4px 8px; font-size: 13px; font-weight: 600; }
.label-pop .lp-search { width: 100%; border: none; outline: none; font-size: 13px; padding: 4px; }
.lp-list { max-height: 40vh; overflow-y: auto; margin-top: 4px; }
.lp-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  font-size: 13.5px; cursor: pointer; border-radius: 4px;
}
.lp-row:hover { background: #f1f3f4; }
.lp-row input { accent-color: #5f6368; }
.lp-create {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: transparent; cursor: pointer;
  font-size: 13px; padding: 8px 4px; border-top: 1px solid #e0e0e0; margin-top: 4px;
  color: #202124; text-align: left;
}
.lp-create svg { width: 16px; height: 16px; color: #5f6368; }
.lp-create:hover { background: #f1f3f4; }

/* ===== トースト ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 70; background: #323232; color: #fff;
  font-size: 14px; padding: 12px 20px; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3); max-width: 90vw;
}
