:root {
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;

  --bg: #F5F3FA;
  --surface: #FFFFFF;
  --surface-sunk: #F0EDF7;
  --border-soft: #E4DFF2;
  --border-strong: #8A7CB8;
  --text-1: #241C3D;
  --text-2: #5B5478;
  --text-3: #756E90;
  --accent: #5B3EA6;
  --accent-on: #FFFFFF;
  --danger: #A6362F;
  --danger-surface: #FBEAE8;
  --success: #276B4E;
  --success-surface: #E7F3ED;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18151F;
    --surface: #221D30;
    --surface-sunk: #1D1928;
    --border-soft: #332C47;
    --border-strong: #8A7CB8;
    --text-1: #EDE9F7;
    --text-2: #B4ABCF;
    --text-3: #9089B0;
    --accent: #B9A6E8;
    --accent-on: #18151F;
    --danger: #F0938A;
    --danger-surface: #3A211E;
    --success: #8FCFAF;
    --success-surface: #1D2F26;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 375px;
  max-height: 480px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-1);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

.app {
  display: flex;
  flex-direction: column;
  max-height: 480px;
  padding: 0 var(--s3);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

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

/* ---- ①保存帯 ---- */

.save-bar {
  margin-top: var(--s3);
  margin-bottom: var(--s2);
}

.save-bar__toggle {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s1);
}

.save-bar__form[hidden] {
  display: none;
}

.save-bar__form {
  margin-top: var(--s2);
  max-height: 160px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.save-bar__preview-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-bar__preview-url {
  margin: 2px 0 0;
  font-size: 0.75rem;
  color: var(--text-2);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-bar__field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
  color: var(--text-2);
}

.save-bar__field input {
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-1);
  padding: 0 var(--s2);
  font-size: 0.75rem;
  font-family: inherit;
}

.save-bar__actions {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s1);
}

.btn {
  flex: 1;
  height: 40px;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.btn--ghost {
  background: var(--surface-sunk);
  color: var(--text-1);
  border: 1px solid var(--border-soft);
}

/* ---- ②見出し ---- */

.list-section__heading {
  margin: 0;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 28px;
  height: 28px;
}

/* ---- ③未対応リスト ---- */

.list-section__body {
  margin-top: var(--s1);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding-bottom: var(--s2);
}

.item-row {
  background: var(--surface);
  border-radius: 8px;
  padding: 10px var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.item-row--done {
  background: var(--surface-sunk);
}

.item-row__top {
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.item-row__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  background: none;
  border: none;
  color: var(--text-1);
  padding: 0;
  cursor: pointer;
}

.item-row--done .item-row__title {
  font-weight: 400;
  color: var(--text-2);
}

.item-row__menu-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-2);
}

.item-row__menu-btn:hover {
  background: var(--surface-sunk);
}

.item-row__bottom {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.5;
}

.due-chip {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px var(--s1);
  border-radius: 4px;
  background: var(--surface-sunk);
  color: var(--text-3);
}

.due-chip--overdue {
  background: var(--danger-surface);
  color: var(--danger);
}

.memo-icon {
  color: var(--text-3);
}

.empty-state {
  margin: var(--s3) 0;
  font-size: 0.75rem;
  color: var(--text-2);
  line-height: 1.5;
  text-align: center;
}

/* ---- ④対応済み折りたたみ ---- */

.done-section {
  margin-top: var(--s2);
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.done-section__heading {
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
}

.done-section__body[hidden] {
  display: none;
}

.done-section__body {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding-bottom: var(--s3);
}

/* ---- ⋯メニュー（ポップオーバー） ---- */

.item-menu {
  position: fixed;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(36, 28, 61, 0.18);
  overflow: hidden;
  z-index: 10;
}

.item-menu__option {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--s2) var(--s3);
  font-size: 0.75rem;
  color: var(--text-1);
}

.item-menu__option:hover {
  background: var(--surface-sunk);
}

.item-menu__option--danger {
  color: var(--danger);
}
