/* HAMONI Routine の画面。image-assistant (hamoni-image-assistant) に寄せる (2026-11-19):
   ライトテーマ固定・システムの書体・左に 220px の灰色のサイドバー・角丸のメニュー・青のボタン。
   900px より狭い画面ではサイドバーを出さず、上に名前とタブを出す。
   フローの編集は Zapier・Power Automate のように、きっかけとステップのカードを縦につなげて見せる。 */
:root {
  --text: #1d1d1f;
  --muted: #71717a;
  --line: #e6e6e6;
  --field-line: #d4d4d8;
  --side-line: rgba(60, 60, 67, .18);
  --side-bg: #f4f4f4;
  --blue: #0071e3;
  --blue-hover: #005bb5;
  --blue-soft: #e8f1fd;
  --red: #dc2626;
  --red-soft: #fdecec;
  --green: #1a7f37;
  --green-soft: #e6f4ea;
  --amber: #a15c00;
  --amber-soft: #fdf3e1;
  --bubble-in: #f2f2f5;
  --switch-on: #34c759;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; background: #fff; color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
pre { margin: 0; }
.spacer { flex: 1; }

/* ── ボタン ── */
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 8px; white-space: nowrap; font-weight: 600;
}
.primary { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.secondary { border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 500; }
.secondary:hover { background: #f5f5f7; }
.primary:disabled, .secondary:disabled { opacity: .45; cursor: default; }
.text-button { border: 0; background: none; padding: 0; color: var(--blue); }
.text-button:hover { text-decoration: underline; }
.danger-text { border: 0; background: none; padding: 0; color: var(--red); font-weight: 600; }
.danger-text:hover { text-decoration: underline; }
.icon-button { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.icon-button:hover { background: #f0f0f3; color: var(--text); }
.hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.error { margin: 0; color: var(--red); font-size: 13px; }

/* ── ログイン前 ── */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--side-bg); }
.login-card {
  width: min(400px, 100%); display: flex; flex-direction: column; align-items: flex-start; gap: 16px;
  padding: 28px 24px; background: #fff; border: 1px solid var(--line); border-radius: 16px;
}
.login-card p { margin: 0; color: var(--muted); line-height: 1.7; }
.signin { display: block; border-radius: 12px; }
.signin img { display: block; max-width: 100%; height: auto; }
.signin:hover img { filter: brightness(.97); }

/* ── 外枠とサイドバー (image-assistant の AppShell と同じ寸法) ── */
.brand { font-size: 18px; font-weight: 800; letter-spacing: .02em; line-height: 1.2; }
.brand small { display: block; font-size: 11px; font-weight: 600; color: rgba(60, 60, 67, .6); letter-spacing: 0; }
.shell { display: flex; min-height: 100dvh; }
.main { flex: 1; min-width: 0; }
.sidebar { display: none; }
@media (min-width: 900px) {
  .sidebar {
    position: sticky; top: 0; display: flex; flex-direction: column; gap: 14px; flex-shrink: 0;
    width: 220px; height: 100dvh; padding: 16px; overflow-y: auto;
    background: var(--side-bg); border-right: 1px solid var(--side-line); color: #000; font-size: 14px; line-height: 19px;
  }
}
.group { display: flex; flex-direction: column; gap: 2px; }
.item {
  display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none;
  color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item:hover { background: rgba(0, 0, 0, .05); }
.item.active { background: #e3e3ea; font-weight: 700; }
.me { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--side-line); }
.me-name { padding: 0 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { padding: 0 12px 6px; font-size: 12px; color: rgba(60, 60, 67, .6); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fff;
}
.tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 2; }
.tabs a { flex: 1; padding: 8px 6px; border-radius: 8px; color: var(--muted); text-align: center; font-weight: 600; white-space: nowrap; }
.tabs a.active { background: #e3e3ea; color: var(--text); }
@media (min-width: 900px) {
  .topbar, .tabs { display: none; }
}

/* ── 中身 ── */
.content { max-width: 880px; margin: 0 auto; padding: 32px 32px 80px; }
@media (max-width: 640px) { .content { padding: 20px 16px 64px; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; letter-spacing: .01em; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; align-items: center; gap: 12px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; font-size: 13px; }
.notice { margin-bottom: 16px; padding: 10px 14px; border-radius: 10px; background: var(--blue-soft); }
.notice.bad { background: var(--red-soft); color: #8a1c1c; }

.empty {
  display: grid; justify-items: center; gap: 10px; padding: 40px 16px; text-align: center;
  border: 1px dashed var(--field-line); border-radius: 12px; color: var(--muted);
}
.empty b { color: var(--text); font-size: 15px; }

/* アプリのしるし (アイコンの四角) */
.app-mark { display: grid; place-items: center; flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; }
.app-mark.schedule { background: #fff4e5; color: #b45309; }
.app-mark.google { background: #e8f5ee; color: #188038; }
.app-mark.http { background: #eef0ff; color: #4f46e5; }
.app-mark.big { width: 40px; height: 40px; border-radius: 10px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.succeeded { background: var(--green-soft); color: var(--green); }
.chip.waiting, .chip.running, .chip.pending { background: var(--amber-soft); color: var(--amber); }
.chip.failed { background: var(--red-soft); color: var(--red); }
.chip.skipped { background: #f0f0f3; color: var(--muted); }

/* ── フローの一覧 ── */
.flows { display: grid; gap: 14px; }
.flow { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.flow.off { background: #fafafa; }
.flow-head { display: flex; align-items: flex-start; gap: 12px; }
.flow-title { flex: 1; min-width: 0; display: grid; gap: 4px; }
.flow-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.flow-when { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.flow-ops { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chain .node { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; background: #fff; }
.chain .node .app-mark { width: 22px; height: 22px; border-radius: 99px; }
.chain .arrow { color: #a1a1aa; }
.flow-foot { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--line); }
.flow-foot .next { color: var(--blue); font-weight: 600; }
.flow.off .flow-foot .next { color: var(--muted); }
.flow-foot .spacer { flex: 1; }

.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { position: relative; width: 40px; height: 24px; border-radius: 99px; background: var(--field-line); transition: background .15s; }
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--switch-on); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ── フローの編集: カードを縦につなぐ ── */
.name-input { font-size: 18px !important; font-weight: 700; min-height: 46px !important; }
.steps { display: grid; justify-items: center; margin-top: 20px; }
.connector { width: 2px; height: 22px; background: #d4d4d8; }
.step-card { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.step-card.trigger { border-top: 3px solid #f59e0b; }
.step-card.action { border-top: 3px solid var(--blue); }
.step-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line); }
.step-no { display: grid; place-items: center; flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: #f0f0f3; color: var(--muted); font-size: 12px; font-weight: 700; }
.step-title { flex: 1; min-width: 0; display: grid; }
.step-title b { font-size: 14px; }
.step-title span { color: var(--muted); font-size: 12px; }
.step-body { display: grid; gap: 16px; padding: 16px; }
.add-step { margin-top: 0; }
.picker { width: 100%; display: grid; gap: 14px; padding: 16px; border: 1px dashed var(--field-line); border-radius: 12px; background: #fafafa; }
.picker-group { display: grid; gap: 8px; }
.picker-group > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.picker-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.pick { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; }
.pick:hover { border-color: var(--blue); }
.pick b { display: block; font-size: 14px; }
.pick span { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; }
.editor-foot { display: flex; align-items: center; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.editor-foot .spacer { flex: 1; }

.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.label { padding: 0; font-size: 12px; font-weight: 600; color: var(--muted); }
legend.label { margin-bottom: 6px; }
input:not([type=checkbox]), textarea, select {
  width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--field-line); border-radius: 8px; background: #fff;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, .15); }
input[type=time], input[type=number] { width: auto; min-width: 110px; }
textarea { resize: vertical; line-height: 1.6; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row > input[type=email] { flex: 1; min-width: 200px; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.seg { justify-self: start; display: inline-flex; padding: 2px; border-radius: 9px; background: #ececf0; }
.seg button { border: 0; border-radius: 7px; background: none; padding: 5px 16px; color: var(--muted); font-size: 13px; font-weight: 600; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.picked { margin: 0; min-height: 1.2em; color: var(--green); font-size: 13px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--field-line); background: #fff; font-weight: 600; }
.days button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
/* 差し込みのボタン: 入力中の欄の下にだけ出す (全部の欄に出すと うるさい) */
.field .vars { display: none; }
.field:focus-within .vars { display: flex; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vars > span { font-size: 12px; color: var(--muted); }
.var { border: 1px solid #c7d7f5; border-radius: 6px; background: var(--blue-soft); color: #1d4f99; padding: 1px 8px; font-size: 12px; }
.var:hover { border-color: var(--blue); }

/* ── 実行履歴 ── */
.filter { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 4px 6px 4px 12px; border-radius: 99px; background: #f0f0f3; font-size: 13px; }
.runs { display: grid; gap: 14px; }
.run { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.run-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: #fafafa; border-bottom: 1px solid var(--line); }
.run-head b { font-size: 14px; }
.run-head time { color: var(--muted); font-size: 13px; }
.run-head .spacer { flex: 1; }
.run-steps { display: grid; }
.run-step { display: grid; grid-template-columns: 28px 1fr; gap: 4px 12px; padding: 12px 16px; }
.run-step + .run-step { border-top: 1px solid #f0f0f3; }
.run-step .app-mark { grid-row: span 2; }
.run-step-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 28px; }
.run-step-line b { font-size: 13px; }
.run-step-line .when { color: var(--muted); font-size: 12px; }
.run-step-out { display: grid; gap: 6px; min-width: 0; }
.run-error { color: var(--red); font-size: 12px; overflow-wrap: anywhere; }
.run-none { color: var(--muted); font-size: 12px; }
.bubble { max-width: min(560px, 92%); padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; }
.bubble.out { justify-self: start; background: var(--blue-soft); border-bottom-left-radius: 4px; }
.bubble.in { justify-self: start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.bubble time { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.code { padding: 8px 10px; border-radius: 8px; background: #f6f6f8; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.more { justify-self: center; margin-top: 4px; }

/* ── 外部連携 ── */
.services { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.service { display: flex; align-items: center; gap: 14px; padding: 16px; flex-wrap: wrap; }
.service + .service { border-top: 1px solid var(--line); }
.svc-text { flex: 1; min-width: 180px; display: grid; gap: 2px; }
.svc-name { font-weight: 700; font-size: 15px; }
.svc-state { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.svc-state.ok { color: var(--green); }
.svc-error { color: var(--red); font-size: 13px; }
.svc-ops { display: flex; gap: 8px; }
.services-foot { margin: 10px 4px 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

@media (max-width: 520px) {
  .flow-head { flex-direction: column; }
  .flow-ops { width: 100%; justify-content: space-between; }
  .page-head .primary { width: 100%; }
}
