/* ============================================================
   モノクロ。電子契約 — スタイル（タスクボードの基本部品を流用）
   基調はグレースケール。色は「緊急度」の表現にだけ使う。
   ============================================================ */

:root {
  --ink-0: #ffffff;
  --ink-1: #fafafa;
  --ink-2: #f2f2f2;
  --ink-3: #e6e6e6;
  --ink-4: #d4d4d4;
  --ink-5: #a3a3a3;
  --ink-6: #737373;
  --ink-7: #4a4a4a;
  --ink-8: #262626;
  --ink-9: #111111;

  --bg: var(--ink-1);
  --surface: var(--ink-0);
  --surface-2: var(--ink-2);
  --border: var(--ink-3);
  --border-strong: var(--ink-4);
  --text: var(--ink-9);
  --text-muted: var(--ink-6);
  --text-faint: var(--ink-5);

  --alert: #c0392b;
  --alert-bg: #fdeceb;
  --warn: #a86b00;
  --warn-bg: #fdf3e0;
  --ok: #2f6f4f;
  --ok-bg: #ecf5f0;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.18);

  --header-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1b1b1b;
    --surface-2: #232323;
    --border: #2e2e2e;
    --border-strong: #3d3d3d;
    --text: #f2f2f2;
    --text-muted: #a0a0a0;
    --text-faint: #7a7a7a;

    --alert: #ef7d70;
    --alert-bg: #3a1f1c;
    --warn: #e0a349;
    --warn-bg: #382c17;
    --ok: #7fc0a0;
    --ok-bg: #1c2f26;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.7);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ---------- ローディング ---------- */
.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  color: var(--text-faint);
  letter-spacing: 0.3em;
  font-size: 12px;
}

/* ============================================================
   ログイン画面
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
}

.login-art {
  position: relative;
  background: var(--ink-9);
  color: var(--ink-0);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.login-art::after {
  content: "";
  position: absolute;
  right: -140px;
  bottom: -160px;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 0 0 60px rgba(255, 255, 255, 0.035);
}

.login-art .brand {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.login-art .tagline {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.login-art .tagline h2 {
  font-size: 26px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.login-art .tagline p {
  color: rgba(255, 255, 255, 0.62);
  margin: 0;
}

.login-art .foot {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 40px 24px;
}

.login-box {
  width: 100%;
  max-width: 360px;
}

.login-box h1 {
  font-size: 22px;
  margin-bottom: 6px;
}

.login-box .sub {
  color: var(--text-muted);
  margin: 0 0 26px;
  font-size: 13px;
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius);
  margin-bottom: 22px;
}

.login-tabs button {
  border: 0;
  background: transparent;
  padding: 9px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: 0.15s;
}

.login-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}


/* Discordログインのボタン。ブランドカラーはここでしか使わない */
.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #5865f2;
  color: #fff;
  border: none;
  text-decoration: none;
  padding: 13px 18px;
  font-weight: 600;
  font-size: 15px;
}

.btn-discord:hover {
  background: #4752c4;
  color: #fff;
}

.btn-discord svg {
  flex: none;
}

/* コールバックが弾かれた理由を出す。理由が分からないと再試行しかできない */
.login-box .form-error {
  margin-bottom: 18px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #c0392b 12%, transparent);
  border: 1px solid color-mix(in srgb, #c0392b 45%, transparent);
  color: #c0392b;
  font-size: 13px;
  line-height: 1.7;
}

.login-hint {
  margin-top: 22px;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.8;
}

.login-hint code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}

@media (max-width: 860px) {
  .login-page {
    grid-template-columns: 1fr;
  }
  .login-art {
    padding: 32px;
    gap: 28px;
  }
  .login-art .tagline h2 {
    font-size: 20px;
  }
}


/* ============================================================
   フォーム部品
   ============================================================ */
.field {
  margin-bottom: 16px;
}

.field > label,
.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.label .req {
  color: var(--alert);
  margin-left: 4px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(128, 128, 128, 0.18);
}

textarea {
  resize: vertical;
  min-height: 76px;
  line-height: 1.7;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 5px;
}

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.15s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--text-faint);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ink-9);
  border-color: var(--ink-9);
  color: var(--ink-0);
}

.btn-primary:hover:not(:disabled) {
  background: var(--ink-8);
  border-color: var(--ink-8);
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    background: var(--ink-0);
    border-color: var(--ink-0);
    color: var(--ink-9);
  }
  .btn-primary:hover:not(:disabled) {
    background: var(--ink-3);
    border-color: var(--ink-3);
  }
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  color: var(--alert);
  border-color: var(--border-strong);
}

.btn-danger:hover:not(:disabled) {
  background: var(--alert-bg);
  border-color: var(--alert);
}

