/* ② エディタ */
.editor-screen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: var(--c-bg); }

.editor-header {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--c-surface-header);
  border-bottom: 1px solid var(--c-border);
}
.editor-header__divider, .editor-toolbar__divider { width: 1px; height: 28px; background: var(--c-border); }
/* タイトルは見出し（h1）。見た目はボタンのまま */
.editor-title-wrap { min-width: 0; display: flex; font-size: inherit; font-weight: inherit; }
/* ツールバーと年表をまとめる main。中の並びは今までどおり */
.editor-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-title {
  min-width: 0;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-m);
  background: transparent;
  font-size: var(--fs-m);
  font-weight: 700;
  cursor: pointer;
}
.editor-title .icon { color: var(--c-sub); }
.editor-title__text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.editor-toolbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
}
.editor-toolbar__hint { margin-left: 4px; font-size: var(--fs-s); color: var(--c-sub); }
.editor-toolbar__divider { margin: 0 8px; }
.btn__small { --text-nudge: 0.16em; font-size: var(--fs-s); font-weight: 400; } /* 小さなひらがなだけの文字（もどす・やりなおす）は、少し多めに下げる */

/* 年表 */
.editor-main { position: relative; flex: 1; min-height: 0; display: flex; }

/* ⑪ はじめての案内 */
.onboard {
  position: absolute;
  left: 60px;
  top: 120px;
  width: min(660px, calc(100% - 80px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-l);
  background: var(--c-white);
  box-shadow: var(--shadow-pop);
}
.onboard__title { font-size: var(--fs-l); font-weight: 700; }
.onboard__steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.onboard__steps li { counter-increment: step; display: flex; align-items: center; gap: 12px; }
.onboard__steps li::before {
  content: counter(step);
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--c-info-bg);
  color: var(--c-info);
  font-weight: 700;
}
.onboard__foot { display: flex; align-items: center; gap: 16px; }
.onboard__foot a { font-weight: 700; }
.onboard__foot .btn { font-weight: 400; color: var(--c-sub); }

@media (max-width: 1100px) {
  .editor-toolbar__hint { display: none; }
}

/* ---- エディタの中身と右のパネル ---- */
.editor-content { position: relative; flex: 1; min-width: 0; display: flex; }
.editor-aside { display: none; }
.editor-aside.is-open { display: flex; width: 380px; flex-shrink: 0; }
.panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--c-white);
  border-left: 1px solid var(--c-border);
  box-shadow: -4px 0 12px rgba(0, 0, 0, .06);
}
.panel__head { height: 56px; flex-shrink: 0; display: flex; align-items: center; padding: 0 8px 0 20px; border-bottom: 1px solid var(--c-divider); }
.panel__title { flex: 1; font-size: var(--fs-m); font-weight: 700; }
.panel__body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.panel__body > * { flex-shrink: 0; }
.panel__foot { min-height: 68px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-top: 1px solid var(--c-divider); }
.panel__note { font-size: var(--fs-xs); color: var(--c-sub); }

.panel-section { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--c-divider); }
.panel-section:last-child { border-bottom: 0; }
.section__title { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-base); font-weight: 700; }
.section__count { font-size: var(--fs-s); font-weight: 400; color: var(--c-sub); }
.panel-section--future { color: var(--c-disabled); }
.future-row { display: flex; align-items: center; justify-content: space-between; }

.form-row { display: flex; align-items: center; gap: 10px; }
.form-row__label { width: 64px; flex-shrink: 0; }
.form-row .field__input { flex: 1; min-width: 0; }

/* 年代を入れる部品 */
.date { display: flex; flex-direction: column; gap: 6px; }
.date.is-disabled { opacity: .6; }
.date__row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.date__era { width: 88px; }
.date__num { width: 76px; text-align: right; }
.date__unit { min-width: 2.2em; }
.date__prec { flex: 1 1 100%; min-width: 0; } /* あいまいさは次の行に（せまいパネルでも全部読めるように） */
.date__md-row { display: flex; align-items: center; gap: 4px; font-size: var(--fs-s); color: var(--c-sub); }
.date__md-row[hidden] { display: none; }
.date__md-label { margin-right: 4px; }
.date__md { width: 48px; min-height: 36px; text-align: right; }
.range-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-left: 30px; }
.range-row[hidden] { display: none; }
.range-row.is-disabled { opacity: .6; }

