:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a66;
  --line: #e3e1db;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --accent-soft: #e3f1ec;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --danger: #b3261e;
  --danger-soft: #fbe5e3;
  --quote: #f1efe9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --card: #20201e;
    --text: #ecebe7;
    --muted: #a3a19b;
    --line: #34332f;
    --accent: #5cc0a4;
    --accent-text: #0d1f1a;
    --accent-soft: #1d3530;
    --warn: #e6b45c;
    --warn-soft: #3a2f1c;
    --danger: #f2827a;
    --danger-soft: #3d2220;
    --quote: #2a2a27;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

main { max-width: 760px; margin: 0 auto; padding: 20px 16px 64px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.intro { display: grid; gap: 12px; justify-items: start; margin-top: 24px; }
.intro p { margin: 0; }

.notice {
  margin-bottom: 16px; padding: 10px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text);
}
.notice.bad { background: var(--danger-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

.google { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.google .state { display: grid; gap: 2px; }
.google .label { font-weight: 600; }
.google .err { color: var(--danger); font-size: 13px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 12px; }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; }

.routine { display: grid; gap: 10px; margin-bottom: 12px; }
.routine.off { opacity: .7; }
.routine .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.routine .title { font-weight: 700; font-size: 16px; }
.routine .meta { color: var(--muted); font-size: 13px; }
.routine .next { font-size: 13px; }
.routine .msg {
  margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--quote); font-family: inherit;
  white-space: pre-wrap; word-break: break-word; font-size: 14px;
}
.routine .ops { display: flex; gap: 8px; flex-wrap: wrap; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.on { background: var(--accent-soft); color: var(--accent); }
.pill.off { background: var(--quote); color: var(--muted); }
.pill.sent { background: var(--accent-soft); color: var(--accent); }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.failed { background: var(--danger-soft); color: var(--danger); }

.runs { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 8px; }
.runs .caption { font-size: 12px; color: var(--muted); }
.run { display: grid; gap: 4px; }
.run .line { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.run .err { color: var(--danger); font-size: 12px; }
.run .reply {
  margin: 0 0 0 4px; padding: 6px 10px; border-left: 3px solid var(--accent);
  white-space: pre-wrap; word-break: break-word; font-size: 14px;
}
.run .reply time { display: block; color: var(--muted); font-size: 11px; }
.run .noreply { color: var(--muted); font-size: 12px; }

dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  border: 1px solid var(--line); border-radius: 14px; padding: 0;
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { display: grid; gap: 16px; padding: 20px; }

.field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 6px; }
input[type=text], input:not([type]), input[type=email], input[type=time], textarea, select {
  width: 100%; min-height: 38px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
input[type=time] { width: auto; }
textarea { resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input[type=email] { flex: 1; min-width: 200px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

.seg { display: inline-flex; justify-self: start; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.seg button { border: 0; background: var(--card); color: var(--muted); padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.dest-picked { margin: 4px 0 0; font-size: 13px; color: var(--accent); min-height: 1em; }

.days { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.days button {
  width: 40px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer;
}
.days button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

.error { margin: 0; color: var(--danger); font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 480px) {
  .routine .head { flex-direction: column; }
  .who #who-name { display: none; }
}