/* ---------- アラート ---------- */
.alert {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert-error {
  background: var(--alert-bg);
  border-color: var(--alert);
  color: var(--alert);
}

.alert-ok {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}


/* ============================================================
   アプリ全体レイアウト
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header a.logo { color: inherit; }
.app-header .logo {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.app-header .logo small {
  display: block;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-top: -3px;
}

.app-nav {
  display: flex;
  gap: 2px;
  margin-left: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.app-nav::-webkit-scrollbar {
  display: none;
}

.app-nav a {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: 0.15s;
}

.app-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.app-nav a.active {
  background: var(--ink-9);
  color: var(--ink-0);
}

@media (prefers-color-scheme: dark) {
  .app-nav a.active {
    background: var(--ink-0);
    color: var(--ink-9);
  }
}

.app-nav .badge {
  display: inline-block;
  min-width: 17px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--alert);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  line-height: 17px;
}

.user-menu {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  cursor: pointer;
}

.user-btn:hover {
  background: var(--surface-2);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink-9);
  color: var(--ink-0);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}

@media (prefers-color-scheme: dark) {
  .avatar {
    background: var(--ink-3);
    color: var(--ink-9);
  }
}

.user-btn .who {
  text-align: left;
  line-height: 1.25;
}

.user-btn .who b {
  display: block;
  font-size: 12.5px;
}

.user-btn .who span {
  font-size: 10.5px;
  color: var(--text-faint);
}

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 50;
}

.dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}

.dropdown button:hover {
  background: var(--surface-2);
}

.dropdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 5px 0;
}

.app-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 21px;
}

.page-head .desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 3px;
}


/* ============================================================
   カード / セクション
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.section {
  margin-bottom: 30px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
}

.section-title .count {
  padding: 1px 8px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}


/* ---------- バッジ ---------- */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  background: var(--surface);
  white-space: nowrap;
}

.badge-pill.status-todo {
  border-color: var(--border-strong);
}
.badge-pill.status-in_progress {
  background: var(--ink-9);
  border-color: var(--ink-9);
  color: var(--ink-0);
}
.badge-pill.status-on_hold {
  border-style: dashed;
}
.badge-pill.status-done {
  background: var(--ok-bg);
  border-color: var(--ok);
  color: var(--ok);
}

@media (prefers-color-scheme: dark) {
  .badge-pill.status-in_progress {
    background: var(--ink-3);
    border-color: var(--ink-3);
    color: var(--ink-9);
  }
}

.badge-pill.pri-high {
  border-color: var(--alert);
  color: var(--alert);
}
.badge-pill.pri-low {
  color: var(--text-faint);
}

.due {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.due.overdue {
  color: var(--alert);
}
.due.today {
  color: var(--warn);
}
.due.soon {
  color: var(--text);
}

.due .rel {
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
}


/* ---------- 空状態 ---------- */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-faint);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty .mark {
  font-size: 26px;
  margin-bottom: 8px;
  opacity: 0.5;
}


/* ============================================================
   フィルタバー
   ============================================================ */
.filters {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  margin-bottom: 16px;
}

.filters .grow {
  flex: 1;
  min-width: 180px;
}

.filters select,
.filters input {
  padding: 6px 10px;
  font-size: 12.5px;
}

.filters select {
  width: auto;
  min-width: 118px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  gap: 2px;
}

.seg button {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.seg button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}


/* ============================================================
   モーダル / ドロワー
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: flex;
  animation: fade 0.15s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  margin: auto;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.16s ease;
}

@keyframes pop {
  from {
    transform: translateY(10px) scale(0.985);
    opacity: 0;
  }
}

.drawer {
  margin-left: auto;
  width: min(680px, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: slide 0.2s ease;
}

@keyframes slide {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

.modal-head,
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2,
.drawer-head h2 {
  font-size: 16px;
}

.modal-body,
.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot,
.drawer-foot {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.modal-foot .left {
  margin-right: auto;
}

.icon-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  color: var(--text-faint);
  padding: 4px 7px;
  border-radius: var(--radius-sm);
  flex: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 560px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}


/* ---------- トースト ---------- */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--ink-9);
  color: var(--ink-0);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 320px;
  animation: pop 0.15s ease;
}

.toast.err {
  background: var(--alert);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: var(--ink-2);
    color: var(--ink-9);
  }
}

/* ---------- 共通ユーティリティ ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.spread {
  justify-content: space-between;
}
.wrap {
  flex-wrap: wrap;
}
.muted {
  color: var(--text-muted);
}
.faint {
  color: var(--text-faint);
}
.small {
  font-size: 12px;
}
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden {
  display: none !important;
}
.nowrap {
  white-space: nowrap;
}
hr.sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}


/* チェックボックス付きのラベル（タスクボードのマップ画面から流用） */