/* ジャンルを選ぶ（チップ） */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-pill);
  background: var(--c-white);
  font-size: var(--fs-s);
  cursor: pointer;
}
.chip[aria-checked="true"] { border: 2px solid var(--c-ink); padding: 0 11px; font-weight: 700; }
.chip--add { border-style: dashed; color: var(--c-sub); }

/* 年表の設定：見出し・ジャンルの行 */
.headings { display: flex; flex-direction: column; gap: 6px; }
.heading-row { display: flex; align-items: center; gap: 6px; }
.heading-row .field__input:nth-child(2) { flex: 1; min-width: 0; }
.genre-list { display: flex; flex-direction: column; gap: 8px; }
.genre-row { display: flex; align-items: center; gap: 8px; background: var(--c-white); border-radius: var(--r-m); }
.genre-row.is-dragging { position: relative; z-index: 2; box-shadow: var(--shadow-pop); }
.genre-row .field__input { flex: 1; min-width: 0; }
.drag-handle {
  width: 32px;
  height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--c-disabled);
  cursor: grab;
  touch-action: none;
}
.color-btn {
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-border);
  border-radius: var(--r-m);
  cursor: pointer;
}
.color-option { display: inline-flex; align-items: center; gap: 10px; }
.menu-anchor { position: fixed; width: 1px; height: 1px; }

/* ⑭ 項目の一覧 */
.item-list { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 16px 24px; overflow: hidden; }
.item-list__tools { display: flex; align-items: center; gap: 12px; }
.item-list__scroll { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--c-border); border-radius: var(--r-l) var(--r-l) 0 0; background: var(--c-white); }
.item-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.item-table th, .item-table td { height: var(--tap); padding: 0 12px; border-bottom: 1px solid var(--c-divider); text-align: left; }
.item-table thead th { position: sticky; top: 0; z-index: 1; background: var(--c-surface-subtle); border-bottom-color: var(--c-border); font-weight: 700; }
.th-sort { min-height: var(--tap); display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: transparent; font-weight: 700; cursor: pointer; }
.th-sort__mark { font-size: var(--fs-xs); }
.item-table tbody tr { cursor: pointer; }
.item-table tbody tr:hover { background: var(--c-surface-subtle); }
.item-table tbody tr.is-selected td { background: var(--c-surface-header); }
.item-table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--c-ink); }
.item-table tbody tr:focus-visible { outline-offset: -3px; }
.col-color { width: 44px; }
.col-name { font-weight: 700; }
.col-date { width: 150px; }
.col-genre { width: 170px; }
.col-memo { width: 120px; color: var(--c-sub); }
.memo-yes { display: inline-flex; align-items: center; gap: 4px; }
.item-table__empty { padding: 16px; color: var(--c-sub); }
.item-table__empty:empty { display: none; }
.item-list__hint { font-size: var(--fs-s); color: var(--c-sub); }

@media (max-width: 1000px) {
  .editor-aside.is-open { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; width: min(380px, 100%); }
  .editor-main { position: relative; }
}

/* 長さを変えるつまみ（イラストレーターのハンドルのように、選んだ期間の両端に出す） */
.tl-handle { cursor: ew-resize; }
.tl-handle:hover .tl-handle__box { fill: var(--c-ink); }
.tl-canvas .tl-item { cursor: move; }

/* ヘッダーの右側のまとまり。画面がせまい時は2行にする */
.editor-header__tools { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
@media (max-width: 960px) {
  .editor-header { height: auto; min-height: 56px; flex-wrap: wrap; row-gap: 4px; padding: 6px 16px; }
  .editor-header > .spacer { display: none; }
  .editor-title-wrap, .editor-title { flex: 1; }
  .editor-header__tools { width: 100%; justify-content: flex-end; }
}
