/* AIで工程表を作成（体験版）。色は common/base.css のトークンだけを使う */
.as { max-width: 1280px; margin: 0 auto; padding: 20px var(--gutter) 56px; }

/* 作業の流れ（1→2→3） */
.as-steps { display: flex; align-items: center; gap: 10px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; margin: 0 auto 22px; box-shadow: var(--shadow-s); }
.as-steps button { display: flex; align-items: center; gap: 8px; padding: 7px 16px 7px 8px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.as-steps button:disabled { cursor: default; opacity: .55; }
.as-steps button:not(:disabled):hover { background: var(--sunken); color: var(--ink); }
.as-steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); font-size: 13px; }
.as-steps button[aria-current="step"] { background: var(--brand); color: #fff; }
.as-steps button[aria-current="step"] .n { background: var(--accent); color: #fff; }
.as-steps button.done .n { background: var(--ok-soft); color: var(--ok); }
.as-steps-line { width: 22px; height: 2px; background: var(--line-2); flex: none; }

.scr-head { max-width: 800px; margin-bottom: 18px; }
.scr-head h2 { font-size: 24px; font-weight: 800; line-height: 1.4; }
.scr-lead { margin-top: 6px; color: var(--ink-2); line-height: 1.85; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px; min-width: 0; box-shadow: var(--shadow-s); }
.panel h3 { font-size: 16px; font-weight: 800; line-height: 1.5; }
.panel h4 { font-size: 14px; font-weight: 800; margin-bottom: 6px; }
input, select { font-size: 16px; }

/* 1. 依頼を選ぶ */
.case-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.case-card { text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-m); padding: 14px 16px; display: grid; gap: 4px; transition: border-color .15s, box-shadow .15s; }
.case-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-s); }
.case-card[aria-pressed="true"] { border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-soft); }
.case-card .cc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.case-card .cc-client { font-size: 12.5px; color: var(--ink-3); }
.case-card .cc-title { font-size: 15.5px; font-weight: 800; line-height: 1.5; }
.case-card .cc-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.case-card .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; }
.case-card[aria-pressed="true"] .radio { border-color: var(--brand); }
.case-card[aria-pressed="true"] .radio::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.pick-grid { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 14px; align-items: start; }
.req-text { margin-top: 8px; white-space: pre-line; line-height: 1.85; font-size: 14.5px; color: var(--ink); background: var(--paper); border-radius: var(--r-m); padding: 12px 14px; border-left: 3px solid var(--line-2); }
.req-warn { margin-top: 10px; padding: 9px 12px; border-radius: var(--r-s); background: var(--warn-soft); color: var(--warn); font-size: 13px; line-height: 1.7; font-weight: 600; }
.cond { margin: 8px 0 0; display: grid; gap: 10px; font-size: 14px; }
.cond dt { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.cond dd { margin: 1px 0 0; color: var(--ink); line-height: 1.7; }
.cond ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cond .role { color: var(--ink-3); font-size: 12.5px; }
.pick-foot {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 16px; margin: 20px calc(var(--gutter) * -1) 0; padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  background: rgba(246, 244, 238, .94); backdrop-filter: blur(6px); border-top: 1px solid var(--line);
}
.pick-note { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; flex: 1; }
.btn-big { min-height: 50px; padding: 0 26px; font-size: 16px; border-radius: 12px; }

/* 作っている間 */
.making { position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; background: rgba(22, 36, 44, .45); padding: 16px; }
.making-card { width: min(400px, 100%); background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-l); padding: 22px 24px 20px; }
.making-title { font-weight: 800; font-size: 17px; }
.making-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.making-steps li { display: flex; align-items: center; gap: 10px; color: var(--ink-3); }
.making-steps li i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; }
.making-steps li.now { color: var(--ink); font-weight: 700; }
.making-steps li.now i { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.making-steps li.done { color: var(--ink-2); }
.making-steps li.done i { border-color: var(--ok); background: var(--ok); }
.making-steps li.done i::after { content: ''; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
@keyframes spin { to { transform: rotate(360deg); } }
.making-bar { height: 6px; border-radius: 3px; background: var(--sunken); margin-top: 16px; overflow: hidden; }
.making-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }
.making-note { margin-top: 10px; font-size: 12px; color: var(--ink-3); line-height: 1.6; }

/* 2. 確かめて直す */
.rv-top { display: flex; align-items: stretch; gap: 12px; margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; flex: 1; min-width: 0; }
.tile { padding: 10px 14px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-s); min-width: 0; }
.tile b { display: block; font-size: 26px; line-height: 1.25; font-weight: 800; }
.tile b small { font-size: 14px; font-weight: 700; margin-left: 2px; }
.tile span { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.tile.ok b { color: var(--ok); } .tile.warn b { color: var(--warn); } .tile.bad b { color: var(--bad); } .tile.none b { color: var(--ink-3); }
.rv-top .btn { align-self: center; flex: none; }
.rv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.side { display: grid; gap: 16px; min-width: 0; }

.gantt-panel { padding: 14px 0 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 16px 10px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.lgms { width: 10px; height: 10px; border-radius: 2px; transform: rotate(45deg); background: var(--brand); }
.legend i.dl { background: var(--bad-soft); border-left: 2px solid var(--bad); width: 10px; }
.legend i.off { background: var(--sunken); border: 1px solid var(--line-2); }
.gantt-scroll { overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.gantt { --lab: 214px; --rh: 30px; --w: 10px; position: relative; width: calc(var(--lab) + var(--cw)); min-width: 100%; }
.g-head, .g-row { display: flex; position: relative; z-index: 1; }
.g-head { height: 40px; }
.g-row { height: var(--rh); border-top: 1px solid var(--line); cursor: pointer; }
.g-lab { position: sticky; left: 0; z-index: 4; flex: none; width: var(--lab); background: var(--surface); border-right: 1px solid var(--line-2); display: flex; align-items: center; gap: 6px; padding: 0 8px; min-width: 0; }
.g-head .g-lab { font-size: 12px; color: var(--ink-3); font-weight: 700; border-top: 0; }
.g-row:hover .g-lab { background: var(--sunken); }
.g-row.sel .g-lab { background: var(--accent-soft); }
.g-row.sel { outline: 2px solid var(--accent); outline-offset: -2px; z-index: 3; }
.g-lab .id { font-size: 11.5px; font-weight: 800; color: var(--brand-2); flex: none; min-width: 24px; }
.g-lab .nm { font-size: 12.5px; line-height: 1.3; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.g-lab .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.g-lab .dot.err { background: var(--bad); }
.g-lab .dot.warn { background: var(--accent); }
.g-lab .ed { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-2); flex: none; line-height: 16px; }
.g-cal { position: relative; flex: none; width: var(--cw); }
.g-bg { position: absolute; left: var(--lab); top: 0; bottom: 0; width: var(--cw); z-index: 0; pointer-events: none; }
.g-bg .off { position: absolute; top: 0; bottom: 0; background: var(--sunken); }
.g-bg .wk { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--line); }
.g-bg .dl { position: absolute; top: 0; bottom: 0; background: var(--bad-soft); border-left: 2px solid var(--bad); }
.g-head .mo { position: absolute; top: 3px; height: 18px; font-size: 11px; font-weight: 800; color: var(--ink-2); padding-left: 4px; border-left: 1px solid var(--line-2); line-height: 18px; white-space: nowrap; }
.g-head .mon { position: absolute; top: 22px; font-size: 10px; color: var(--ink-3); line-height: 16px; padding-left: 1px; white-space: nowrap; }
.g-head .dl-tag { position: absolute; top: 21px; font-size: 10px; font-weight: 800; color: #fff; background: var(--bad); border-radius: 3px; padding: 0 4px; line-height: 16px; white-space: nowrap; z-index: 2; }
.seg { position: absolute; top: 7px; bottom: 7px; border-radius: 4px; background: var(--bc, var(--c1)); z-index: 1; }
.seg.err { box-shadow: 0 0 0 2px var(--bad); }
.seg.warn { box-shadow: 0 0 0 2px var(--accent); }
.link { position: absolute; top: 50%; height: 2px; margin-top: -1px; background: var(--bc, var(--c1)); opacity: .4; z-index: 1; }
.ms { position: absolute; top: 50%; width: 13px; height: 13px; margin: -6px 0 0; background: var(--brand); border-radius: 2px; transform: rotate(45deg); z-index: 1; }
.ms.err { box-shadow: 0 0 0 2px var(--bad); }
.ms.warn { box-shadow: 0 0 0 2px var(--accent); }
.leave { position: absolute; top: 2px; bottom: 2px; background: repeating-linear-gradient(135deg, var(--bad) 0 1.5px, transparent 1.5px 4px); opacity: .55; z-index: 2; }
.nodate { position: absolute; left: 8px; top: 7px; font-size: 11.5px; color: var(--ink-3); }
.hint { padding: 8px 16px 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }

.issues { list-style: none; margin: 10px 0 0; display: grid; gap: 8px; }
.issues li { border-radius: var(--r-m); padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; font-size: 13px; line-height: 1.65; background: var(--surface); }
.issues li.error { border-left-color: var(--bad); background: var(--bad-soft); }
.issues li.warn { border-left-color: var(--accent); background: var(--warn-soft); }
.issues li.none { border-left-color: var(--ok); background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.issues .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.issues .rule { font-weight: 800; font-size: 13.5px; }
.issues .msg { color: var(--ink); }
.issues .fix { margin-top: 4px; color: var(--ink-2); font-size: 12.5px; }
.issues .gos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.issues .gos .btn { min-height: 32px; padding: 0 10px; font-size: 13px; }
.issues li.hit { box-shadow: 0 0 0 2px var(--accent); }

.ed-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ed-title { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.ed-id { font-size: 13px; font-weight: 800; color: #fff; background: var(--brand-2); border-radius: 5px; padding: 0 7px; flex: none; line-height: 22px; }
.ed-title h3 { font-size: 15px; line-height: 1.5; min-width: 0; }
.ed-nav { display: flex; gap: 6px; flex: none; }
.ed-memo { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.ed-lead { margin-top: 8px; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; padding: 7px 10px; background: var(--accent-soft); border-radius: var(--r-s); }
.ed-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; margin-top: 12px; }
.ed-form .f { display: grid; gap: 3px; min-width: 0; align-content: start; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.ed-form .f:nth-child(n+3) { grid-column: 1 / -1; }
.ed-form .f:nth-child(3) { grid-column: 1; }
.ed-form input, .ed-form select { width: 100%; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); color: var(--ink); font-weight: 500; }
.ed-form small { font-size: 11.5px; font-weight: 500; color: var(--ink-3); line-height: 1.5; }
.fixed-row { display: flex; gap: 8px; }
.fixed-row input { flex: 1; }
.fixed-row .btn { height: 40px; flex: none; }
.ed-form .f.edited input, .ed-form .f.edited select { background: var(--accent-soft); border-color: var(--accent); }
.ed-result { display: grid; gap: 6px; margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); }
.ed-result div { display: flex; gap: 10px; align-items: baseline; }
.ed-result dt { font-size: 12px; font-weight: 700; color: var(--ink-3); width: 78px; flex: none; }
.ed-result dd { margin: 0; font-size: 14px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 4px; }
.live { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--ink-2); padding: 8px 10px; border-radius: var(--r-s); background: var(--sunken); line-height: 1.6; }
.live.better { background: var(--ok-soft); color: var(--ok); }
.live.worse { background: var(--bad-soft); color: var(--bad); }

.ai-box { margin-top: 16px; }
.ai-head p { margin-top: 4px; font-size: 13.5px; color: var(--ink-2); line-height: 1.8; }
.ai-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 14px; }
.ass { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.8; color: var(--ink); }
.log { width: 100%; border-collapse: collapse; font-size: 13px; }
.log th { text-align: left; font-size: 12px; color: var(--ink-3); padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line-2); }
.log td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.ai-meta { margin-top: 6px; font-size: 12px; color: var(--ink-3); line-height: 1.6; }
.ai-note { margin-top: 12px; padding: 10px 12px; border-radius: var(--r-m); font-size: 13px; line-height: 1.75; }
.ai-note b { display: block; margin-bottom: 2px; }
.ai-note.repair { background: var(--sunken); color: var(--ink-2); }
.ai-note.susp { background: var(--warn-soft); color: var(--warn); }
.rv-foot { display: flex; justify-content: flex-end; margin-top: 18px; }

/* 3. Excelにまとめる */
.ex-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px; box-shadow: var(--shadow-s); }
.ex-box .tile { box-shadow: none; background: var(--paper); }
.ex-edited { margin-top: 12px; font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.ex-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.ex-note { margin-top: 12px; font-size: 12.5px; color: var(--ink-3); line-height: 1.8; }
.ex-grid { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 16px; margin-top: 18px; align-items: start; }
.sheets { margin: 8px 0 0; display: grid; gap: 10px; }
.sheets dt { font-weight: 800; font-size: 13.5px; }
.sheets dd { margin: 1px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.table-wrap { margin-top: 10px; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); max-height: 460px; overflow-y: auto; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.table-wrap th { position: sticky; top: 0; background: var(--brand); color: #fff; font-weight: 700; text-align: left; padding: 7px 9px; white-space: nowrap; }
.table-wrap td { padding: 6px 9px; border-top: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.table-wrap td.r { text-align: right; }
.table-wrap tr.y td { background: var(--warn-soft); }

@media (max-width: 980px) {
  .rv-grid { grid-template-columns: minmax(0, 1fr); }
  .pick-grid, .ai-grid, .ex-grid { grid-template-columns: minmax(0, 1fr); }
  .case-cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .as { padding-top: 14px; }
  .as-steps { gap: 4px; padding: 4px; margin-bottom: 16px; width: 100%; justify-content: space-between; }
  .as-steps button { padding: 6px 8px 6px 6px; font-size: 12.5px; gap: 5px; min-width: 0; }
  .as-steps .n { width: 22px; height: 22px; font-size: 12px; }
  .as-steps-line { width: 6px; }
  .scr-head h2 { font-size: 20px; }
  .panel { padding: 14px; }
  .gantt-panel { padding: 12px 0 10px; }
  .panel-head { padding: 0 14px 8px; }
  .gantt { --lab: 118px; --rh: 34px; }
  .g-lab { padding: 0 6px; gap: 4px; }
  .g-lab .id { font-size: 10.5px; min-width: 22px; }
  .g-lab .nm { font-size: 11.5px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
  .g-lab .ed { display: none; }
  .hint { padding: 8px 14px 0; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 8px 12px; }
  .tile b { font-size: 22px; }
  .rv-top { flex-direction: column; align-items: stretch; gap: 10px; }
  .rv-top .btn { width: 100%; }
  .pick-foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .pick-foot .btn { width: 100%; }
  .pick-note { font-size: 12px; }
  .ed-form { grid-template-columns: 1fr 1fr; }
  .rv-foot .btn { width: 100%; }
  .ex-box { padding: 16px; }
  .ex-btns .btn { width: 100%; }
}

/* 固定開始日：打っても、カレンダーから選んでもよい */
.pick-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; height: 40px; cursor: pointer; overflow: hidden; }
.pick-wrap input[type="date"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
#fixedMsg { display: block; margin-top: 4px; font-weight: 600; }
#fixedMsg.bad { color: var(--bad); }
#fixedMsg.ok { color: var(--ok); }
#fixedMsg:empty { display: none; }
.live-dep { margin-top: 8px; padding: 8px 12px; border-radius: var(--r-s); background: var(--warn-soft); border-left: 4px solid var(--warn); font-size: 13px; line-height: 1.65; font-weight: 600; }
.live-dep[hidden] { display: none; }
@media (max-width: 640px) {
  .fixed-row { flex-wrap: wrap; }
  .fixed-row #ed-fixed { flex: 1 1 100%; min-width: 0; }
  .fixed-row .pick-wrap, .fixed-row #ed-clear { flex: 1 1 0; }
}