@media (max-width: 720px) {
  .mm-hint {
    display: none;
  }
}

.mm-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

/* ============================================================
   電子契約（社内側）
   ============================================================ */

/* リンクで作ったボタン（PDFを開く・ダウンロードなど）に下線を出さない */
a.btn { text-decoration: none; }

.ct-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ct-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-top: 1px solid var(--border);
  text-decoration: none;
}
.ct-row:first-child { border-top: 0; }
.ct-row:hover { background: var(--surface-2); }
.ct-row-main { display: flex; flex-direction: column; min-width: 0; }
.ct-row-main b { font-size: 14.5px; }
.ct-row-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

@media (max-width: 640px) {
  .ct-row { flex-direction: column; align-items: flex-start; }
  .ct-row-meta { flex-wrap: wrap; }
}

.seg-count {
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-faint);
}

/* 状態の色。**相手の対応待ちと締結だけ色を付ける**（基調はグレー） */
.badge-pill.ct-draft { background: var(--surface-2); color: var(--text-muted); }
.badge-pill.ct-sent,
.badge-pill.ct-viewed { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-pill.ct-completed { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge-pill.ct-declined,
.badge-pill.ct-expired { background: var(--alert-bg); color: var(--alert); border-color: transparent; }
.badge-pill.ct-canceled { background: var(--surface-2); color: var(--text-faint); text-decoration: line-through; }
.page-head h1 .badge-pill { vertical-align: middle; font-size: 12px; margin-left: 6px; }

.ct-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 26px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.ct-drop:hover,
.ct-drop.dragging { border-color: var(--text); }
.ct-drop.has-file { border-style: solid; background: var(--ok-bg); }
.ct-drop-main { font-weight: 600; }

.ct-h3 { font-size: 15px; margin: 0 0 10px; }

.ct-url {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.ct-url input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--surface-2);
}
@media (max-width: 560px) {
  .ct-url { flex-wrap: wrap; }
  .ct-url input { flex-basis: 100%; }
}

.note-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--text);
  font-size: 13px;
}

