  :root {
    --primary: #a67c52;
    --primary-light: #d8bfa0;
    --primary-dark: #8c6642;
    --accent: #e76f51;
    --bg-color: #f7f5f2;
    --card-bg: #ffffff;
    --text-main: #4a4a4a;
    --text-sub: #888888;
    --border-radius: 16px;
    --shadow-soft: 0 4px 20px rgba(166, 124, 82, 0.08);
    --font-family: 'Rounded Mplus 1c', sans-serif;
    --green: #4caf50;
    --red: #ef5350;
    --gray: #bdbdbd;
  }

  * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
  }

  html, body {
    background: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
  }

  body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  /* ===== 固定ヘッダー ===== */
  .sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  }
  .sticky-spacer {
    height: 120px;
  }
  .sticky-spacer.with-picker {
    height: 180px;
  }

  header {
    background: var(--bg-color);
    padding: 0.6em 0 0.3em;
    font-size: 1.1rem;
    font-weight: 800;
    text-align: center;
    color: var(--primary-dark);
  }

  /* ===== ページタブ ===== */
  .page-tabs {
    display: flex;
    background: var(--card-bg);
    margin: 0;
    padding: 6px;
    gap: 4px;
    border-bottom: 1px solid #eee;
  }
  .page-tab {
    flex: 1;
    padding: 10px 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-sub);
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s;
    text-align: center;
  }
  .page-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(166, 124, 82, 0.3);
  }
  .page-tab:not(.active):active {
    background: #f0ede8;
  }

  /* 名前選択エリア */
  .picker {
    background: var(--bg-color);
    padding: 0.5rem 1rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  select, input[type="text"] {
    width: 100%;
    max-width: 400px;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-main);
    background: var(--card-bg);
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
  }

  select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a67c52' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
  }

  select:focus, input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.2);
  }

  /* 月タブ切り替え */
  .tab-container {
    background: var(--bg-color);
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 1rem;
    margin-bottom: 0;
    scrollbar-width: none;
  }
  .tab-container::-webkit-scrollbar { display: none; }

  .tab {
    flex: 0 0 auto;
    padding: 0.6rem 1.2rem;
    background: #e6e2dd;
    color: var(--text-sub);
    border-radius: 99px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(166, 124, 82, 0.3);
    transform: translateY(-1px);
  }

  /* ===== カレンダー詳細ビュー ===== */
  .calendar-detail-list {
    padding: 0 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
  }

  .detail-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 0.8rem 1rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    scroll-margin-top: 100px;
    transition: background-color 0.4s;
  }
  .detail-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 5px;
    background: var(--primary-light);
  }
  .detail-card.sunday::before { background: #ffadad; }
  .detail-card.saturday::before { background: #a0c4ff; }
  .detail-card.off::before { background: #d1d1d1; }
  .detail-card.off {
    background: #fafafa;
    opacity: 0.7;
  }
  .detail-card.undecided {
    border: 1.5px dashed #e0e0e0;
    box-shadow: none;
    background: transparent;
    opacity: 0.6;
  }
  .detail-card.undecided::before { background: transparent; }
  .detail-card.today {
    border: 2px solid var(--accent);
    box-shadow: 0 0 12px rgba(231, 111, 81, 0.15);
  }
  .detail-card.today::after {
    content: "TODAY";
    position: absolute; top: 0; right: 0;
    background: var(--accent); color: #fff;
    font-size: 0.65rem; font-weight: bold;
    padding: 2px 8px; border-bottom-left-radius: 8px;
  }
  .detail-card.low-attendance {
    border: 2px solid var(--accent);
    background: #fff5f2;
  }
  .detail-card.highlight {
    background-color: #fff9c4;
  }
  .detail-card.past {
    opacity: 0.45;
    cursor: pointer;
  }
  .detail-card.past .detail-section { display: none; }
  .detail-card.past .detail-info { display: none; }
  .detail-card.past::after {
    content: "タップで表示";
    position: absolute;
    bottom: 4px; right: 10px;
    font-size: 0.65rem;
    color: var(--text-sub);
  }

  .detail-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
  }
  .detail-date {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--primary-dark);
  }
  .detail-holiday {
    font-size: 0.75rem;
    background: #ffe8e0;
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
  }
  .detail-pill {
    font-size: 0.75rem;
    background: var(--primary);
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    margin-left: auto;
  }
  .detail-off-tag,
  .detail-undecided-tag {
    font-size: 0.75rem;
    background: var(--gray);
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    margin-left: auto;
  }

  .detail-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.8rem;
    color: var(--text-sub);
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: #f8f6f3;
    border-radius: 8px;
  }
  .detail-info b {
    color: var(--text-main);
    font-weight: 600;
  }

  /* 出席・欠席・未回答セクション */
  .detail-section {
    margin-top: 0.4rem;
  }
  .detail-section-head {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
  }
  .detail-section-head.present { color: var(--green); }
  .detail-section-head.absent { color: var(--red); }
  .detail-section-head.unanswered { color: var(--gray); }

  .detail-section-icon {
    font-size: 0.6rem;
    line-height: 1;
  }
  .detail-section-count {
    font-weight: 400;
    color: var(--text-sub);
    font-size: 0.75rem;
    margin-left: 2px;
  }

  .detail-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .name-chip {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
  }
  .name-chip.present {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
  }
  .name-chip.absent {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
  }
  .name-chip.unanswered {
    background: #f5f5f5;
    color: #999;
    border: 1px solid #e0e0e0;
  }

  .detail-empty {
    font-size: 0.8rem;
    color: #ccc;
    padding-left: 0.5rem;
  }

  /* 出席・欠席セクション区切り */
  .detail-section + .detail-section {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #eee;
  }


  /* ===== 出欠回答リスト（既存） ===== */
  .calendar-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0 1rem;
  }

  .calendar-day-box {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.2rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    scroll-margin-top: 140px;
  }
  .calendar-day-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 6px;
    background: var(--primary-light);
  }
  .calendar-day-box.sunday::before { background: #ffadad; }
  .calendar-day-box.saturday::before { background: #a0c4ff; }
  .calendar-day-box.off::before { background: #d1d1d1; }
  .calendar-day-box.off { background: #fcfcfc; }
  .calendar-day-box.off .day-label { opacity: 0.7; }
  .calendar-day-box.undecided {
    border: 2px dashed #e0e0e0;
    box-shadow: none;
    background: transparent;
  }
  .calendar-day-box.low-attendance {
    border: 2px solid var(--accent);
    background: #fff5f2;
  }
  .calendar-day-box.low-attendance .day-label::after {
    content: "人数不足";
    display: inline-block;
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--accent);
    background: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--accent);
  }

  .day-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
    color: var(--primary-dark);
  }

  .pill {
    font-size: 0.8rem;
    background: var(--primary-light);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: normal;
  }
  .off-tag {
    font-size: 0.8rem;
    background: #bbb;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
  }
  .request-hint {
    display: block;
    width: 100%;
    font-size: 0.85rem;
    color: var(--accent);
    margin-top: 0.2rem;
  }

  .event-note {
    background: #fdf8f0;
    color: #6d5843;
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
    white-space: pre-wrap;
    border-left: 3px solid var(--primary);
  }
  .event-note.activity-content-note {
    margin-top: 0.2rem;
    border-left-color: #8c6642;
  }

  .event-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-sub);
    margin-bottom: 1rem;
    background: #f5f5f5;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
  }
  .event-info a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
  }

  .time-row {
    display: flex;
    align-items: center;
    background: #fff;
    border: 2px solid #eee;
    border-radius: 12px;
    padding: 0.8rem;
    margin-top: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
  }
  .time-row:hover { border-color: var(--primary-light); }
  .time-row:active { transform: scale(0.98); background: #fcfcfc; }
  .time-row[aria-pressed="true"] {
    border-color: var(--primary);
    background: #fdfaf7;
  }
  .time-row[aria-pressed="true"] .time-row-left input[type="checkbox"] {
    background: var(--primary);
    border-color: var(--primary);
  }
  .time-row[aria-pressed="true"] .time-row-left input[type="checkbox"]::after { display: block; }

  .time-row-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 5rem;
  }
  .time-row-left input[type="checkbox"] {
    appearance: none;
    width: 24px; height: 24px;
    border: 2px solid #ccc;
    border-radius: 6px;
    position: relative;
    cursor: pointer;
    margin: 0;
  }
  .time-row-left input[type="checkbox"]::after {
    content: ''; display: none;
    position: absolute;
    left: 7px; top: 3px;
    width: 6px; height: 12px;
    border: solid #fff;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
  }
  .time-row-left span { font-weight: 700; color: var(--text-main); }
  .spacer3 { width: 1rem; }

  .meta {
    flex: 1; display: flex; align-items: center; gap: 0.5rem; overflow: hidden;
  }

  .count-label {
    background: var(--text-sub);
    color: #fff;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 1.8em;
    text-align: center;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.1s;
  }
  .count-label:active { transform: scale(1.1); }
  .time-row[aria-pressed="true"] .count-label { background: var(--primary); }

  .names {
    font-size: 0.85rem; color: var(--text-sub);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  .pill {
    border: none; background: #eee; color: var(--text-sub);
    font-size: 0.75rem; padding: 4px 8px; border-radius: 6px;
    cursor: pointer; transition: 0.2s;
  }
  .pill:active { background: #ddd; }

  .save-btn {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    width: 90%; max-width: 500px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 30px;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 800;
    box-shadow: 0 10px 25px rgba(166, 124, 82, 0.4);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 90;
    cursor: pointer;
    display: block; opacity: 0; pointer-events: none;
  }
  .save-btn.dirty {
    transform: translateX(-50%) translateY(0);
    opacity: 1; pointer-events: auto;
  }
  .save-btn:active { transform: translateX(-50%) scale(0.95); }

  .overlay {
    position: fixed; inset: 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center; z-index: 1000;
  }
  .overlay.show { display: flex; }
  .spinner {
    width: 50px; height: 50px;
    border: 5px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .loading-text {
    position: absolute; margin-top: 80px; font-weight: bold; color: var(--primary);
  }

  .toast {
    position: fixed; bottom: 90px; left: 50%;
    transform: translateX(-50%);
    background: rgba(50, 50, 50, 0.9);
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
  }
  .toast.show { opacity: 1; }

  .skeleton {
    background: #f0f0f0; height: 20px; border-radius: 4px; margin: 5px 0;
    animation: pulse 1.5s infinite ease-in-out;
  }
  @keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

  .scroll-top-btn {
    position: fixed; right: 20px; bottom: 90px;
    width: 45px; height: 45px;
    background: rgba(255,255,255,0.9); color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    opacity: 0; pointer-events: none; transition: all 0.3s; z-index: 80;
  }
  .scroll-top-btn.show { opacity: 1; pointer-events: auto; }

  /* Today Highlight for Response List */
  .calendar-day-box.today {
    border: 2px solid var(--accent);
    box-shadow: 0 0 15px rgba(231, 111, 81, 0.2);
  }
  .calendar-day-box.today::after {
    content: "TODAY";
    position: absolute; top: 0; right: 0;
    background: var(--accent); color: #fff;
    font-size: 0.7rem; font-weight: bold;
    padding: 2px 8px; border-bottom-left-radius: 8px;
  }

  /* ページコンテンツ表示制御 */
  .page-content { min-height: 50vh; }