.ct-status.ct-done { border-color: var(--ok); }
.ct-status.ct-declined { border-color: var(--alert); }
.ct-reason {
  white-space: pre-wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.ct-meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 4px 12px;
  margin: 14px 0 0;
  font-size: 13px;
}
.ct-meta dt { color: var(--text-muted); }
.ct-meta dd { margin: 0; word-break: break-all; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.ct-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ct-timeline li {
  display: flex;
  gap: 14px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.ct-timeline li:first-child { border-top: 0; }
.ct-tl-when { color: var(--text-muted); flex-shrink: 0; width: 140px; }

.ct-steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ct-step {
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-faint);
}
.ct-step.active { background: var(--text); color: var(--surface); }

/* 道具は画面を下に送っても見えるようにする（長い契約書でも上まで戻らずに済む） */
.ct-sticky {
  position: sticky;
  top: calc(var(--header-h) + 6px);
  z-index: 5;
  margin: 0 -4px 12px;
}

/* 道具の帯の上でドラッグしても文字が選択されないように（欄を置こうとして帯に触れることがある） */
.cf-toolbar {
  user-select: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 10px;
}
.cf-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.cf-tool {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}
.cf-tool:hover { border-color: var(--text); }
.cf-tool.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.cf-hint { margin-left: 4px; }
.cf-props { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.cf-props-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cf-prop-label { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 220px; }
.cf-prop-label > span { white-space: nowrap; }
.cf-prop-label input { padding: 5px 9px; }

.ct-pages,
.sg-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 8px 0;
}

.ct-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin: 12px -18px -18px;
  padding: 12px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.ct-footer [data-count] { margin-right: auto; }

/* ---- PDFのページ ---- */
.pdf-page {
  position: relative;
  width: 100%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.pdf-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.pdf-overlay {
  position: absolute;
  inset: 0;
}
.pdf-overlay.placing { cursor: crosshair; touch-action: none; }
.pdf-page-no {
  position: absolute;
  right: 8px;
  bottom: -20px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ---- 記入欄（社内の配置画面） ----
   種類ごとに色を分ける。どこに何を置いたか、離れて見ても分かるように */
.cf {
  --cf: 37, 99, 235;
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid rgba(var(--cf), 0.9);
  background: rgba(var(--cf), 0.12);
  border-radius: 3px;
  cursor: move;
  touch-action: none;
  overflow: hidden;
  user-select: none;
}
.cf-signature { --cf: 124, 58, 237; }
.cf-stamp { --cf: 207, 31, 42; }
.cf-date { --cf: 22, 128, 72; }
.cf-checkbox { --cf: 82, 82, 91; }
.cf.optional { border-style: dashed; }
.cf.selected { box-shadow: 0 0 0 2px rgba(var(--cf), 0.35); background: rgba(var(--cf), 0.2); }
.cf-ghost { pointer-events: none; border-style: dashed; }
.cf-label {
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  line-height: 1.2;
  color: rgb(var(--cf));
  white-space: nowrap;
  pointer-events: none;
  font-weight: 600;
}
.cf-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  background: rgb(var(--cf));
  cursor: nwse-resize;
  border-top-left-radius: 3px;
}
.cf-badge-text { background: rgba(37, 99, 235, 0.12); color: rgb(37, 99, 235); }
.cf-badge-signature { background: rgba(124, 58, 237, 0.12); color: rgb(124, 58, 237); }
.cf-badge-stamp { background: rgba(207, 31, 42, 0.12); color: rgb(207, 31, 42); }
.cf-badge-date { background: rgba(22, 128, 72, 0.12); color: rgb(22, 128, 72); }
.cf-badge-checkbox { background: rgba(82, 82, 91, 0.12); color: rgb(82, 82, 91); }

/* ============================================================
   電子契約（相手の記入画面 /s/:token）
   ============================================================ */

.sg-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.sg-header .logo { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }
.sg-header .logo small { margin-left: 8px; font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.08em; }

.sg-main {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.sg-intro h1 { font-size: 22px; margin: 6px 0 2px; }
.sg-to { font-size: 15px; font-weight: 600; }
.sg-msg {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--text);
  background: var(--surface-2);
  white-space: pre-wrap;
}
.sg-howto { margin: 12px 0; padding-left: 20px; font-size: 13.5px; }
.sg-howto li { margin: 3px 0; }

.sg-progress {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 13.5px;
}

/* 記入欄：未記入は黄色で目立たせ、記入済みは控えめにする */
.sg-field {
  position: absolute;
  box-sizing: border-box;
  margin: 0;
  padding: 0 4px;
  border: 1.5px solid #d4a017;
  background: rgba(255, 214, 10, 0.32);
  border-radius: 3px;
  color: #111;
  font: inherit;
  font-size: 11px;
  line-height: 1.15;
  cursor: pointer;
  overflow: hidden;
  text-align: center;
}
.sg-field.optional { border-style: dashed; background: rgba(255, 214, 10, 0.16); }
.sg-field.filled { border-color: rgba(22, 128, 72, 0.6); background: rgba(22, 128, 72, 0.06); }
.sg-field.missing { border-color: var(--alert); background: rgba(192, 57, 43, 0.18); animation: sg-shake 0.3s; }
.sg-field.flash { box-shadow: 0 0 0 4px rgba(255, 214, 10, 0.7); }
.sg-field:focus-visible { outline: 2px solid #111; outline-offset: 1px; }
.sg-text { text-align: left; cursor: text; padding: 0 3px; }
.sg-text::placeholder { color: rgba(0, 0, 0, 0.45); }
.sg-date { cursor: default; color: #111; font-weight: 600; }
.sg-date:disabled { opacity: 1; }
.sg-checkbox { font-weight: 700; font-size: 13px; padding: 0; }
.sg-signature img,
.sg-stamp img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* 欄の大きさに合わせて文字を縮める。小さい押印欄で説明がはみ出さないように */
.sg-signature,
.sg-stamp { container-type: size; }
.sg-signature span,
.sg-stamp span { display: block; font-weight: 600; font-size: clamp(7px, min(24cqh, 15cqw), 12px); }
.sg-signature small,
.sg-stamp small { font-weight: 400; opacity: 0.7; }

@keyframes sg-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

.sg-submit { margin-top: 24px; }
.sg-agree {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 14px;
  font-weight: 600;
}
.sg-agree input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; }
.sg-agree.missing { border-color: var(--alert); background: var(--alert-bg); }
.sg-send { padding: 13px; font-size: 15px; }

.sg-pad {
  display: block;
  width: 100%;
  aspect-ratio: 1040 / 400;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.sg-pad-preview { aspect-ratio: 1040 / 300; margin-top: 10px; cursor: default; }
.sg-seal-wrap { display: flex; justify-content: center; margin-top: 12px; }
.sg-seal {
  width: 160px;
  height: 160px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
}

.sg-message-card { max-width: 620px; margin: 40px auto; }

.sg-preview {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  border: 1px solid var(--warn);
  font-size: 13px;
}
.sg-message-card h1 { font-size: 20px; margin-top: 0; }
.sg-message-card.ok { border-top: 4px solid var(--ok); }

