/* ===== リセット・全体設定 ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Text sizes use rem: the default body is 16px (previously 14px). */
    font-size: 100%;
    /* Shared visual grammar: spacing, type, surfaces and interaction states. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --type-caption: 0.857143rem;
    --type-body: 1rem;
    --type-label: 0.928571rem;
    --type-heading: 1.285714rem;
    --leading-body: 1.65;
    --radius-sm: 8px;
    --radius-control: 10px;
    --radius-card: 14px;
    --radius-dialog: 20px;
    --control-height: 40px;
    --icon-stroke: 1.8;
    --on-accent: #08261f;
    --action-danger: #a92c45;
    --action-danger-hover: #90233a;
    --action-bg: var(--blurple);
    --action-hover: #7ae5c7;
    --focus-color: #89ead4;
    --focus-width: 3px;
    --focus-offset: 3px;
    --border-control: #526d7b;
    --shadow-card: 0 3px 12px rgba(0, 10, 16, 0.12);
    --shadow-dialog: 0 24px 70px rgba(0, 8, 15, 0.5);
    --surface-card: var(--bg-medium);
    --surface-input: var(--bg-darkest);
    --state-hover: color-mix(in srgb, var(--text-primary) 7%, transparent);
    --state-active: color-mix(in srgb, var(--blurple) 13%, var(--bg-dark));
    --state-active-border: color-mix(in srgb, var(--blurple) 52%, transparent);
    --state-disabled-opacity: 0.5;
    --danger-soft: color-mix(in srgb, var(--red) 12%, transparent);
    --success-soft: color-mix(in srgb, var(--green) 12%, transparent);
    --warning-soft: color-mix(in srgb, var(--yellow) 12%, transparent);
    /* Semantic tones: a readable foreground plus soft fill and border, so components never hardcode theme colors. */
    --tone-success: var(--green);
    --tone-warning: var(--yellow);
    --tone-danger: var(--red);
    --tone-info: var(--cyan);
    --tone-muted: var(--text-muted);
    --tone-success-soft: color-mix(in srgb, var(--tone-success) 14%, transparent);
    --tone-warning-soft: color-mix(in srgb, var(--tone-warning) 14%, transparent);
    --tone-danger-soft: color-mix(in srgb, var(--tone-danger) 14%, transparent);
    --tone-info-soft: color-mix(in srgb, var(--tone-info) 14%, transparent);
    --tone-success-border: color-mix(in srgb, var(--tone-success) 40%, transparent);
    --tone-warning-border: color-mix(in srgb, var(--tone-warning) 40%, transparent);
    --tone-danger-border: color-mix(in srgb, var(--tone-danger) 40%, transparent);
    --tone-info-border: color-mix(in srgb, var(--tone-info) 40%, transparent);
    /* Tone text that stays readable on its own soft fill: pulled toward the body text colour. */
    --tone-success-text: color-mix(in srgb, var(--tone-success) 72%, var(--text-primary));
    --tone-warning-text: color-mix(in srgb, var(--tone-warning) 72%, var(--text-primary));
    --tone-danger-text: color-mix(in srgb, var(--tone-danger) 72%, var(--text-primary));
    --tone-info-text: color-mix(in srgb, var(--tone-info) 72%, var(--text-primary));
    --orange-text: color-mix(in srgb, var(--orange) 72%, var(--text-primary));
    --accent-text: var(--blurple);
    --weekend-sun: #ff8f99;
    --weekend-sat: #7cc4ff;
    --surface-inset: color-mix(in srgb, var(--bg-darkest) 55%, transparent);
    --heat-strong-text: var(--on-accent);
    /* Text on tone fills (light tones in the dark themes, deep tones in light), on always-dark fills, and brand marks. */
    --on-tone: #0b141c;
    --on-strong: #ffffff;
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow-color: #020a10;
    --scrim: rgba(2, 8, 17, 0.65);
    --violet: #a38bff;
    --brand-line: #06c755;
    --brand-slack: #6b46c1;
    --brand-mattermost: #1f9bcf;
    /* Data colours (calendar chips): fixed across themes, each deep enough for white chip text (>= 4.5:1). */
    --cat-1: #c2185b;
    --cat-2: #00796b;
    --cat-3: #a35a00;
    --cat-4: #c62828;
    --cat-5: #1565c0;
    --cat-6: #5e35b1;
    --cat-7: #bf360c;
    --cat-8: #2e7d32;
    --event-special: #0b6bc4;
    --event-special-border: #74b9ff;
    --event-ticket: #fdcb6e;
    --event-ticket-text: #2d2000;
    --type-min: 0.785714rem;
    --tap-min: 32px;
    /* Compatibility tokens used by existing display markup. */
    --bg-primary: var(--bg-medium);
    --bg-secondary: var(--bg-dark);
    --bg-hover: var(--state-hover);
    --bg-modifier-hover: var(--state-hover);
    --border-color: var(--border-medium);
    --shadow-lg: var(--shadow-dialog);

    /* ===== Theme 1: 既定（ダークティール） ===== */
    --bg-darkest: #08131b;
    --bg-dark: #0f1f29;
    --bg-medium: #132632;
    --bg-light: #193140;
    --bg-lighter: #234454;
    --bg-modifier-accent: rgba(255,255,255,0.08);
    --text-primary: #f3f8fb;
    --text-secondary: #c1d3dd;
    --text-muted: #9eb5c2;
    --text-normal: #f3f8fb;
    --white: #ffffff;
    --blurple: #4ad7b2;
    --blurple-hover: #23b891;
    --green: #66f0a9;
    --green-dark: #13754f;
    --yellow: #f5d16d;
    --red: #ff7a86;
    --orange: #ffb45c;
    --cyan: #56c5ff;
    --pink: #ff8dc6;
    --in-person: #66f0a9;
    --online-realtime: #56c5ff;
    --online-async: #ffb45c;
    --unavailable: #ff7a86;
    --font: 'IBM Plex Sans JP', sans-serif;
    --font-display: 'Space Grotesk', 'IBM Plex Sans JP', sans-serif;
    --radius: 14px;
    --transition: 0.18s ease;
    --shadow-soft: 0 22px 50px rgba(3, 11, 18, 0.38);
    --icon-fill: 1;
    --icon-weight: 500;
    --icon-grad: 0;
    --body-bg:
        radial-gradient(circle at top left, rgba(86, 197, 255, 0.14), transparent 36%),
        radial-gradient(circle at top right, rgba(74, 215, 178, 0.14), transparent 28%),
        linear-gradient(180deg, #071119 0%, #09151d 100%);
    --chat-area-bg:
        linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
        linear-gradient(180deg, #0a1821 0%, #0d1f2a 100%);
    --surface-soft: rgba(255,255,255,0.05);
    --surface-medium: rgba(255,255,255,0.08);
    --surface-strong: rgba(255,255,255,0.16);
    --border-soft: rgba(255,255,255,0.06);
    --border-medium: rgba(255,255,255,0.08);
}

/* ===== Theme 2: ネイビー ===== */
[data-theme="navy"] {
    --on-tone: #0b1020;
    --border-strong: rgba(255, 255, 255, 0.14);
    --shadow-color: #000000;
    --scrim: rgba(0, 0, 0, 0.66);
    --violet: #b9a8ff;
    --on-accent: #121b3b;
    --action-hover: #c4ceff;
    --focus-color: #b7c4ff;
    --border-control: #657399;
    --shadow-card: 0 3px 12px rgba(0, 0, 0, 0.18);
    --shadow-dialog: 0 24px 70px rgba(0, 0, 0, 0.6);
    --bg-darkest: #04060f;
    --bg-dark: #0a0f1e;
    --bg-medium: #101830;
    --bg-light: #182242;
    --bg-lighter: #232f55;
    --bg-modifier-accent: rgba(255,255,255,0.05);
    --text-primary: #e6eaff;
    --text-secondary: #a8b1d9;
    --text-muted: #a0accb;
    --text-normal: #e6eaff;
    --white: #ffffff;
    --blurple: #a5b4ff;
    --blurple-hover: #bac5ff;
    --green: #79dfb0;
    --green-dark: #2a3f80;
    --yellow: #f2cb7a;
    --red: #ff8c95;
    --orange: #8fa6ff;
    --cyan: #6b9eff;
    --pink: #b9c1e8;
    --in-person: #7aa8ff;
    --online-realtime: #9ab2ff;
    --online-async: #c3cdf2;
    --unavailable: #ff8c95;
    --shadow-soft: 0 22px 50px rgba(0, 0, 0, 0.55);
    --icon-fill: 0;
    --icon-weight: 300;
    --icon-grad: -25;
    --body-bg:
        radial-gradient(circle at top left, rgba(107, 124, 255, 0.10), transparent 38%),
        linear-gradient(180deg, #000000 0%, #050813 100%);
    --chat-area-bg:
        linear-gradient(180deg, rgba(255,255,255,0.015), rgba(255,255,255,0)),
        linear-gradient(180deg, #07101f 0%, #0a1530 100%);
    --surface-soft: rgba(255,255,255,0.04);
    --surface-medium: rgba(255,255,255,0.06);
    --surface-strong: rgba(255,255,255,0.12);
    --border-soft: rgba(255,255,255,0.05);
    --border-medium: rgba(255,255,255,0.08);
}

/* ===== Theme 3: ライト ===== */
[data-theme="light"] {
    --accent-text: #4555cc;
    --weekend-sun: #c42b3d;
    --weekend-sat: #2f5bd3;
    --surface-inset: rgba(11, 20, 36, 0.035);
    --heat-strong-text: var(--text-primary);
    --on-tone: #ffffff;
    --border-strong: rgba(11, 20, 36, 0.18);
    --shadow-color: #1e3150;
    --scrim: rgba(15, 23, 42, 0.45);
    --violet: #6c5ce7;
    --on-accent: #ffffff;
    --action-bg: #4555cc;
    --action-hover: #3544b0;
    --focus-color: #3545c1;
    --border-control: #8795aa;
    --shadow-card: 0 3px 12px rgba(30, 49, 80, 0.05);
    --shadow-dialog: 0 24px 70px rgba(30, 49, 80, 0.2);
    --bg-darkest: #ffffff;
    --bg-dark: #f4f6fb;
    --bg-medium: #ffffff;
    --bg-light: #eaeef6;
    --bg-lighter: #d7dfee;
    --bg-modifier-accent: rgba(11, 20, 36, 0.05);
    --text-primary: #0b1424;
    --text-secondary: #3f4b65;
    --text-muted: #596880;
    --text-normal: #0b1424;
    --white: #ffffff;
    /* #5865f2 fell below 4.5:1 both as text on white and under white text, so the light accent is one step deeper. */
    --blurple: #4555cc;
    --blurple-hover: #3544b0;
    --green: #187441;
    --green-dark: #0a7b46;
    --yellow: #8a5a00;
    --red: #be2940;
    --orange: #b44a13;
    --cyan: #006782;
    --pink: #db3dad;
    --in-person: #1aa55e;
    --online-realtime: #4555cc;
    --online-async: #f06c1e;
    --unavailable: #e0364a;
    --shadow-soft: 0 22px 50px rgba(80, 95, 130, 0.18);
    --icon-fill: 1;
    --icon-weight: 600;
    --icon-grad: 0;
    --body-bg:
        radial-gradient(circle at top left, rgba(88, 101, 242, 0.10), transparent 36%),
        radial-gradient(circle at top right, rgba(240, 108, 30, 0.08), transparent 28%),
        linear-gradient(180deg, #f8faff 0%, #edf1fb 100%);
    --chat-area-bg:
        linear-gradient(180deg, rgba(11, 20, 36, 0.015), rgba(11, 20, 36, 0)),
        linear-gradient(180deg, #ffffff 0%, #f6f8fd 100%);
    --surface-soft: rgba(11, 20, 36, 0.035);
    --surface-medium: rgba(11, 20, 36, 0.06);
    --surface-strong: rgba(11, 20, 36, 0.1);
    --border-soft: rgba(11, 20, 36, 0.07);
    --border-medium: rgba(11, 20, 36, 0.1);
}

/* Keep typography independent of layout spacing and respect browser text preferences. */
:root[data-font-size="small"] { font-size: 87.5%; }
:root[data-font-size="large"] { font-size: 112.5%; }
:root[data-font-size="extra-large"] { font-size: 125%; }
:root[data-font-family="system"] {
    --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: var(--font);
}
:root[data-font-family="meiryo"] {
    --font: Meiryo, 'メイリオ', 'Yu Gothic', sans-serif;
    --font-display: var(--font);
}
:root[data-font-family="serif"] {
    --font: 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif JP', serif;
    --font-display: var(--font);
}

.settings-font-preview {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-control);
    background: var(--surface-soft);
    font-size: var(--type-body);
    line-height: var(--leading-body);
    overflow-wrap: anywhere;
}

body {
    font-family: var(--font);
    background: var(--body-bg);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

[data-ui-density="compact"] .channel-item {
    padding-top: 7px;
    padding-bottom: 7px;
    margin-top: 2px;
    margin-bottom: 2px;
}

[data-ui-density="compact"] .sidebar-insights {
    padding: 10px 12px 6px;
    gap: 8px;
}

[data-ui-density="compact"] .sidebar-card {
    padding: 8px 10px;
}

[data-ui-density="compact"] .workspace-hero {
    padding-top: 8px;
}

[data-ui-density="compact"] .message {
    margin-top: 10px;
    margin-bottom: 10px;
}

[data-reduced-motion="true"] *,
[data-reduced-motion="true"] *::before,
[data-reduced-motion="true"] *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
}

[data-reduced-motion="true"] .channel-item:hover,
[data-reduced-motion="true"] .server-icon:hover,
[data-reduced-motion="true"] .slash-btn:hover,
[data-reduced-motion="true"] .workspace-hero-action:hover,
[data-reduced-motion="true"] .btn:hover,
[data-reduced-motion="true"] .action-btn:hover,
[data-reduced-motion="true"] .settings-save-btn:hover,
[data-reduced-motion="true"] .cal-page-nav-btn:hover,
[data-reduced-motion="true"] .cal-page-action-btn:hover,
[data-reduced-motion="true"] .cdp-add-btn:hover,
[data-reduced-motion="true"] .pd-action-btn:hover,
[data-reduced-motion="true"] .kt-action-btn:hover,
[data-reduced-motion="true"] .kt-filter-btn:hover,
[data-reduced-motion="true"] .kt-card:hover,
[data-reduced-motion="true"] .rp-print-btn:hover,
[data-reduced-motion="true"] .mode-toggle-btn:hover,
[data-reduced-motion="true"] .chat-mode-toggle:hover,
[data-reduced-motion="true"] .chat-jump-latest:hover,
[data-reduced-motion="true"] .cal-day:hover,
[data-reduced-motion="true"] .chat-fullcal-cell:hover:not(.chat-fullcal-empty),
[data-reduced-motion="true"] .settings-section:hover,
[data-reduced-motion="true"] .admin-card:hover {
    transform: none !important;
}

.material-icons {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    min-width: 1.25em;
    overflow: hidden;
    font-family: var(--font);
    font-weight: normal;
    font-style: normal;
    font-size: 1em;
    line-height: 1;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    font-feature-settings: 'liga';
}

.material-icons svg {
    width: 1em;
    height: 1em;
    display: block;
    /* The <title> exists only for textContent compatibility; keep it from overriding button tooltips. */
    pointer-events: none;
    stroke: currentColor;
    fill: none;
    stroke-width: var(--icon-stroke);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.modal-label .material-icons,
.admin-card-header .material-icons,
.sidebar-card-header .material-icons,
.server-header .material-icons {
    font-size: 1.05em;
    vertical-align: text-bottom;
}

.modal-label,
.admin-card-header,
.sidebar-card-header > span,
.server-header h2 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ===== Discordレイアウト ===== */
.discord-app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}

/* サーバーリスト */
.server-list {
    width: 72px;
    background: var(--bg-darkest);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 12px;
    gap: 8px;
    flex-shrink: 0;
}

.server-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-radius var(--transition), background var(--transition);
}
.server-icon:hover,
.server-icon.active {
    border-radius: 16px;
    background: var(--blurple);
}
.server-icon .material-icons {
    font-size: 1.714286rem;
    color: var(--text-primary);
}

/* チャンネルサイドバー */
.channel-sidebar {
    width: 240px;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: hidden; /* スクロールは内部コンテンツ側で管理 */
    height: 100%;
}
.sidebar-scroll-area {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.server-header {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-strong);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--shadow-color) 20%, transparent);
}
.server-header h2 {
    font-size: 1.071429rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-category {
    font-size: 0.785714rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 18px 16px 4px;
    letter-spacing: 0.02em;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 1px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
}
a.channel-item { text-decoration: none; }
.channel-item:hover {
    background: var(--bg-lighter);
    color: var(--text-primary);
}
.channel-item.active {
    background: var(--bg-lighter);
    color: var(--text-primary);
    font-weight: 500;
}
.channel-item .material-icons {
    font-size: 1.428571rem;
    color: var(--text-muted);
}

.sidebar-insights {
    padding: 12px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid var(--border-strong);
}
.sidebar-card {
    background: var(--bg-medium);
    border-radius: var(--radius);
    padding: 10px 12px;
    box-shadow: inset 0 0 0 1px var(--border-soft);
}
.sidebar-card-header {
    font-size: 0.857143rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: space-between;
    text-transform: uppercase;
}
.sidebar-toggle {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}
.sidebar-toggle:hover { color: var(--text-primary); }
.sidebar-toggle .material-icons { font-size: 1.285714rem; transition: transform var(--transition); }
.sidebar-card.collapsed .sidebar-toggle .material-icons { transform: rotate(-90deg); }
.sidebar-card.collapsed .sidebar-card-body { display: none; }

.mini-cal-title {
    font-size: 0.857143rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 6px;
}
.mini-cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}
.mini-cal-header {
    text-align: center;
    font-size: var(--type-min);
    font-weight: 700;
    color: var(--text-muted);
    padding-bottom: 2px;
}
.mini-cal-cell {
    background: var(--bg-darkest);
    border: 1px solid var(--bg-lighter);
    border-radius: 6px;
    height: 28px;
    position: relative;
    overflow: hidden;
}
.mini-cal-cell.empty {
    background: transparent;
    border-color: transparent;
}
.mini-cal-cell.today {
    border-color: var(--blurple);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--blurple) 20%, transparent) inset;
}
.mini-cal-date {
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: var(--type-min);
    color: var(--text-secondary);
    font-weight: 700;
}
.mini-cal-dots {
    position: absolute;
    bottom: 4px;
    left: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}
.mini-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0.95;
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--shadow-color) 35%, transparent);
}
.mini-dot.activity { background: var(--green); }
.mini-dot.spevent { background: var(--cyan); }
.mini-dot.ticket { background: var(--orange); }

.sidebar-card-body {
    font-size: 0.857143rem;
    color: var(--text-primary);
}
.sidebar-empty {
    font-size: 0.857143rem;
    color: var(--text-muted);
}
.mini-calendar .calendar-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    font-size: var(--type-min);
    gap: 4px;
}
.mini-calendar .cal-day {
    min-height: 60px;
}
.mini-calendar .cal-event {
    font-size: var(--type-min);
    padding: 2px 4px;
}
.my-schedule-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.day-chip {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: var(--bg-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.785714rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.my-schedule-cells {
    display: flex;
    gap: 4px;
    flex: 1;
}
.my-schedule-cell {
    flex: 1;
    height: 16px;
    border-radius: 4px;
    background: var(--bg-darkest);
    position: relative;
}
.my-schedule-cell::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 3px;
    background: var(--bg-lighter);
}
.my-schedule-cell[data-state="in_person"]::after { background: color-mix(in srgb, var(--in-person) 80%, transparent); }
.my-schedule-cell[data-state="online_realtime"]::after { background: color-mix(in srgb, var(--online-realtime) 80%, transparent); }
.my-schedule-cell[data-state="online_async"]::after { background: color-mix(in srgb, var(--online-async) 80%, transparent); }
.my-schedule-cell[data-state="unavailable"]::after { background: color-mix(in srgb, var(--unavailable) 80%, transparent); }
.my-schedule-cell[data-state="empty"]::after { background: var(--bg-dark); }

.availability-heatmap {
    margin-top: 16px;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface-inset);
}
.availability-heatmap h4 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    color: var(--text-primary);
}
.availability-heatmap-scroll { overflow-x: auto; }
.availability-heatmap .heatmap-grid {
    min-width: 250px;
    grid-template-columns: 94px repeat(5, minmax(0, 1fr));
}
.availability-heatmap .heatmap-time-label span {
    display: block;
    font-size: var(--type-min);
}
.availability-heatmap .heatmap-cell { height: 40px; }
.availability-heatmap .heatmap-cell span { line-height: 40px; }
.heatmap-grid {
    display: grid;
    grid-template-columns: 58px repeat(5, minmax(0, 1fr));
    gap: 4px 3px;
    align-items: stretch;
}
.heatmap-axis-corner {
    min-height: 16px;
    border-right: 1px solid var(--border-soft);
}
.heatmap-day-label {
    min-width: 0;
    text-align: center;
    font-size: var(--type-min);
    font-weight: 800;
    color: var(--text-muted);
    line-height: 16px;
    border-radius: 4px;
    background: var(--surface-soft);
}
.heatmap-time-label {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding: 2px 7px 2px 0;
    line-height: 1.12;
    border-right: 1px solid var(--border-soft);
    color: var(--text-muted);
    text-align: right;
}
.heatmap-time-label strong {
    color: var(--text-secondary);
    font-size: var(--type-min);
    font-weight: 800;
}
/* Compact layout; planning forms show the full time range. */
.heatmap-time-label span {
    display: none;
}
.heatmap-cell {
    position: relative;
    height: 30px;
    min-width: 0;
    border-radius: 5px;
    background: var(--surface-soft);
    overflow: hidden;
    border: 1px solid var(--border-soft);
    box-shadow: inset 0 0 0 1px var(--border-soft);
    transition: transform var(--transition), border-color var(--transition), filter var(--transition);
}
.heatmap-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, color-mix(in srgb, var(--white) 18%, transparent), transparent 56%);
    opacity: calc(var(--ratio, 0) * 0.5);
    z-index: 0;
}
.heatmap-cell:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    border-color: var(--border-strong);
}
.heatmap-cell span {
    position: relative;
    z-index: 1;
    font-size: var(--type-min);
    font-weight: 800;
    display: inline-block;
    width: 100%;
    text-align: center;
    color: var(--text-primary);
    line-height: 30px;
    text-shadow: 0 1px 2px color-mix(in srgb, var(--shadow-color) 35%, transparent);
}
/* More people available at the same time use a stronger accent. */
.heatmap-cell.heatmap-level-0 {
    background: var(--surface-inset);
    border-color: var(--border-soft);
}
.heatmap-cell.heatmap-level-0 span {
    color: var(--text-muted);
    font-weight: 700;
    text-shadow: none;
}
.heatmap-cell.heatmap-level-1 { background: color-mix(in srgb, var(--action-bg) 18%, transparent); border-color: color-mix(in srgb, var(--action-bg) 26%, transparent); }
.heatmap-cell.heatmap-level-2 { background: color-mix(in srgb, var(--action-bg) 34%, transparent); border-color: color-mix(in srgb, var(--action-bg) 42%, transparent); }
.heatmap-cell.heatmap-level-3 { background: color-mix(in srgb, var(--action-bg) 70%, transparent); border-color: color-mix(in srgb, var(--action-bg) 78%, transparent); }
.heatmap-cell.heatmap-level-4 { background: var(--action-bg); border-color: var(--action-bg); }
.heatmap-cell:is(.heatmap-level-1, .heatmap-level-2) span { color: var(--text-primary); text-shadow: none; }
.heatmap-cell.heatmap-level-3 span { color: var(--heat-strong-text); text-shadow: none; }
.heatmap-cell.heatmap-level-4 span { color: var(--on-accent); text-shadow: none; }

/* ロール切り替え */
.role-switcher {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 16px;
}
.role-label {
    font-size: 0.928571rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background var(--transition);
}
.role-label:hover { background: var(--bg-lighter); }
.role-label input { accent-color: var(--blurple); }

/* サイドバーメンバーリスト */
.member-list-sidebar {
    padding: 4px 8px;
}
.member-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.928571rem;
    color: var(--text-muted);
    cursor: default;
    transition: background var(--transition);
}
.member-item:hover { background: var(--bg-light); }
.member-item.online { color: var(--text-secondary); }
.member-item.offline,
.member-item.unknown {
    color: var(--text-muted);
}
.member-item.offline .member-avatar-img,
.member-item.offline .member-avatar-fallback {
    filter: grayscale(0.35);
    opacity: 0.82;
}

/* アバターラッパー（ステータスドット付き） */
.member-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}
.member-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-light);
    display: block;
}
.member-avatar-fallback {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.928571rem;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    /* アバターがある場合はオーバーレイ表示 */
    position: absolute;
    bottom: 0;
    right: 0;
    border: 2px solid var(--bg-darkest);
    box-sizing: content-box;
}
/* 旧来の非アバターモード用（アバターなし時） */
.member-item > .status-dot {
    position: static;
    border: none;
}
.member-item.online .status-dot { background: var(--green); }
.member-item.idle .status-dot { background: var(--yellow); }
.member-item.dnd .status-dot { background: var(--red); }
.member-item.offline .status-dot { background: var(--text-muted); }
.member-item.unknown .status-dot {
    background: var(--bg-dark);
    border-color: var(--text-muted);
}

.member-name-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.member-status-text {
    flex-shrink: 0;
    font-size: var(--type-min);
    font-weight: 700;
    color: var(--text-muted);
}
.member-item.online .member-status-text { color: var(--green); }
.member-item.idle .member-status-text { color: var(--yellow); }
.member-item.dnd .member-status-text { color: var(--red); }

/* ユーザーバーのアバター画像対応 */
.user-bar-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* メンバーリスト ロード中 */
.member-list-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 0.785714rem;
    color: var(--text-muted);
}
.member-list-loading .material-icons {
    font-size: 1rem;
    animation: spin-slow 1.2s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }

/* メンバーカテゴリラベル */
.member-category-label {
    font-size: 0.785714rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 10px 3px;
}

/* ===== メインチャットエリア ===== */
.chat-area {
    flex: 1;
    background: var(--bg-medium);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.chat-header {
    min-height: 84px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}
.chat-header .material-icons { font-size: 1.571429rem; color: var(--text-muted); }
.channel-name { font-weight: 700; font-size: 1.071429rem; }

/* メッセージコンテナ */
.messages-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.channel-state {
    min-height: 180px;
    display: grid;
    place-items: center;
    padding: 28px 16px;
    color: var(--text-secondary);
}

.channel-state-card {
    width: min(520px, 100%);
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 18px;
    border-radius: 12px;
    background: var(--surface-soft);
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

.channel-state-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
    color: var(--blurple);
    font-size: 1.571429rem;
}

.channel-state-title {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
    font-size: 1.071429rem;
}

.channel-state-text {
    margin: 0;
    font-size: 0.928571rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.channel-state-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.channel-skeleton {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.channel-skeleton-line {
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--white) 7%, transparent), color-mix(in srgb, var(--white) 15%, transparent), color-mix(in srgb, var(--white) 7%, transparent));
    background-size: 220% 100%;
    animation: skeletonSweep 1.15s linear infinite;
}

.channel-skeleton-line.short { width: 64%; }
.channel-skeleton-line.medium { width: 82%; }

@keyframes skeletonSweep {
    from { background-position: 100% 0; }
    to { background-position: -120% 0; }
}

/* 各メッセージ */
.message {
    display: flex;
    gap: 16px;
    padding: 4px 0;
    animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.285714rem;
    font-weight: 700;
}
.avatar-bot { background: linear-gradient(135deg, var(--blurple), var(--violet)); }
.avatar-user { background: linear-gradient(135deg, var(--green-dark), var(--tone-success)); }
.avatar-admin { background: linear-gradient(135deg, var(--tone-warning), var(--orange)); }
.avatar-system { background: linear-gradient(135deg, var(--cyan), var(--tone-info)); }

.message-content { flex: 1; min-width: 0; }
.message-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.message-author {
    font-weight: 700;
    font-size: 1rem;
}
.author-bot { color: var(--blurple); }
.author-user { color: var(--green); }
.author-admin { color: var(--orange); }
.author-system { color: var(--cyan); }

.message-badge {
    font-size: var(--type-min);
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 500;
    background: var(--blurple);
    color: var(--on-accent);
}

.message-timestamp {
    font-size: 0.785714rem;
    color: var(--text-muted);
}

.message-text {
    font-size: 1rem;
    line-height: 22px;
    color: var(--text-primary);
    word-wrap: break-word;
}

/* Embed */
.embed {
    max-width: 520px;
    border-radius: var(--radius);
    background: var(--bg-dark);
    margin-top: 6px;
    overflow: hidden;
    border-left: 4px solid var(--blurple);
}
.embed.embed-green { border-left-color: var(--green); }
.embed.embed-orange { border-left-color: var(--orange); }
.embed.embed-red { border-left-color: var(--red); }
.embed.embed-cyan { border-left-color: var(--cyan); }

.embed-body {
    padding: 12px 16px;
    overflow-x: auto;
}
.embed-title {
    font-weight: 700;
    font-size: 1.071429rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.embed-description {
    font-size: 0.928571rem;
    color: var(--text-secondary);
    line-height: 20px;
    margin-bottom: 8px;
}
.embed-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.embed-field {
    flex: 1;
    min-width: 120px;
}
.embed-field-name {
    font-size: 0.857143rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.embed-field-value {
    font-size: 0.928571rem;
    color: var(--text-primary);
    line-height: 18px;
}
.embed-footer {
    font-size: 0.785714rem;
    color: var(--text-muted);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--bg-lighter);
}

/* Botのアクションボタン */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.action-buttons-rich {
    gap: 10px;
}
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    font-size: 0.928571rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), transform 0.1s;
}
.action-btn.has-visual {
    min-width: 150px;
    min-height: 54px;
    padding: 8px 12px;
    gap: 10px;
    justify-content: flex-start;
    text-align: left;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px var(--border-medium), 0 10px 20px var(--border-strong);
}
.action-btn-icon {
    width: 30px;
    min-width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--surface-strong);
    color: currentColor;
    font-size: 1.285714rem;
}
.action-btn-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.action-btn-copy-single {
    display: inline-flex;
}
.action-btn-label,
.action-btn-detail {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.action-btn-label {
    font-weight: 700;
}
.action-btn-detail {
    font-size: 0.785714rem;
    font-weight: 500;
    opacity: 0.78;
}
.action-btn:hover { filter: brightness(0.9); }
.action-btn:active { transform: scale(0.97); }

.action-btn.btn-blurple { background: var(--blurple); color: var(--on-accent); }
.action-btn.btn-green { background: var(--green-dark); color: var(--on-strong); }
.action-btn.btn-gray { background: var(--bg-lighter); color: var(--text-primary); }
.action-btn.btn-red { background: var(--red); color: var(--on-strong); }
.action-btn.btn-cyan { background: var(--green-dark); color: var(--on-strong); }
.action-btn .material-icons { font-size: 1.142857rem; }

/* 集計テーブル */
.summary-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 8px;
    border-radius: 8px;
}
.summary-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    font-size: 0.857143rem;
}
.summary-table-wrap > .summary-table {
    margin-top: 0;
}
.summary-table th,
.summary-table td {
    padding: 6px 8px;
    text-align: center;
    border: 1px solid var(--bg-lighter);
}
.summary-table th {
    background: var(--bg-light);
    font-weight: 700;
    color: var(--text-secondary);
}
.summary-table td {
    color: var(--text-primary);
}
.count-high { color: var(--green); font-weight: 700; }
.count-mid { color: var(--yellow); }
.count-low { color: var(--red); }

/* ===== 入力エリア ===== */
.input-area {
    padding: 0 16px 24px;
    flex-shrink: 0;
}

.slash-commands {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.slash-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--bg-lighter);
    border-radius: var(--radius);
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.928571rem;
    font-family: var(--font);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.slash-btn:hover {
    background: var(--bg-lighter);
    border-color: var(--blurple);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--blurple) 20%, transparent);
}
.slash-btn .material-icons { font-size: 1.142857rem; color: var(--blurple); }
.slash-btn-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.15;
}
.slash-btn-command,
.cmd-desc,
.cmd-alias {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.slash-btn-command {
    font-size: 0.928571rem;
    font-weight: 700;
}
.cmd-desc {
    font-size: 0.785714rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.cmd-alias {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: var(--type-min);
}

.input-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-lighter);
    border-radius: var(--radius);
    padding: 2px 12px;
    gap: 8px;
}
.input-box input {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font);
    padding: 10px 0;
    outline: none;
}
.input-box input::placeholder { color: var(--text-muted); }
.input-icon {
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition);
}
.input-icon:hover { color: var(--text-primary); }

.slash-command-palette {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    max-height: min(420px, 58vh);
    overflow-y: auto;
    padding: 8px;
    border: 1px solid color-mix(in srgb, var(--blurple) 28%, transparent);
    border-radius: 8px;
    background: var(--bg-dark);
    box-shadow: 0 18px 40px color-mix(in srgb, var(--shadow-color) 34%, transparent);
    z-index: 90;
}

.slash-command-option {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    border-radius: 6px;
    padding: 9px 10px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
}

.slash-command-option:hover,
.slash-command-option.is-active {
    background: color-mix(in srgb, var(--blurple) 16%, transparent);
}

.slash-command-option .material-icons {
    color: var(--blurple);
    font-size: 1.285714rem;
}

.slash-command-option-main {
    min-width: 0;
}

.slash-command-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.slash-command-option-main strong,
.slash-command-option-main small,
.slash-command-title-row em {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slash-command-option-main strong {
    font-size: 0.928571rem;
    min-width: 0;
}

.slash-command-option-main small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.785714rem;
}

.slash-command-category,
.slash-command-surface {
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--blurple) 35%, transparent);
    border-radius: 6px;
    padding: 1px 7px;
    font-size: var(--type-min);
    font-style: normal;
    font-weight: 700;
}

.slash-command-category {
    max-width: 92px;
    color: var(--blurple);
}

.slash-command-surface {
    max-width: 84px;
    border-color: color-mix(in srgb, var(--text-muted) 28%, transparent);
    color: var(--text-secondary);
}

.surface-both .slash-command-surface {
    border-color: color-mix(in srgb, var(--tone-success) 28%, transparent);
    color: var(--green);
}

.surface-webui .slash-command-surface {
    border-color: color-mix(in srgb, var(--blurple) 35%, transparent);
    color: var(--blurple);
}

.surface-discord .slash-command-surface {
    border-color: color-mix(in srgb, var(--orange) 35%, transparent);
    color: var(--yellow);
}

.slash-command-option-main .slash-command-discord {
    color: var(--text-secondary);
}

.slash-command-empty {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px;
    color: var(--text-secondary);
}

.slash-command-empty .material-icons {
    color: var(--text-muted);
    font-size: 1.285714rem;
}

.slash-command-empty strong,
.slash-command-empty small {
    display: block;
}

.slash-command-empty strong {
    color: var(--text-primary);
    font-size: 0.928571rem;
}

.slash-command-empty small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.785714rem;
}

.footer-mode-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.chat-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--bg-lighter);
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-primary);
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 0.928571rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.chat-mode-toggle:hover,
.chat-mode-toggle.active {
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
    border-color: color-mix(in srgb, var(--blurple) 45%, transparent);
    transform: translateY(-1px);
}

.chat-mode-toggle:disabled {
    cursor: progress;
    opacity: 0.72;
    transform: none;
}

.chat-mode-toggle .material-icons {
    font-size: 1.214286rem;
    color: var(--blurple);
}

.chat-mode-count {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border-medium);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 0.857143rem;
    font-weight: 700;
}

.chat-mode-hint {
    flex: 1 1 auto;
    color: var(--text-muted);
    font-size: 0.857143rem;
    line-height: 1.5;
    min-width: 0;
}

.chat-jump-latest {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid color-mix(in srgb, var(--blurple) 35%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--blurple) 10%, transparent);
    color: var(--text-primary);
    padding: 6px 10px;
    font-family: var(--font);
    font-size: 0.857143rem;
    font-weight: 800;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), border-color var(--transition);
}

.chat-jump-latest:hover {
    background: color-mix(in srgb, var(--blurple) 18%, transparent);
    border-color: color-mix(in srgb, var(--blurple) 55%, transparent);
    transform: translateY(-1px);
}

.chat-jump-latest .material-icons {
    font-size: 1.071429rem;
    color: var(--blurple);
}

.input-area.chat-mode-active .chat-mode-count {
    border-color: color-mix(in srgb, var(--blurple) 32%, transparent);
    background: color-mix(in srgb, var(--blurple) 10%, transparent);
    color: var(--text-primary);
}

.input-area.chat-mode-active .input-box {
    border-color: color-mix(in srgb, var(--blurple) 45%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 28%, transparent), 0 14px 28px var(--border-strong);
}

.input-area.chat-mode-active .input-icon {
    color: var(--blurple);
}

.input-box input:disabled {
    cursor: progress;
    opacity: 0.65;
}

.messages-container.chat-mode-view {
    gap: 10px;
    scroll-behavior: smooth;
}

.channel-chat-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    background: var(--surface-soft);
    box-shadow: inset 0 0 0 1px var(--border-medium);
    animation: chatPanelRise 0.28s ease both;
}

.channel-chat-panel-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--blurple) 14%, transparent);
    color: var(--blurple);
    flex: 0 0 auto;
}

.channel-chat-panel-title {
    font-weight: 800;
}

.channel-chat-panel-text {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.857143rem;
}

.channel-chat-date {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    color: var(--text-muted);
    font-size: 0.785714rem;
    font-weight: 800;
}

.channel-chat-date::before,
.channel-chat-date::after {
    content: "";
    height: 1px;
    background: var(--surface-medium);
}

.channel-chat-date span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--surface-soft);
}

.channel-chat-message {
    border-left: 2px solid transparent;
}

.channel-chat-message.is-self {
    border-left-color: color-mix(in srgb, var(--blurple) 62%, transparent);
    background: color-mix(in srgb, var(--blurple) 7%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 12%, transparent);
}

.channel-chat-message.is-new {
    animation: chatMessageRise 0.34s cubic-bezier(.2,.8,.2,1) both;
}

.message-local-badge {
    display: inline-flex;
    align-items: center;
    min-height: 16px;
    padding: 0 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tone-warning) 16%, transparent);
    color: var(--yellow);
    font-size: var(--type-min);
    font-weight: 800;
}

@keyframes chatPanelRise {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes chatMessageRise {
    from { opacity: 0; transform: translateY(24px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== モーダル ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--scrim);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}
.modal-overlay.show { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-medium);
    border-radius: 12px;
    width: 90vw;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px color-mix(in srgb, var(--shadow-color) 50%, transparent);
    animation: scaleIn 0.25s ease;
}
@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--bg-lighter);
}
.modal-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.285714rem;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-lighter); color: var(--text-primary); }

.modal-body { padding: 20px; }
.modal-body { overflow-x: auto; }

.modal-label {
    font-size: 0.928571rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.modal-hint {
    font-size: 0.857143rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.field-error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: var(--red);
    font-size: 0.857143rem;
    line-height: 1.4;
}

.field-error::before {
    content: 'error';
    font-family: 'Material Symbols Rounded', 'Material Icons', 'Segoe UI Symbol', sans-serif;
    font-size: 1rem;
    line-height: 1;
}

.discord-input[aria-invalid="true"],
.discord-select[aria-invalid="true"] {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone-danger) 72%, transparent), 0 0 0 3px color-mix(in srgb, var(--tone-danger) 8%, transparent);
}

.ui-toast-region {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.ui-toast {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--bg-medium);
    color: var(--text-primary);
    box-shadow: 0 18px 36px var(--border-strong), inset 0 0 0 1px var(--border-medium);
    pointer-events: auto;
    animation: uiStatusIn var(--motion-normal, 220ms) var(--motion-ease, ease) both;
}

.ui-toast-icon {
    color: var(--blurple);
    font-size: 1.285714rem;
}

.ui-toast-error .ui-toast-icon { color: var(--red); }
.ui-toast-success .ui-toast-icon { color: var(--green); }
.ui-toast-warn .ui-toast-icon { color: var(--orange); }

.ui-toast-text {
    min-width: 0;
    font-size: 0.928571rem;
    line-height: 1.45;
}

.ui-toast-close {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-grid;
    place-items: center;
}

.ui-toast-close:hover {
    background: var(--surface-medium);
    color: var(--text-primary);
}

.ui-toast:has(.ui-toast-action) {
    grid-template-columns: 22px minmax(0, 1fr) auto auto;
}

.ui-toast-action {
    border: 1px solid color-mix(in srgb, var(--blurple) 50%, transparent);
    background: color-mix(in srgb, var(--blurple) 14%, transparent);
    color: var(--text-primary);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.857143rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.ui-toast-action:hover {
    background: color-mix(in srgb, var(--blurple) 24%, transparent);
}

.discord-select,
.discord-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 4px;
    border: none;
    background: var(--bg-darkest);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font);
    outline: none;
}
.discord-select:focus,
.discord-input:focus {
    box-shadow: 0 0 0 2px var(--blurple);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--bg-lighter);
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--bg-medium);
    backdrop-filter: blur(14px);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn:hover { filter: brightness(0.9); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--blurple); color: var(--on-accent); }
.btn-gray { background: var(--bg-lighter); color: var(--text-primary); }
.btn-cancel { background: transparent; color: var(--text-secondary); }
.btn-cancel:hover { text-decoration: underline; }

/* ===== 管理者設定ページ ===== */
.admin-page {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}
.admin-topbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-strong);
    background: var(--bg-dark);
    position: sticky;
    top: 0;
    z-index: 10;
}
.admin-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}
.admin-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.928571rem;
    padding: 6px 10px;
    border-radius: 6px;
}
.admin-back:hover { background: var(--bg-lighter); color: var(--text-primary); }
.admin-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.admin-card {
    background: var(--bg-medium);
    border-radius: 12px;
    box-shadow: 0 16px 48px color-mix(in srgb, var(--shadow-color) 25%, transparent);
    overflow: hidden;
}
.admin-card-header {
    padding: 14px 16px;
    font-size: 0.928571rem;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--bg-lighter);
}
.admin-card-body {
    padding: 16px;
}
.admin-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.admin-status {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 0.928571rem;
    border: 1px solid var(--bg-lighter);
}
.admin-status.ok { border-color: color-mix(in srgb, var(--tone-success) 35%, transparent); color: var(--text-primary); }
.admin-status.warn { border-color: color-mix(in srgb, var(--tone-warning) 35%, transparent); color: var(--text-primary); }
.admin-status.err { border-color: color-mix(in srgb, var(--tone-danger) 35%, transparent); color: var(--text-primary); }
.admin-inline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ===== 予定登録グリッド ===== */
.schedule-grid-scroll {
    overflow-x: auto;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}
.schedule-grid {
    display: grid;
    grid-template-columns: 84px repeat(5, minmax(64px, 1fr));
    gap: 2px;
    background: var(--bg-darkest);
    border-radius: var(--radius);
    overflow: hidden;
    min-width: 460px;
}
.schedule-grid-scroll > .schedule-grid {
    margin-bottom: 0;
}

.grid-header {
    background: var(--bg-light);
    padding: 8px 4px;
    font-size: 0.857143rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-secondary);
}

.grid-period {
    background: var(--bg-light);
    padding: 8px 10px;
    font-size: 0.857143rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.grid-period .period-time {
    font-size: var(--type-min);
    font-weight: 400;
    color: var(--text-muted);
}

.grid-cell {
    border: none;
    background: var(--bg-dark);
    padding: 10px 4px;
    text-align: center;
    cursor: pointer;
    font-size: 0.785714rem;
    font-weight: 500;
    font-family: var(--font);
    transition: all var(--transition);
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}
.grid-cell:hover {
    filter: brightness(1.2);
    transform: scale(1.02);
}
/* 曜日・時限の見出しはボタン（押すと列・行をまとめて変える） */
.grid-line-btn {
    border: none;
    font-family: var(--font);
    cursor: pointer;
    text-align: inherit;
}
.grid-header.grid-line-btn { text-align: center; }
.grid-line-btn:hover {
    color: var(--text-primary);
    background: var(--bg-lighter);
}
/* 塗るモードでは、なぞる操作がスクロールにならないようにする */
.schedule-grid.is-painting .grid-cell { touch-action: none; }
.schedule-brush {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.schedule-brush-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--bg-lighter);
    border-radius: 999px;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.785714rem;
    font-weight: 600;
    cursor: pointer;
}
.schedule-brush-btn.active {
    border-color: var(--blurple);
    background: color-mix(in srgb, var(--blurple) 18%, var(--bg-dark));
    color: var(--text-primary);
}

/* Attendance is read from a tinted fill plus a colour bar; the label itself stays at body contrast in every theme. */
.grid-cell[data-state] { color: var(--text-primary); font-weight: 600; }
.grid-cell[data-state="empty"] { background: var(--bg-dark); color: var(--text-muted); font-weight: 400; }
.grid-cell[data-state="in_person"] { background: color-mix(in srgb, var(--in-person) 22%, transparent); box-shadow: inset 3px 0 0 var(--in-person); }
.grid-cell[data-state="online_realtime"] { background: color-mix(in srgb, var(--online-realtime) 22%, transparent); box-shadow: inset 3px 0 0 var(--online-realtime); }
.grid-cell[data-state="online_async"] { background: color-mix(in srgb, var(--online-async) 22%, transparent); box-shadow: inset 3px 0 0 var(--online-async); }
.grid-cell[data-state="unavailable"] { background: color-mix(in srgb, var(--unavailable) 16%, transparent); box-shadow: inset 3px 0 0 var(--unavailable); }

/* 凡例 */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.785714rem;
    color: var(--text-secondary);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.cell-sample {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}
.cell-sample.in_person { background: color-mix(in srgb, var(--in-person) 30%, transparent); border:1px solid var(--green); }
.cell-sample.online_realtime { background: color-mix(in srgb, var(--online-realtime) 35%, transparent); border:1px solid var(--blurple); }
.cell-sample.online_async { background: color-mix(in srgb, var(--online-async) 30%, transparent); border:1px solid var(--orange); }
.cell-sample.unavailable { background: color-mix(in srgb, var(--unavailable) 20%, transparent); border:1px solid var(--red); }
.cell-sample.empty { background: var(--bg-dark); border:1px solid var(--bg-lighter); }

/* キャンパス滞在リスト */
.campus-status-embed {
    max-width: 820px;
}
.campus-status-layout {
    display: grid;
    grid-template-columns: minmax(220px, 0.9fr) minmax(280px, 1.1fr);
    gap: 14px;
    align-items: stretch;
}
.campus-presence-panel,
.campus-bus-panel {
    min-width: 0;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-control);
    background: var(--surface-inset);
    padding: 12px;
}
.campus-section-title,
.campus-panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 900;
    font-size: 0.928571rem;
    color: var(--text-primary);
}
.campus-section-title {
    margin: 12px 0 6px;
    color: var(--text-muted);
}
.campus-section-title:first-child {
    margin-top: 0;
}
.campus-section-title-on {
    color: var(--green);
}
.campus-section-title .material-icons,
.campus-panel-head .material-icons {
    font-size: 1.285714rem;
}
.campus-empty,
.campus-bus-empty {
    color: var(--text-muted);
    font-size: 0.928571rem;
    padding: 8px 0;
}
.campus-member {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.928571rem;
}
.campus-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.campus-dot.on-campus { background: var(--tone-success); box-shadow: 0 0 0 3px var(--tone-success-soft); }
.campus-dot.off-campus { background: var(--text-muted); }
.campus-panel-head {
    justify-content: flex-start;
    margin-bottom: 10px;
}
.campus-panel-head div {
    min-width: 0;
}
.campus-panel-head strong,
.campus-panel-head small {
    display: block;
}
.campus-panel-head small {
    color: var(--text-muted);
    font-size: 0.785714rem;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.campus-bus-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--cyan);
    font-size: 0.857143rem;
    font-weight: 800;
    text-decoration: none;
}
.campus-bus-link .material-icons {
    font-size: 1.071429rem;
}
.campus-bus-api-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 8px;
    margin-bottom: 8px;
}
.campus-bus-route-select {
    min-width: 0;
}
.campus-bus-refresh {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: color-mix(in srgb, var(--blurple) 14%, transparent);
    color: var(--cyan);
    cursor: pointer;
}
.campus-bus-refresh .material-icons {
    font-size: 1.285714rem;
}
.campus-bus-api-status {
    margin: 0 0 8px;
    color: var(--text-muted);
    font-size: 0.785714rem;
}
.campus-bus-api-status-error {
    color: var(--orange);
}
.campus-bus-next {
    border: 1px solid color-mix(in srgb, var(--blurple) 30%, transparent);
    background: color-mix(in srgb, var(--blurple) 9%, transparent);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}
.campus-bus-next-label {
    color: var(--cyan);
    font-size: 0.785714rem;
    font-weight: 900;
}
.campus-bus-next strong,
.campus-bus-next span,
.campus-bus-next div {
    display: block;
}
.campus-bus-next strong {
    color: var(--text-primary);
    font-size: 1.071429rem;
    margin-top: 3px;
}
.campus-bus-next span:not(.campus-bus-next-label) {
    color: var(--text-secondary);
    font-size: 0.857143rem;
    margin-top: 2px;
}
.campus-bus-next div {
    color: var(--green);
    font-size: 1.571429rem;
    font-weight: 900;
    margin-top: 6px;
}
.campus-bus-list {
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
}
.campus-bus-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 28px;
    gap: 8px;
    align-items: center;
    border-radius: 6px;
    padding: 7px 8px;
    background: var(--surface-soft);
}
.campus-bus-row-passed {
    opacity: 0.56;
}
.campus-bus-time {
    color: var(--cyan);
    font-weight: 900;
    font-size: 0.928571rem;
}
.campus-bus-row-main {
    min-width: 0;
}
.campus-bus-row-main strong,
.campus-bus-row-main span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.campus-bus-row-main strong {
    color: var(--text-primary);
    font-size: 0.928571rem;
}
.campus-bus-row-main span {
    color: var(--text-muted);
    font-size: 0.785714rem;
    margin-top: 1px;
}
.campus-bus-delete {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: color-mix(in srgb, var(--tone-danger) 12%, transparent);
    color: var(--red);
    cursor: pointer;
}
.campus-bus-delete .material-icons {
    font-size: 1.214286rem;
}
.campus-bus-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}
.campus-bus-form input {
    min-width: 0;
}
.campus-bus-form input[type="time"] {
    min-height: 36px;
}
.campus-bus-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: var(--radius-control);
    background: var(--action-bg);
    color: var(--on-accent);
    font-weight: 700;
    cursor: pointer;
    min-height: 36px;
}
.campus-bus-add .material-icons {
    font-size: 1.285714rem;
}
@media (max-width: 760px) {
    .campus-status-layout {
        grid-template-columns: 1fr;
    }
    .campus-bus-form {
        grid-template-columns: 1fr;
    }
}

/* スクロールバー */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--bg-darkest);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--bg-lighter); }

/* ===== プログレスバー (Redmine用) ===== */
.progress-bar-bg {
    width: 100%;
    height: 12px;
    background: var(--bg-darkest);
    border-radius: 6px;
    margin-top: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
}
.progress-danger { background: var(--red); }
.progress-warning { background: var(--orange); }
.progress-success { background: var(--green); }
.progress-info { background: var(--blurple); }
.ticket-status {
    display: flex;
    justify-content: space-between;
    font-size: 0.785714rem;
    margin-top: 4px;
    color: var(--text-muted);
}

/* ===== カレンダービュー (改善UX版) ===== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    background: var(--bg-darkest);
    border-radius: 8px;
    box-shadow: inset 0 2px 8px color-mix(in srgb, var(--shadow-color) 30%, transparent);
}
.cal-header {
    text-align: center;
    font-size: 0.928571rem;
    font-weight: 700;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--bg-lighter);
    margin-bottom: 4px;
}
.cal-day {
    background: var(--bg-dark);
    border: 1px solid var(--bg-lighter);
    border-radius: 6px;
    padding: 6px 0 6px 0;
    min-height: 80px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: background var(--transition), border-color var(--transition);
}
.cal-day:hover {
    background: var(--bg-medium);
    border-color: var(--blurple);
}
.cal-date {
    font-size: 0.857143rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
    align-self: flex-start;
    margin-left: 6px;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
}
.cal-event {
    font-size: 0.785714rem;
    color: var(--on-strong);
    padding: 3px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    text-shadow: 0 1px 2px color-mix(in srgb, var(--shadow-color) 50%, transparent); /* 文字の視認性アップ */
    box-shadow: 0 1px 3px color-mix(in srgb, var(--shadow-color) 15%, transparent); /* 帯の立体感アップ */
}
/* Phones: a day cell is about 38px wide, too narrow to read a title. Events shrink to colour bars
   (the day panel opened by tapping a day lists them in full) and the grid keeps seven equal columns.
   !important is needed because the chip's shape and padding are written inline by generateCalendarHtml(). */
@media (max-width: 560px) {
    .calendar-grid { gap: 4px; padding: 6px; }
    .cal-date-row { padding: 0 2px; }
    .cal-date { margin-left: 2px; }
    .cal-day { min-height: 72px; }
    .calendar-grid .cal-event {
        flex: 0 0 auto;
        height: 6px;
        padding: 0 !important;
        font-size: 0;
        line-height: 0;
        text-shadow: none;
        clip-path: none !important;
    }
}
.cal-empty {
    background: transparent;
    border: none;
}
.cal-empty:hover {
    background: transparent;
    border-color: transparent;
}
.cal-today {
    background: color-mix(in srgb, var(--blurple) 10%, transparent);
    border: 1px solid var(--blurple);
    box-shadow: 0 0 8px color-mix(in srgb, var(--blurple) 20%, transparent);
}
.cal-today .cal-date {
    background: var(--blurple);
    color: var(--on-accent);
    box-shadow: 0 2px 4px color-mix(in srgb, var(--blurple) 40%, transparent);
}

/* ===== サイドバーウィジェット リデザイン ===== */

.sidebar-card-body.clickable-widget {
    cursor: pointer;
    border-radius: 0 0 8px 8px;
    transition: background var(--transition);
}
.sidebar-card-body.clickable-widget:hover {
    background: var(--surface-soft);
}
.widget-expand-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: var(--type-min);
    color: var(--text-muted);
    padding: 5px 0 2px;
    margin-top: 5px;
    border-top: 1px solid var(--bg-lighter);
    letter-spacing: 0.01em;
}
.widget-expand-hint .material-icons { font-size: 0.857143rem; }
.sidebar-card-body.clickable-widget:hover .widget-expand-hint {
    color: var(--blurple);
}

/* ===== ミニカレンダー v2 ===== */
.mini-cal2-month-label {
    font-size: 0.785714rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 5px;
    letter-spacing: 0.03em;
}
.mini-cal2-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}
.mini-cal2-dow {
    text-align: center;
    font-size: var(--type-min);
    font-weight: 700;
    padding: 1px 0 4px;
}
.mini-cal2-dow.dow-sun { color: var(--weekend-sun); }
.mini-cal2-dow.dow-sat { color: var(--weekend-sat); }
.mini-cal2-dow:not(.dow-sun):not(.dow-sat) { color: var(--text-muted); }
.mini-cal2-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1px 0 3px;
    border-radius: 4px;
    min-height: 26px;
}
.mini-cal2-cell:not(.mini-cal2-empty):hover { background: var(--bg-lighter); }
.mini-cal2-num {
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    font-size: var(--type-min);
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 50%;
}
.mini-cal2-cell.mini-cal2-today .mini-cal2-num {
    background: var(--action-bg);
    color: var(--on-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--action-bg) 30%, transparent);
}
.mini-cal2-cell.mini-cal2-sun .mini-cal2-num { color: var(--weekend-sun); }
.mini-cal2-cell.mini-cal2-sat .mini-cal2-num { color: var(--weekend-sat); }
.mini-cal2-cell.mini-cal2-today.mini-cal2-sun .mini-cal2-num,
.mini-cal2-cell.mini-cal2-today.mini-cal2-sat .mini-cal2-num {
    color: var(--on-accent);
}
.mini-cal2-events {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-top: 1px;
    flex-wrap: wrap;
    max-width: 20px;
}
.mini-cal2-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mini-cal2-dot.ev-activity { background: var(--green); }
.mini-cal2-dot.ev-special  { background: var(--cyan); }
.mini-cal2-dot.ev-ticket   { background: var(--orange); }

/* ===== マイスケジュール v2 ===== */
.my-sched2 { display: flex; flex-direction: column; gap: 5px; }
.my-sched2-grid {
    display: grid;
    grid-template-columns: 58px repeat(5, minmax(0, 1fr));
    gap: 4px 3px;
    align-items: stretch;
}
.my-sched2-axis-corner {
    min-height: 16px;
    border-right: 1px solid var(--border-soft);
}
.my-sched2-day-label {
    min-width: 0;
    text-align: center;
    font-size: var(--type-min);
    font-weight: 800;
    color: var(--text-muted);
    line-height: 16px;
    border-radius: 4px;
    background: var(--surface-soft);
}
.my-sched2-time-label {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    padding: 2px 7px 2px 0;
    line-height: 1.12;
    border-right: 1px solid var(--border-soft);
    text-align: right;
    color: var(--text-muted);
}
.my-sched2-time-label strong {
    color: var(--text-secondary);
    font-size: var(--type-min);
    font-weight: 800;
}
.my-sched2-time-label span {
    display: none;
}
.my-sched2-cell {
    min-width: 0;
    height: 24px;
    border-radius: 5px;
    border: 1px solid var(--border-medium);
    box-shadow: inset 0 0 0 1px var(--border-soft);
    transition: filter var(--transition), transform var(--transition), border-color var(--transition);
}
.my-sched2-cell:hover {
    filter: brightness(1.35);
    transform: translateY(-1px);
    border-color: var(--border-strong);
}
.my-sched2-cell[data-state="empty"]           { background: var(--surface-soft); border-color: var(--border-soft); }
.my-sched2-cell[data-state="in_person"]       { background: color-mix(in srgb, var(--in-person) 66%, transparent); border-color: color-mix(in srgb, var(--in-person) 46%, transparent); }
.my-sched2-cell[data-state="online_realtime"] { background: color-mix(in srgb, var(--online-realtime) 66%, transparent); border-color: color-mix(in srgb, var(--online-realtime) 42%, transparent); }
.my-sched2-cell[data-state="online_async"]    { background: color-mix(in srgb, var(--online-async) 64%, transparent); border-color: color-mix(in srgb, var(--online-async) 42%, transparent); }
.my-sched2-cell[data-state="unavailable"]     { background: color-mix(in srgb, var(--unavailable) 54%, transparent); border-color: color-mix(in srgb, var(--unavailable) 38%, transparent); }

/* ===== チャット展開 — フルカレンダー ===== */
.chat-fullcal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-top: 8px;
}
.chat-fullcal-dow {
    text-align: center;
    font-size: 0.785714rem;
    font-weight: 700;
    padding: 3px 0 6px;
    border-bottom: 1px solid var(--bg-lighter);
    margin-bottom: 2px;
}
.chat-fullcal-dow.dow-sun { color: var(--weekend-sun); }
.chat-fullcal-dow.dow-sat { color: var(--weekend-sat); }
.chat-fullcal-dow:not(.dow-sun):not(.dow-sat) { color: var(--text-muted); }
.chat-fullcal-cell {
    min-height: 48px;
    background: var(--bg-light);
    border-radius: 5px;
    padding: 4px 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid transparent;
    transition: border-color var(--transition);
}
.chat-fullcal-cell:hover:not(.chat-fullcal-empty) { border-color: var(--bg-lighter); }
.chat-fullcal-empty { background: transparent; border: none; min-height: unset; }
.chat-fullcal-today {
    background: color-mix(in srgb, var(--blurple) 10%, transparent);
    border-color: var(--blurple) !important;
}
.chat-fullcal-num {
    font-size: 0.785714rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.chat-fullcal-today .chat-fullcal-num { background: var(--action-bg); color: var(--on-accent); }
.chat-fullcal-weekend .chat-fullcal-num { color: var(--text-muted); }
.chat-fullcal-event-chip {
    font-size: var(--type-min);
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--on-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 14px;
}
.chip-activity { background: var(--green-dark); }
.chip-special  { background: var(--green-dark); }
.chip-ticket   { background: color-mix(in srgb, var(--orange) 85%, transparent); color: var(--on-tone); }

/* ===== チャット展開 — マイスケジュールテーブル ===== */
.chat-mysched-table {
    width: 100%;
    min-width: 520px;
    border-collapse: separate;
    border-spacing: 3px;
    margin-top: 8px;
    font-size: 0.857143rem;
}
.chat-mysched-table th {
    text-align: center;
    font-size: var(--type-min);
    font-weight: 700;
    color: var(--text-muted);
    padding: 5px 4px;
    background: var(--bg-dark);
    border-radius: 4px;
    white-space: nowrap;
}
.chat-mysched-table td {
    text-align: center;
    padding: 8px 3px;
    border-radius: 5px;
    font-size: 0.785714rem;
    font-weight: 600;
    min-width: 44px;
}
.chat-mysched-table td.day-cell,
.chat-mysched-table td.time-cell {
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.857143rem;
}
.chat-mysched-table td.time-cell span {
    color: var(--text-muted);
    font-size: var(--type-min);
    font-weight: 500;
    white-space: nowrap;
}
.mysched-empty           { background: var(--bg-dark); color: var(--text-muted); font-weight:400; }
.mysched-in_person       { background: color-mix(in srgb, var(--in-person) 15%, transparent); color: var(--green); }
.mysched-online_realtime { background: color-mix(in srgb, var(--online-realtime) 15%, transparent); color: var(--online-realtime); }
.mysched-online_async    { background: color-mix(in srgb, var(--online-async) 15%, transparent); color: var(--orange); }
.mysched-unavailable     { background: color-mix(in srgb, var(--unavailable) 12%, transparent); color: var(--red); }

/* ===== ユーザーバー（サイドバー最下部）===== */
.user-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-darkest);
    border-top: 1px solid var(--border-soft);
    margin-top: auto;
    flex-shrink: 0;
}
.user-bar-avatar {
    font-size: 1.571429rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: 50%;
    flex-shrink: 0;
}
.user-bar-info {
    flex: 1;
    min-width: 0;
}
.user-bar-name {
    font-size: 0.928571rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-bar-status {
    font-size: 0.785714rem;
    color: var(--text-muted);
}
.user-bar-settings-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), background var(--transition);
    flex-shrink: 0;
}
.user-bar-settings-btn:hover { color: var(--text-primary); background: var(--bg-light); }
.user-bar-settings-btn .material-icons { font-size: 1.428571rem; }
.user-bar-avatar .material-icons { font-size: 1.285714rem; color: var(--text-secondary); }

/* ===== 個人設定ページ ===== */
.settings-page {
    padding: 24px 28px;
    width: min(100%, 960px);
    max-width: 960px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow: visible;
    height: auto;
    flex: 0 0 auto;
}
.settings-page-with-nav {
    width: min(100%, 1160px);
    max-width: 1160px;
}
.settings-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 22px;
    align-items: flex-start;
}
.settings-nav {
    position: sticky;
    top: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px 10px;
    border-radius: 10px;
    background: var(--bg-dark);
    border: 1px solid var(--bg-lighter);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}
.settings-nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-nav-group-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: var(--type-min);
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.settings-nav-group-title .material-icons {
    font-size: 1rem;
    color: var(--blurple);
}
.settings-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.892857rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
}
.settings-nav-link .material-icons {
    font-size: 1.142857rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.settings-nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-light);
}
.settings-nav-link.is-active {
    color: var(--text-primary);
    background: var(--bg-lighter);
}
.settings-nav-link.is-active .material-icons {
    color: var(--blurple);
}
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}
.settings-calendar-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--bg-lighter);
    background: var(--bg-darker, var(--surface-inset));
}
/* display: flex が hidden 属性に勝ってしまうので、閉じた選択欄は確実に隠す */
.settings-calendar-picker[hidden] {
    display: none;
}
.settings-calendar-picker-label {
    font-size: 0.785714rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.settings-calendar-picker-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
@media (max-width: 900px) {
    .settings-page-with-nav {
        width: 100%;
        max-width: 100%;
    }
    .settings-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .settings-nav {
        position: relative;
        top: 0;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        max-height: none;
        overflow-x: auto;
    }
    .settings-nav-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
    }
}
.settings-mode-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    max-width: 100%;
    padding: 4px;
    border: 1px solid var(--bg-lighter);
    border-radius: 8px;
    background: var(--bg-dark);
    overflow-x: auto;
}
.settings-mode-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 7px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.928571rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.settings-mode-tab:hover {
    color: var(--text-primary);
    background: var(--bg-light);
}
.settings-mode-tab.is-active {
    color: var(--text-primary);
    background: var(--bg-lighter);
}
.settings-mode-tab .material-icons {
    font-size: 1.285714rem;
}
.settings-section {
    background: var(--bg-dark);
    border-radius: 8px;
    overflow: hidden;
    flex: 0 0 auto;
}
.settings-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-light);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--bg-lighter);
}
.settings-section-title .material-icons { font-size: 1.285714rem; color: var(--blurple); }
.settings-section-title-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.settings-role-title {
    justify-content: space-between;
}
.settings-permission-reload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--bg-lighter);
    border-radius: 6px;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.857143rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}
.settings-permission-reload-btn:hover {
    color: var(--text-primary);
    border-color: var(--blurple);
    background: var(--surface-medium);
}
.settings-permission-reload-btn:disabled {
    cursor: wait;
    opacity: 0.7;
}
.settings-permission-reload-btn .material-icons {
    font-size: 1.214286rem;
}
.settings-permission-reload-btn.is-loading .material-icons {
    animation: spin-slow 1.2s linear infinite;
}
.settings-role-box {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.settings-role-label {
    font-size: 0.785714rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.settings-role-badge {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.928571rem;
    font-weight: 700;
}
.settings-role-badge .material-icons {
    margin-right: 5px;
    font-size: 1.142857rem;
}
.settings-role-admin {
    background: color-mix(in srgb, var(--tone-success) 14%, transparent);
    color: var(--tone-success-text);
    border: 1px solid color-mix(in srgb, var(--tone-success) 35%, transparent);
}
.settings-role-member {
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
    color: var(--accent-text);
    border: 1px solid color-mix(in srgb, var(--blurple) 30%, transparent);
}
.settings-role-note {
    font-size: 0.857143rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.settings-fields {
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.settings-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.settings-field-wide { grid-column: span 2; }
.settings-field label {
    font-size: 0.785714rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.settings-field .discord-input { width: 100%; }
.settings-field .discord-input,
.settings-field .discord-select {
    min-width: 0;
}
.settings-theme-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.settings-theme-option {
    min-width: 0;
}
/* 言語切替: 個人設定の先頭に置く */
.settings-language-section {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 34%, transparent);
}
.settings-language-section .settings-save-msg {
    margin-left: auto;
    font-weight: 600;
}
.settings-language-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
}
.settings-language-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.settings-language-option {
    min-width: 0;
    min-height: 52px;
}
.settings-language-glyph {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--surface-medium);
    color: var(--text-primary);
    font-size: 1.142857rem;
    font-weight: 800;
    line-height: 1;
}
.settings-language-glyph .material-icons {
    font-size: 1.285714rem;
}
.settings-language-option.active .settings-language-glyph {
    background: var(--blurple);
    color: var(--on-accent);
}
.settings-language-detected {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.857143rem;
    font-weight: 600;
}
.settings-language-detected .material-icons {
    font-size: 1.142857rem;
    color: var(--blurple);
}
.settings-language-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.857143rem;
    line-height: 1.6;
}
.settings-check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    color: var(--text-primary) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 0.928571rem !important;
    font-weight: 600 !important;
    cursor: pointer;
}
.settings-check-label input {
    accent-color: var(--blurple);
}
.settings-check-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 12px;
}
.settings-hint {
    padding: 10px 16px;
    font-size: 0.857143rem;
    color: var(--text-muted);
    line-height: 1.6;
    border-bottom: 1px solid var(--bg-lighter);
}
/* 手入力・上級者向けの操作は畳んでおき、主な操作だけを先に見せる */
.settings-manual-link {
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px dashed var(--bg-lighter);
    border-radius: 8px;
}
.settings-manual-link > summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.857143rem;
}
.settings-manual-link[open] > summary {
    margin-bottom: 8px;
}
.settings-manual-link .settings-hint {
    padding: 6px 0 0;
    border-bottom: none;
}
.settings-next-step {
    margin: 8px 0 6px;
    color: var(--text-secondary);
    font-size: 0.857143rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.settings-optional-block {
    margin: 0 16px 12px;
}
.settings-optional-block > summary {
    cursor: pointer;
    padding: 8px 0;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.928571rem;
}
.settings-field > .settings-hint {
    padding: 0;
    border-bottom: 0;
}
.settings-hint code {
    color: var(--text-primary);
    background: var(--surface-medium);
    border-radius: 4px;
    padding: 1px 5px;
}
.settings-apikey-row {
    display: flex;
    gap: 6px;
}
.settings-apikey-row .discord-input { flex: 1; }
.settings-account-link-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(3, auto);
    gap: 8px;
    align-items: center;
}
.settings-calendar-link-row {
    grid-template-columns: repeat(2, max-content);
    justify-content: start;
}
.settings-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    background: var(--bg-light);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.928571rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition);
}
.settings-link-btn:hover {
    background: var(--bg-lighter);
    border-color: var(--blurple);
}
.settings-link-btn:disabled {
    opacity: 0.62;
    cursor: wait;
}
.settings-link-btn-check {
    color: var(--tone-success);
    border-color: var(--tone-success-border);
}
.settings-link-btn-official {
    color: var(--accent-text);
    border-color: var(--state-active-border);
}
.settings-link-btn .material-icons {
    font-size: 1.285714rem;
}
.settings-line-friend-qr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    background: var(--surface-soft);
}
.settings-line-friend-qr-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 144px;
    height: 144px;
    padding: 8px;
    border-radius: 6px;
    background: var(--white);
    box-sizing: border-box;
}
.settings-line-friend-qr-image img {
    width: 128px;
    height: 128px;
    object-fit: contain;
    display: block;
}
.settings-line-friend-qr-info {
    min-width: 0;
}
.settings-line-friend-qr-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}
.settings-line-friend-qr-title .material-icons {
    color: var(--tone-success);
    font-size: 1.285714rem;
}
.settings-line-friend-qr-id {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 0.928571rem;
    font-weight: 700;
    word-break: break-all;
}
.settings-line-friend-qr .settings-hint {
    margin-top: 6px;
    padding: 0;
    border-bottom: 0;
}
.settings-line-friend-qr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.settings-line-friend-qr-actions .settings-link-btn {
    min-height: 34px;
    padding: 7px 10px;
}
.settings-integration-overview {
    margin: 10px 16px 0;
    padding: 12px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    background: var(--surface-soft);
}
.settings-integration-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.settings-integration-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--text-primary);
    font-size: 1rem;
}
.settings-integration-title .material-icons {
    font-size: 1.357143rem;
    color: var(--text-muted);
}
.settings-integration-score {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--bg-modifier-accent);
    color: var(--text-secondary);
    font-size: 0.857143rem;
    font-weight: 700;
    white-space: nowrap;
}
.settings-integration-score.is-ok {
    border-color: var(--tone-success-border);
    color: var(--tone-success);
    background: var(--tone-success-soft);
}
.settings-integration-score.is-warn {
    border-color: var(--tone-warning-border);
    color: var(--tone-warning);
    background: var(--tone-warning-soft);
}
.settings-integration-score.is-error {
    border-color: var(--tone-danger-border);
    color: var(--tone-danger);
    background: var(--tone-danger-soft);
}
.settings-integration-lamp-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.settings-integration-lamp {
    display: grid;
    grid-template-columns: 10px 20px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    padding: 9px 10px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
    color: var(--text-secondary);
    font-family: var(--font);
    text-align: left;
    cursor: pointer;
    appearance: none;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.settings-integration-lamp:hover {
    background: var(--state-hover);
    border-color: var(--state-active-border);
}
.settings-integration-lamp:focus-visible {
    outline: 2px solid var(--blurple);
    outline-offset: 2px;
}
.settings-integration-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 3px var(--surface-soft);
}
.settings-integration-lamp .material-icons {
    font-size: 1.357143rem;
    color: var(--text-muted);
}
.settings-integration-main {
    min-width: 0;
}
.settings-integration-main strong,
.settings-integration-main small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.settings-integration-main strong {
    color: var(--text-primary);
    font-size: 0.928571rem;
}
.settings-integration-main small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.785714rem;
}
.settings-integration-label {
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--surface-medium);
    color: var(--text-secondary);
    font-size: 0.785714rem;
    font-weight: 700;
    white-space: nowrap;
}
.settings-integration-lamp-ok {
    border-color: color-mix(in srgb, var(--tone-success) 28%, transparent);
}
.settings-integration-lamp-ok .settings-integration-light {
    background: var(--tone-success);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone-success) 12%, transparent), 0 0 12px color-mix(in srgb, var(--tone-success) 45%, transparent);
}
.settings-integration-lamp-ok .material-icons,
.settings-integration-lamp-ok .settings-integration-label {
    color: var(--tone-success);
}
.settings-integration-lamp-warn {
    border-color: color-mix(in srgb, var(--tone-warning) 28%, transparent);
}
.settings-integration-lamp-warn .settings-integration-light {
    background: var(--tone-warning);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone-warning) 12%, transparent), 0 0 12px color-mix(in srgb, var(--tone-warning) 42%, transparent);
}
.settings-integration-lamp-warn .material-icons,
.settings-integration-lamp-warn .settings-integration-label {
    color: var(--tone-warning);
}
.settings-integration-lamp-error {
    border-color: color-mix(in srgb, var(--tone-danger) 35%, transparent);
}
.settings-integration-lamp-error .settings-integration-light {
    background: var(--tone-danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone-danger) 13%, transparent), 0 0 12px color-mix(in srgb, var(--tone-danger) 45%, transparent);
}
.settings-integration-lamp-error .material-icons,
.settings-integration-lamp-error .settings-integration-label {
    color: var(--tone-danger);
}
.settings-integration-lamp-empty .settings-integration-light {
    background: var(--text-muted);
}
.settings-link-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    min-height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-medium);
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 0.857143rem;
    line-height: 1.4;
}
.settings-link-status .material-icons {
    font-size: 1.214286rem;
    flex: 0 0 auto;
}
.settings-link-status strong {
    color: var(--text-primary);
    white-space: nowrap;
}
/* Narrow screens: icon, state and explanation do not fit on one line, so the explanation drops below. */
.settings-link-status { flex-wrap: wrap; }
.settings-link-status > span:not(.material-icons) { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.settings-link-status.is-ok { border-color: var(--tone-success-border); background: var(--tone-success-soft); }
.settings-link-status.is-ok .material-icons { color: var(--tone-success); }
.settings-link-status.is-warn { border-color: var(--tone-warning-border); background: var(--tone-warning-soft); }
.settings-link-status.is-warn .material-icons { color: var(--tone-warning); }
.settings-link-status.is-error { border-color: var(--tone-danger-border); background: var(--tone-danger-soft); }
.settings-link-status.is-error .material-icons { color: var(--tone-danger); }
.settings-link-status.is-empty .material-icons { color: var(--text-muted); }
.settings-line-official-friend-status {
    margin-top: 10px;
}
.settings-toggle-btn {
    background: var(--bg-light);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: background var(--transition);
}
.settings-toggle-btn:hover { background: var(--bg-lighter); color: var(--text-primary); }
.settings-toggle-btn .material-icons { font-size: 1.285714rem; }
.settings-link-row {
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.settings-ext-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.857143rem;
    color: var(--blurple);
    text-decoration: none;
    padding: 4px 10px;
    background: color-mix(in srgb, var(--blurple) 10%, transparent);
    border-radius: 4px;
    transition: background var(--transition);
}
.settings-ext-link:hover { background: color-mix(in srgb, var(--blurple) 20%, transparent); }
.settings-ext-link .material-icons { font-size: 1rem; }
.message-avatar .material-icons {
    color: var(--on-strong);
    font-size: 1.428571rem;
}

.settings-save-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0;
}
.settings-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 20px;
    background: var(--blurple);
    color: var(--on-accent);
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition);
}
.settings-save-btn:hover { background: var(--blurple-hover); }
.settings-save-btn .material-icons { font-size: 1.285714rem; }
.settings-save-msg {
    font-size: 0.928571rem;
    color: var(--green);
    font-weight: 600;
}

/* btn-orange (Redmineプロジェクト用) */
.btn-orange { background: var(--orange); color: var(--on-tone); }
.btn-orange:hover { background: var(--orange); }

/* ===== Redmine チャット操作カード ===== */
.task-menu-embed,
.rm-task-embed {
    max-width: 720px;
}

.task-menu-panel {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.task-menu-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.task-menu-head-icon {
    width: 42px;
    min-width: 42px;
    height: 42px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--orange) 18%, transparent);
    color: var(--orange);
    font-size: 1.642857rem;
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

.task-menu-head-copy {
    min-width: 0;
}

.task-menu-title {
    font-size: 1.071429rem;
    font-weight: 800;
    color: var(--text-primary);
}

.task-menu-text {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 0.857143rem;
    line-height: 1.5;
}

.task-menu-project {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 0.857143rem;
}

.task-menu-project .material-icons {
    color: var(--orange);
    font-size: 1.214286rem;
}

.task-menu-project strong {
    color: var(--text-primary);
}

.rm-task-list-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.rm-task-list-title .material-icons {
    color: var(--orange);
}

.rm-task-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rm-task-empty {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 2px 10px;
    align-items: center;
    padding: 14px;
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text-secondary);
}

.rm-task-empty .material-icons {
    grid-row: span 2;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
    color: var(--text-muted);
}

.rm-task-empty strong {
    color: var(--text-primary);
    font-size: 0.928571rem;
}

.rm-task-empty span:last-child {
    font-size: 0.857143rem;
    color: var(--text-muted);
}

.rm-task-card {
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 11px 12px;
    background: var(--surface-soft);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--border-medium);
    cursor: pointer;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    text-align: left;
    font-family: var(--font);
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}

.rm-task-card:hover {
    background: var(--surface-medium);
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 24%, transparent), 0 12px 24px var(--border-strong);
}

.rm-task-icon {
    width: 38px;
    min-width: 38px;
    height: 38px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--tone-info) 13%, transparent);
    color: var(--cyan);
    font-size: 1.5rem;
}

.rm-task-card.warning .rm-task-icon {
    background: color-mix(in srgb, var(--tone-warning) 16%, transparent);
    color: var(--orange);
}

.rm-task-card.overdue .rm-task-icon {
    background: color-mix(in srgb, var(--tone-danger) 16%, transparent);
    color: var(--red);
}

.rm-task-card.done .rm-task-icon {
    background: color-mix(in srgb, var(--tone-success) 14%, transparent);
    color: var(--green);
}

/* ===== 未割当一覧 ===== */
.unassigned-page {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 2px 0 18px;
}

.unassigned-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}

.unassigned-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.unassigned-title > .material-icons {
    width: 42px;
    min-width: 42px;
    height: 42px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--orange) 16%, transparent);
    color: var(--orange);
    font-size: 1.642857rem;
}

.unassigned-title strong {
    display: block;
    color: var(--text-primary);
    font-size: 1.285714rem;
}

.unassigned-title span:not(.material-icons) {
    color: var(--text-secondary);
    font-size: 0.857143rem;
}

.unassigned-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.unassigned-sort {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 8px;
    background: var(--surface-medium);
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

.unassigned-sort button {
    border: none;
    border-radius: 6px;
    padding: 7px 10px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.857143rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.unassigned-sort button.active {
    background: var(--action-bg);
    color: var(--on-accent);
    font-weight: 800;
}

.unassigned-sort .material-icons {
    font-size: 1.142857rem;
}

.unassigned-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.unassigned-summary > div {
    min-width: 0;
    padding: 11px 12px;
    border-radius: 8px;
    background: var(--surface-soft);
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

.unassigned-summary strong,
.unassigned-summary span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unassigned-summary strong {
    color: var(--text-primary);
    font-size: 1.285714rem;
}

.unassigned-summary span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.785714rem;
}

.unassigned-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 11px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--tone-info) 10%, transparent);
    color: var(--text-secondary);
    font-size: 0.857143rem;
}

.unassigned-status .material-icons {
    color: var(--cyan);
    font-size: 1.142857rem;
}

.unassigned-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.unassigned-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 11px;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-soft);
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

.unassigned-card.overdue {
    box-shadow: inset 3px 0 0 var(--red), inset 0 0 0 1px var(--border-medium);
}

.unassigned-card.warning {
    box-shadow: inset 3px 0 0 var(--orange), inset 0 0 0 1px var(--border-medium);
}

.unassigned-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--tone-info) 13%, transparent);
    color: var(--cyan);
    display: grid;
    place-items: center;
}

.unassigned-card.overdue .unassigned-card-icon {
    background: color-mix(in srgb, var(--tone-danger) 16%, transparent);
    color: var(--red);
}

.unassigned-card.warning .unassigned-card-icon {
    background: color-mix(in srgb, var(--tone-warning) 16%, transparent);
    color: var(--orange);
}

.unassigned-card-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.unassigned-card-title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.unassigned-card-title strong {
    color: var(--text-primary);
    font-size: 0.928571rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.unassigned-icon-link {
    width: 32px;
    min-width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-grid;
    place-items: center;
    color: var(--text-secondary);
    background: var(--surface-soft);
    text-decoration: none;
}

.unassigned-icon-link .material-icons {
    font-size: 1.142857rem;
}

.unassigned-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.785714rem;
}

.unassigned-card-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--surface-soft);
    box-shadow: inset 0 0 0 1px var(--border-soft);
}

.unassigned-card-meta .material-icons {
    font-size: 1rem;
}

.unassigned-card-side {
    display: flex;
    align-items: center;
    gap: 9px;
}

.unassigned-due {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 96px;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.857143rem;
    font-weight: 700;
}

.unassigned-due.warning { color: var(--orange); }
.unassigned-due.overdue { color: var(--red); }
.unassigned-due .material-icons { font-size: 1.142857rem; }

.unassigned-claim-btn {
    border: none;
    border-radius: 8px;
    min-height: 36px;
    padding: 0 12px;
    background: var(--blurple);
    color: var(--on-accent);
    font: inherit;
    font-size: 0.857143rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.unassigned-claim-btn .material-icons {
    font-size: 1.214286rem;
}

.unassigned-empty {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 3px 11px;
    align-items: center;
    padding: 18px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text-secondary);
}

.unassigned-empty .material-icons {
    grid-row: span 2;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
    color: var(--text-muted);
}

.unassigned-empty strong {
    color: var(--text-primary);
}

@media (max-width: 760px) {
    .unassigned-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .unassigned-card {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .unassigned-card-side {
        grid-column: 1 / -1;
        justify-content: space-between;
    }
}

.rm-task-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.rm-task-title {
    color: var(--text-primary);
    font-size: 0.928571rem;
    line-height: 1.4;
}

.rm-task-title strong {
    font-weight: 800;
}

.rm-task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.785714rem;
}

.rm-task-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 22px;
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--surface-soft);
}

.rm-task-meta .material-icons {
    font-size: 0.928571rem;
    color: var(--text-muted);
}

.rm-task-progress {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) 38px;
    align-items: center;
    gap: 8px;
}

.rm-task-progress .progress-bar-bg {
    width: 100%;
    height: 8px;
}

.rm-task-progress strong {
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.857143rem;
    text-align: right;
}

.rm-task-due {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    padding: 6px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tone-info) 10%, transparent);
    color: var(--cyan);
    font-size: 0.857143rem;
    font-weight: 700;
    white-space: nowrap;
}

.rm-task-due .material-icons {
    font-size: 1rem;
}

.rm-task-card.warning .rm-task-due {
    background: color-mix(in srgb, var(--tone-warning) 13%, transparent);
    color: var(--orange);
}

.rm-task-card.overdue .rm-task-due {
    background: color-mix(in srgb, var(--tone-danger) 13%, transparent);
    color: var(--red);
}

.rm-task-card.done .rm-task-due {
    background: color-mix(in srgb, var(--tone-success) 12%, transparent);
    color: var(--green);
}

@media (max-width: 720px) {
    .action-btn.has-visual {
        flex: 1 1 100%;
    }

    .rm-task-card {
        grid-template-columns: 38px minmax(0, 1fr);
        align-items: start;
    }

    .rm-task-due {
        grid-column: 2;
        justify-self: start;
    }
}

/* ===== カレンダー専用ページ ===== */
.cal-page {
    display: flex;
    flex-direction: row;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.cal-page-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.cal-page-title {
    flex: 1;
    text-align: center;
    font-size: 1.428571rem;
    font-weight: 700;
    color: var(--text-primary);
}
.cal-page-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 14px;
    background: var(--bg-light);
    color: var(--text-primary);
    border: none;
    border-radius: 6px;
    font-size: 0.928571rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}
.cal-page-nav-btn:hover { background: var(--blurple); }
.cal-page-nav-btn .material-icons { font-size: 1.285714rem; }
.cal-page-today-btn { background: color-mix(in srgb, var(--blurple) 20%, transparent); color: var(--blurple); }
.cal-page-today-btn:hover { background: var(--blurple); color: var(--on-accent); }
.cal-page-legend {
    display: flex;
    gap: 18px;
    font-size: 0.857143rem;
    color: var(--text-muted);
    flex-shrink: 0;
}
.cal-page-legend span { display: flex; align-items: center; gap: 5px; }
.cal-page-legend-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-page-legend-dot.activity { background: var(--green); }
.cal-page-legend-dot.spevent  { background: var(--event-special); }
.cal-page-legend-dot.ticket   { background: var(--orange); }
.cal-page-legend-dot.gathering { background: var(--cat-2); }
.cal-page-legend-dot.reminder  { background: var(--cat-3); }
.cal-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid var(--bg-lighter);
    margin-bottom: 6px;
}
.cal-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid var(--bg-lighter);
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 0.857143rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.cal-tab:hover {
    color: var(--text-primary);
    background: var(--bg-light);
}
.cal-tab.active {
    background: var(--blurple);
    color: var(--on-accent);
    border-color: var(--blurple);
}
.cal-tab .material-icons {
    font-size: 1rem;
}
.cal-tab-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--surface-strong);
    font-size: var(--type-min);
    font-weight: 700;
}
.cal-item-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 6px 0;
    font-size: 0.857143rem;
    color: var(--text-secondary);
}
.cal-item-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.cal-item-filter input[type="checkbox"] {
    accent-color: var(--blurple);
    cursor: pointer;
}
.cal-filter-lock { font-size: 0.857143rem; color: var(--text-muted); margin-left: -2px; }
.cal-sort { margin-left: auto; }
.cal-sort-select {
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--bg-lighter);
    background: var(--bg-dark);
    color: var(--text-primary);
    font: inherit;
    cursor: pointer;
}
.cal-page-body {
    flex: 1;
    min-height: 0;
}
.cal-page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
    padding-bottom: 8px;
}
.cal-page-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.928571rem;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition), opacity var(--transition);
}
.cal-page-action-btn .material-icons { font-size: 1.142857rem; }
.cal-page-action-btn.btn-blurple { background: var(--blurple); color: var(--on-accent); }
.cal-page-action-btn.btn-blurple:hover { background: var(--blurple-hover); }
.cal-page-action-btn.btn-orange { background: var(--orange); color: var(--on-tone); }
.cal-page-action-btn.btn-orange:hover { filter: brightness(1.05); }
.cal-page-action-btn.btn-gray { background: var(--bg-light); color: var(--text-primary); }
.cal-page-action-btn.btn-gray:hover { background: var(--bg-lighter); }
.cal-page-action-btn.btn-green { background: var(--green-dark); color: var(--on-strong); }
.cal-page-action-btn.btn-green:hover { background: var(--green-dark); }

/* ===== Redmine プロジェクトバッジ (チャット用) ===== */
.rm-proj-badge {
    display: inline-block;
    padding: 2px 8px;
    background: color-mix(in srgb, var(--orange) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--orange) 35%, transparent);
    border-radius: var(--radius-sm);
    font-size: 0.857143rem;
    color: var(--orange-text);
    text-decoration: none;
    margin-right: 4px;
    transition: background var(--transition);
}
a.rm-proj-badge:hover { background: color-mix(in srgb, var(--orange) 30%, transparent); }

/* ===== カレンダーページ 左カラム ===== */
.cal-page-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 20px 16px;
    overflow-y: auto;
    min-width: 0;
}

/* カレンダーの日付セル: 日付行+追加ボタン */
.cal-date-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    margin-bottom: 2px;
}
.cal-add-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    border-radius: 3px;
    transition: color var(--transition), background var(--transition);
}
.cal-add-btn .material-icons { font-size: 1rem; }
.cal-day:hover .cal-add-btn { display: flex; }
.cal-add-btn:hover { color: var(--blurple); background: color-mix(in srgb, var(--blurple) 15%, transparent); }
.cal-day.selected {
    border-color: var(--blurple) !important;
    background: color-mix(in srgb, var(--blurple) 12%, transparent) !important;
}
.cal-page-legend-dot.personal { background: var(--violet); }

/* ===== 日付詳細パネル (右カラム) ===== */
.cal-day-panel {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-dark);
    border-left: 1px solid var(--bg-lighter);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.cal-day-panel-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.928571rem;
    text-align: center;
    line-height: 1.6;
    padding: 24px;
}
.cal-day-panel-empty .material-icons { font-size: 2.571429rem; opacity: 0.4; }
.cdp-header {
    display: flex;
    align-items: center;
    padding: 12px 14px 10px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--bg-lighter);
    gap: 8px;
    flex-shrink: 0;
}
.cdp-title { flex: 1; font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.cdp-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 2px; border-radius: 3px; display: flex; align-items: center;
    transition: color var(--transition);
}
.cdp-close:hover { color: var(--text-primary); }
.cdp-close .material-icons { font-size: 1.285714rem; }
.cdp-body { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.cdp-section-title {
    display: flex; align-items: center; gap: 4px;
    font-size: var(--type-min); font-weight: 700; text-transform: uppercase;
    color: var(--text-muted); letter-spacing: 0.05em;
    padding: 6px 4px 2px; border-bottom: 1px solid var(--bg-lighter);
}
.cdp-section-title .material-icons { font-size: 0.928571rem; }
.cdp-item {
    display: flex; align-items: flex-start; gap: 8px;
    background: var(--bg-medium); border-radius: 6px; padding: 8px 10px;
    font-size: 0.857143rem;
}
.cdp-item-icon { font-size: 1.142857rem; flex-shrink: 0; margin-top: 1px; }
.cdp-item-body { flex: 1; min-width: 0; }
.cdp-item-title { font-weight: 600; color: var(--text-primary); line-height: 1.4; word-break: break-word; }
.cdp-item-sub { font-size: 0.785714rem; color: var(--text-muted); margin-top: 3px; }
.cdp-item-group { border-left: 3px solid var(--green); }
.cdp-item-group.cdp-item-gathering { border-left-color: var(--cat-2); }
.cdp-item-group.cdp-item-reminder { border-left: 3px dashed var(--cat-3); }
.cdp-badge-restricted {
    display: inline-flex; align-items: center; gap: 2px;
    background: var(--surface-strong); color: var(--text-secondary);
}
.cdp-badge-restricted .material-icons { font-size: 0.8125rem; }
.cdp-item-ticket { border-left: 3px solid var(--orange); flex-direction: column; }
.cdp-item-personal { border-left: 3px solid var(--violet); }
.cdp-badge {
    display: inline-block; padding: 0 5px; border-radius: 3px;
    font-size: var(--type-min); font-weight: 700; vertical-align: middle; margin-left: 4px;
}
.cdp-badge-due   { background: color-mix(in srgb, var(--tone-danger) 20%, transparent); color: var(--red); }
.cdp-badge-start { background: color-mix(in srgb, var(--tone-success) 20%, transparent); color: var(--green); }
.cdp-progress-bar {
    height: 4px; background: var(--bg-lighter); border-radius: 2px; margin: 5px 0 2px; overflow: hidden;
}
.cdp-progress-fill { height: 100%; background: var(--blurple); border-radius: 2px; transition: width 0.3s; }
.cdp-progress-fill.cdp-prog-done { background: var(--green); }
.cdp-progress-fill.cdp-prog-mid  { background: var(--orange); }
.cdp-del-btn {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 0; flex-shrink: 0; display: flex; align-items: center;
}
.cdp-del-btn:hover { color: var(--red); }
.cdp-del-btn .material-icons { font-size: 1rem; }
.cdp-item-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.cdp-icon-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
}
.cdp-icon-btn:hover {
    color: var(--text-primary);
    background: var(--bg-light);
    border-color: var(--bg-lighter);
}
.cdp-icon-btn.is-danger:hover { color: var(--red); }
.cdp-icon-btn .material-icons { font-size: 1.071429rem; }
.cdp-empty {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; color: var(--text-muted); font-size: 0.857143rem; padding: 20px 0;
}
.cdp-empty .material-icons { font-size: 2rem; opacity: 0.4; }
.cdp-footer {
    padding: 10px 12px; border-top: 1px solid var(--bg-lighter); flex-shrink: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.cdp-add-btn {
    display: flex; align-items: center; gap: 6px; width: 100%;
    padding: 7px 12px; background: color-mix(in srgb, var(--blurple) 15%, transparent); color: var(--blurple);
    border: 1px solid color-mix(in srgb, var(--blurple) 30%, transparent); border-radius: 6px;
    font-size: 0.928571rem; font-family: var(--font); cursor: pointer;
    transition: background var(--transition);
    justify-content: center;
}
.cdp-add-btn:hover { background: color-mix(in srgb, var(--blurple) 30%, transparent); }
.cdp-add-btn .material-icons { font-size: 1.142857rem; }
.cdp-action-ticket { color: var(--orange); border-color: color-mix(in srgb, var(--orange) 35%, transparent); background: color-mix(in srgb, var(--orange) 13%, transparent); }
.cdp-action-ticket:hover { background: color-mix(in srgb, var(--orange) 24%, transparent); }
.cdp-action-notify { color: var(--tone-danger); border-color: color-mix(in srgb, var(--tone-danger) 35%, transparent); background: color-mix(in srgb, var(--tone-danger) 12%, transparent); }
.cdp-action-notify:hover { background: color-mix(in srgb, var(--tone-danger) 22%, transparent); }
.cdp-action-reminder { color: var(--tone-warning); border-color: color-mix(in srgb, var(--tone-warning) 35%, transparent); background: color-mix(in srgb, var(--tone-warning) 12%, transparent); }
.cdp-action-reminder:hover { background: color-mix(in srgb, var(--tone-warning) 22%, transparent); }

/* ===== イベント登録モーダル: タイプタブ ===== */
.ev-type-tabs { display: flex; gap: 6px; margin-top: 4px; }
.ev-type-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 8px; background: var(--bg-light); color: var(--text-muted);
    border: 1px solid var(--bg-lighter); border-radius: 6px;
    font-size: 0.928571rem; font-family: var(--font); cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.ev-type-tab .material-icons { font-size: 1.142857rem; }
.ev-type-tab:hover { background: var(--bg-lighter); color: var(--text-primary); }
.ev-type-tab.active { background: color-mix(in srgb, var(--blurple) 20%, transparent); color: var(--blurple); border-color: color-mix(in srgb, var(--blurple) 40%, transparent); }
.ev-type-tab:disabled { opacity: 0.55; cursor: not-allowed; }
.ev-time-mode-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.ev-time-mode-row .discord-select { flex: 1; min-width: 0; }
.ev-time-detail-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 10px;
    border: 1px solid var(--bg-lighter);
    border-radius: 6px;
    background: var(--bg-light);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.857143rem;
    cursor: pointer;
    white-space: nowrap;
}
.ev-time-detail-btn .material-icons { font-size: 1.071429rem; }
.ev-time-detail-btn.active {
    color: var(--blurple);
    border-color: color-mix(in srgb, var(--blurple) 45%, transparent);
    background: color-mix(in srgb, var(--blurple) 16%, transparent);
}
.ev-custom-time-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

/* ===== プロジェクトダッシュボード ===== */
.pd-page {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100%;
    flex: 0 0 auto;
    overflow: visible;
    box-sizing: border-box;
}
.pd-header {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.pd-header > .material-icons { font-size: 1.714286rem; color: var(--blurple); }
.pd-header-title { font-size: 1.428571rem; font-weight: 700; flex: 1 1 200px; min-width: 0; }
.pd-action-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 14px; background: var(--blurple); color: var(--on-accent);
    border: none; border-radius: 6px; font-size: 0.928571rem; font-family: var(--font);
    cursor: pointer; transition: background var(--transition);
}
.pd-action-btn:hover { background: var(--blurple-hover); }
.pd-action-btn .material-icons { font-size: 1.142857rem; }
.pd-proj-tabs { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.pd-proj-tab {
    padding: 6px 14px; background: var(--bg-light); color: var(--text-muted);
    border: none; border-radius: 5px; font-size: 0.928571rem; font-family: var(--font); cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.pd-proj-tab.active { background: var(--blurple); color: var(--on-accent); }
/* サマリーカード */
.pd-summary-row { display: flex; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
.pd-summary-card {
    flex: 1; min-width: 80px; padding: 14px 16px;
    border-radius: 8px; background: var(--bg-dark);
    border-top: 3px solid transparent; text-align: center;
}
.pd-card-total   { border-color: var(--text-muted); }
.pd-card-open    { border-color: var(--blurple); }
.pd-card-overdue { border-color: var(--red); }
.pd-card-closed  { border-color: var(--green); }
.pd-card-progress { border-color: var(--orange); }
.pd-sum-num { font-size: 1.857143rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.pd-sum-label { font-size: 0.785714rem; color: var(--text-muted); margin-top: 4px; }
/* メイングリッド */
.pd-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 16px;
    min-height: 0;
    overflow: visible;
}
@media (max-width: 760px) {
    .pd-main-grid { grid-template-columns: minmax(0, 1fr); }
}
.pd-section {
    background: var(--bg-dark); border-radius: 8px; overflow: hidden;
    display: flex; flex-direction: column; min-height: 0;
}
.pd-section-title {
    display: flex; align-items: center; gap: 6px;
    padding: 12px 16px; background: var(--bg-light);
    font-size: 0.928571rem; font-weight: 700; color: var(--text-secondary);
    border-bottom: 1px solid var(--bg-lighter);
}
.pd-section-title .material-icons { font-size: 1.142857rem; color: var(--blurple); }
.pd-member-cards {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
    overflow: visible;
}
.pd-member-card {
    padding: 14px 16px; border-bottom: 1px solid var(--bg-lighter);
    display: flex; flex-direction: column; gap: 10px;
}
.pd-member-card:last-child { border-bottom: none; }
.pd-member-header { display: flex; align-items: center; gap: 10px; }
.pd-member-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--blurple); color: var(--on-accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.142857rem; font-weight: 700; flex-shrink: 0;
}
.pd-member-info { flex: 1; }
.pd-member-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.pd-member-sub { font-size: 0.785714rem; color: var(--text-muted); }
.pd-member-bars { display: flex; flex-direction: column; gap: 6px; }
.pd-bar-row { display: flex; align-items: center; gap: 8px; }
.pd-bar-label { font-size: 0.785714rem; color: var(--text-muted); width: 28px; flex-shrink: 0; }
.pd-bar-bg {
    flex: 1; height: 8px; background: var(--bg-lighter); border-radius: 4px; overflow: hidden;
}
.pd-bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.pd-bar-hours   { background: var(--blurple); }
.pd-bar-tickets { background: var(--cyan); }
.pd-prio-urgent { background: var(--red); }
.pd-prio-high   { background: var(--orange); }
.pd-prio-normal { background: var(--blurple); }
.pd-prio-low    { background: var(--green-dark); }
.pd-bar-val { font-size: 0.785714rem; color: var(--text-muted); width: 30px; text-align: right; flex-shrink: 0; }
.pd-member-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.pd-badge {
    padding: 2px 7px; border-radius: 10px; font-size: 0.785714rem; font-weight: 600;
}
.pd-badge-open    { background: color-mix(in srgb, var(--blurple) 20%, transparent); color: var(--blurple); }
.pd-badge-overdue { background: color-mix(in srgb, var(--tone-danger) 20%, transparent);  color: var(--red); }
.pd-badge-closed  { background: color-mix(in srgb, var(--tone-success) 15%, transparent); color: var(--green); }
/* ドーナツチャート */
.pd-donut-wrap { display: flex; align-items: center; gap: 16px; padding: 16px; }
.pd-donut-legend { display: flex; flex-direction: column; gap: 7px; }
.pd-donut-item { display: flex; align-items: center; gap: 6px; font-size: 0.857143rem; color: var(--text-secondary); }
.pd-donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pd-prio-bars { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.pd-empty { color: var(--text-muted); font-size: 0.928571rem; padding: 20px; text-align: center; }
.pd-section-charts {
    padding-bottom: 12px;
    overflow: visible;
}

/* ===== マイタスク Kanban ===== */
.kt-page { padding: 16px 20px; height: 100%; display: flex; flex-direction: column; gap: 12px; overflow: hidden; box-sizing: border-box; }
.kt-header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; flex-shrink: 0; }
.kt-header-title { font-size: 1.285714rem; font-weight: 700; color: var(--text-primary); flex: 1 1 200px; min-width: 0; }
.kt-action-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; background: var(--blurple); color: var(--on-accent); border: none; border-radius: 6px; font-size: 0.928571rem; font-family: var(--font); cursor: pointer; transition: opacity 0.15s; flex-shrink: 0; }
.kt-action-btn:hover { opacity: 0.85; }
.kt-action-btn .material-icons { font-size: 1.142857rem; }
.kt-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.kt-filter-btn { min-height: 32px; padding: 6px 12px; border-radius: 6px; font-size: 0.857143rem; font-weight: 600; cursor: pointer; border: none; font-family: var(--font); transition: background 0.15s, color 0.15s; display: inline-flex; align-items: center; gap: 4px; }
.kt-filter-btn.active { background: var(--blurple); color: var(--on-accent); }
.kt-filter-btn:not(.active) { background: var(--bg-lighter); color: var(--text-secondary); }
.kt-board { display: flex; gap: 12px; flex: 1; overflow-x: auto; min-height: 0; }
.kt-col { flex: 1; min-width: 180px; background: var(--bg-dark); border-radius: 8px; display: flex; flex-direction: column; max-height: 100%; }
/* Phones: each column takes most of the width so the next one peeks in, which shows the board scrolls sideways. */
@media (max-width: 720px) {
    .kt-board { scroll-snap-type: x proximity; }
    .kt-col { flex: 0 0 min(82%, 300px); scroll-snap-align: start; }
}
.kt-col-header { padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--bg-lighter); flex-shrink: 0; }
.kt-col-title { font-size: 0.857143rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.kt-col-count { font-size: 0.857143rem; font-weight: 700; color: var(--text-secondary); background: var(--bg-lighter); padding: 1px 8px; border-radius: 10px; }
.kt-col-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.kt-card { background: var(--bg-light); border-radius: 6px; padding: 10px 12px; cursor: pointer; transition: background 0.15s, transform 0.1s; border-left: 3px solid transparent; }
.kt-card:hover { background: var(--surface-medium); transform: translateY(-1px); }
.kt-card.prio-urgent { border-left-color: var(--red); }
.kt-card.prio-high   { border-left-color: var(--orange); }
.kt-card.prio-normal { border-left-color: var(--blurple); }
.kt-card.prio-low    { border-left-color: var(--green-dark); }
.kt-card-id      { font-size: 0.785714rem; color: var(--text-muted); margin-bottom: 4px; }
.kt-card-subject { font-size: 0.928571rem; font-weight: 600; color: var(--text-primary); line-height: 1.4; margin-bottom: 8px; }
.kt-card-meta    { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.kt-prio-badge   { font-size: var(--type-min); font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.kt-prio-urgent  { background: color-mix(in srgb, var(--tone-danger) 20%, transparent);   color: var(--red); }
.kt-prio-high    { background: color-mix(in srgb, var(--tone-warning) 20%, transparent);   color: var(--orange); }
.kt-prio-normal  { background: color-mix(in srgb, var(--blurple) 20%, transparent);   color: var(--blurple); }
.kt-prio-low     { background: color-mix(in srgb, var(--tone-success) 15%, transparent);  color: var(--green); }
.kt-due          { font-size: var(--type-min); color: var(--text-muted); }
.kt-due.overdue  { color: var(--red); font-weight: 700; }
.kt-due.soon     { color: var(--orange); font-weight: 700; }
.kt-card-prog    { display: flex; flex-direction: column; gap: 3px; }
.kt-prog-bar     { height: 4px; background: var(--bg-lighter); border-radius: 2px; overflow: hidden; }
.kt-prog-fill    { height: 100%; background: var(--blurple); border-radius: 2px; transition: width 0.3s; }
.kt-prog-fill.done { background: var(--green); }
.kt-prog-text    { font-size: var(--type-min); color: var(--text-muted); text-align: right; }
.kt-card-assignee { font-size: 0.785714rem; color: var(--text-muted); margin-top: 6px; }
.kt-empty        { color: var(--text-muted); font-size: 0.857143rem; padding: 16px; text-align: center; }

/* ===== チケット詳細モーダル ===== */
.td-header  { margin-bottom: 16px; }
.td-id      { font-size: 0.857143rem; color: var(--text-muted); margin-bottom: 4px; }
.td-subject { font-size: 1.142857rem; font-weight: 700; color: var(--text-primary); line-height: 1.4; }
.td-grid    { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.td-field   { display: flex; flex-direction: column; gap: 3px; }
.td-label   { font-size: var(--type-min); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.td-val     { font-size: 0.928571rem; color: var(--text-secondary); }
.td-prog-section { margin-top: 8px; }
.td-prog-label   { font-size: 0.857143rem; color: var(--text-muted); margin-bottom: 6px; }
.td-prog-bar     { height: 8px; background: var(--bg-lighter); border-radius: 4px; overflow: hidden; }
.td-prog-fill    { height: 100%; background: var(--blurple); border-radius: 4px; transition: width 0.3s; }
.td-prog-fill.done { background: var(--green); }

/* ===== レポートページ ===== */
.rp-page { padding: 16px 20px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; height: 100%; box-sizing: border-box; }
.rp-header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; flex-shrink: 0; }
.rp-header-title { font-size: 1.285714rem; font-weight: 700; color: var(--text-primary); flex: 1 1 200px; min-width: 0; }
.rp-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex-shrink: 0; }
.rp-proj-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.rp-proj-tab { padding: 6px 14px; border-radius: 6px; font-size: 0.928571rem; font-weight: 600; cursor: pointer; border: none; font-family: var(--font); transition: background 0.15s, color 0.15s; }
.rp-proj-tab.active     { background: var(--blurple); color: var(--on-accent); }
.rp-proj-tab:not(.active) { background: var(--bg-lighter); color: var(--text-secondary); }
.rp-type-row  { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0; }
.rp-type-tabs { display: flex; gap: 0; background: var(--bg-dark); padding: 3px; border-radius: 8px; border: 1px solid var(--bg-lighter); }
.rp-type-tab  { min-height: 32px; padding: 5px 14px; border-radius: 6px; font-size: 0.857143rem; font-weight: 600; cursor: pointer; border: none; font-family: var(--font); color: var(--text-muted); background: transparent; transition: background 0.15s, color 0.15s; }
.rp-type-tab.active { background: var(--bg-light); color: var(--text-primary); }
.rp-date-row  { display: flex; align-items: center; gap: 8px; font-size: 0.857143rem; color: var(--text-muted); }
.rp-date-row input { min-height: 36px; min-width: 0; background: var(--surface-input); border: 1px solid var(--border-control); border-radius: var(--radius-sm); color: var(--text-primary); padding: 4px 8px; font-size: 0.857143rem; font-family: var(--font); }
/* Phones: the label takes its own line and the two dates share the next one (16px date fields do not fit beside it). */
@media (max-width: 720px) {
    .rp-date-row { flex: 1 1 100%; flex-wrap: wrap; }
    .rp-date-row > span:first-child { flex: 0 0 100%; }
    .rp-date-row input { flex: 1 1 0; }
}
.rp-section   { background: var(--bg-dark); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.rp-section-title { padding: 10px 16px; background: var(--bg-light); font-size: 0.928571rem; font-weight: 700; color: var(--text-secondary); border-bottom: 1px solid var(--bg-lighter); display: flex; align-items: center; gap: 6px; }
.rp-section-title .material-icons { font-size: 1.142857rem; color: var(--blurple); }
.rp-section-body  { padding: 16px; }
.rp-summary-row   { display: flex; gap: 10px; flex-wrap: wrap; }
.rp-sum-card  { flex: 1; min-width: 80px; background: var(--bg-light); border-radius: 6px; padding: 14px 12px; text-align: center; }
.rp-sum-num   { font-size: 1.571429rem; font-weight: 700; color: var(--text-primary); }
.rp-sum-label { font-size: 0.785714rem; color: var(--text-muted); margin-top: 4px; }
.rp-table     { width: 100%; border-collapse: collapse; font-size: 0.928571rem; }
.rp-table th  { text-align: left; padding: 8px 10px; font-size: 0.785714rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; border-bottom: 1px solid var(--bg-lighter); white-space: nowrap; }
.rp-table td  { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.rp-table tr:last-child td { border-bottom: none; }
.rp-table tr:hover td { background: var(--surface-soft); }
.rp-prio-badge   { font-size: var(--type-min); font-weight: 700; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.rp-status-badge { font-size: 0.785714rem; font-weight: 600; padding: 2px 7px; border-radius: 3px; white-space: nowrap; }
.rp-status-new    { background: color-mix(in srgb, var(--blurple) 15%, transparent);  color: var(--blurple); }
.rp-status-open   { background: color-mix(in srgb, var(--blurple) 15%, transparent);   color: var(--cyan); }
.rp-status-done   { background: color-mix(in srgb, var(--tone-success) 15%, transparent);  color: var(--green); }
.rp-status-overdue { background: color-mix(in srgb, var(--tone-danger) 15%, transparent);  color: var(--red); }
.rp-prog-cell { display: flex; align-items: center; gap: 6px; }
.rp-prog-bar  { flex: 1; height: 6px; background: var(--bg-lighter); border-radius: 3px; overflow: hidden; min-width: 50px; }
.rp-prog-fill { height: 100%; background: var(--blurple); border-radius: 3px; }
.rp-prog-fill.done { background: var(--green); }
.rp-member-rows   { display: flex; flex-direction: column; gap: 10px; }
.rp-member-row    { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--bg-light); border-radius: 6px; }
.rp-member-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blurple); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 700; flex-shrink: 0; }
.rp-member-info   { flex: 1; }
.rp-member-name   { font-size: 0.928571rem; font-weight: 700; color: var(--text-primary); }
.rp-member-detail { font-size: 0.785714rem; color: var(--text-muted); margin-top: 2px; }
.rp-member-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.rp-print-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; background: var(--bg-lighter); color: var(--text-secondary); border: none; border-radius: 6px; font-size: 0.928571rem; font-family: var(--font); cursor: pointer; transition: background 0.15s, color 0.15s; flex-shrink: 0; }
.rp-print-btn:hover { background: var(--blurple); color: var(--on-accent); }
.rp-print-btn .material-icons { font-size: 1.142857rem; }
.rp-empty { color: var(--text-muted); font-size: 0.928571rem; padding: 20px; text-align: center; }
@media print {
    .channel-sidebar, .server-list, .input-area, .chat-header { display: none !important; }
    .chat-area { width: 100% !important; }
    .rp-print-btn, .rp-proj-tabs, .rp-type-tabs, .rp-date-row { display: none !important; }
}

/* ===== ログイン: Discord OAuth2 ボタン ===== */
.btn-discord-login {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px;
    background: var(--blurple);
    color: var(--on-accent);
    font-size: 1.071429rem;
    font-weight: 700;
    font-family: var(--font);
    border-radius: 8px;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition);
}
.btn-discord-login:hover {
    background: var(--blurple-hover);
    transform: translateY(-1px);
}

/* ===== ログイン: メンバー選択グリッド ===== */
.login-member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 4px 2px;
}
.login-member-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    user-select: none;
}
.login-member-card:hover {
    background: var(--bg-lighter);
}
.login-member-card.selected {
    border-color: var(--blurple);
    background: color-mix(in srgb, var(--blurple) 15%, transparent);
}
.login-member-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.login-member-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.login-member-card-initial {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--blurple);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.285714rem;
    font-weight: 700;
}
.login-member-card-name {
    font-size: 0.857143rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    word-break: break-all;
    line-height: 1.3;
    max-width: 100%;
}
.login-fallback-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--tone-warning) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--tone-warning) 40%, transparent);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.857143rem;
    line-height: 1.5;
}
.login-fallback-notice .material-icons {
    font-size: 1.285714rem;
    color: var(--orange);
    flex-shrink: 0;
    margin-top: 1px;
}

/* ===== チャンネル管理モーダル ===== */
.channel-manager-modal {
    width: min(960px, calc(100vw - 32px));
    max-width: 960px;
}
.channel-manager-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.channel-manager-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.channel-manager-summary span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 6px;
    background: var(--bg-light);
    color: var(--text-muted);
    font-size: 0.857143rem;
    box-shadow: inset 0 0 0 1px var(--bg-modifier-accent);
}
.channel-manager-summary strong {
    color: var(--text-primary);
}
/* 狭い画面では件数表示を省き、追加の操作に縦の領域を使う */
@media (max-width: 600px) {
    .channel-manager-summary {
        display: none;
    }
}
.channel-manager-refresh {
    white-space: nowrap;
}
.channel-manager-status {
    margin-bottom: 12px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--bg-light);
    color: var(--text-muted);
    font-size: 0.857143rem;
}
.channel-manager-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.8fr);
    gap: 12px;
}
.channel-manager-panel {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 8px;
    background: var(--bg-dark);
}
.channel-manager-panel-primary,
.channel-manager-map-panel {
    grid-column: 1;
}
.channel-manager-direct-panel {
    grid-column: 2;
    grid-row: 1 / span 3;
}
.channel-manager-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 0.928571rem;
    font-weight: 700;
}
.channel-manager-panel-title .material-icons {
    font-size: 1.285714rem;
    color: var(--blurple);
}
.channel-manager-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.7fr);
    gap: 10px;
}
.channel-manager-field {
    min-width: 0;
}
.channel-manager-field-wide {
    grid-column: 1 / -1;
}
.channel-manager-stack {
    display: grid;
    gap: 8px;
}
.channel-manager-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.channel-manager-main-action {
    width: 100%;
    margin-top: 10px;
    justify-content: center;
}
.channel-link-rows {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.channel-create-result {
    margin-top: 8px;
    font-size: 0.857143rem;
    color: var(--text-muted);
}
.channel-link-row {
    border: 1px solid var(--bg-modifier-accent);
    background: var(--bg-light);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: stretch;
    justify-content: space-between;
    flex-wrap: wrap;
}
.channel-link-row-main {
    flex: 1;
    min-width: 200px;
}
.channel-link-row-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 0.928571rem;
    font-weight: 600;
    color: var(--text-normal);
}
.channel-link-row-title .material-icons {
    font-size: 1.142857rem;
    color: var(--text-muted);
}
.channel-link-select {
    width: 100%;
}
.channel-link-row-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.channel-row-action {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 0.857143rem;
}
.channel-row-action .material-icons {
    font-size: 1.071429rem;
}
.linked-channel-manager-list {
    max-height: 560px;
    overflow-y: auto;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    padding: 6px;
    display: grid;
    gap: 6px;
}
.linked-channel-manager-item {
    padding: 8px;
    border-radius: 6px;
    background: var(--bg-light);
}
.linked-channel-manager-line {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
}
.linked-channel-manager-line .material-icons {
    font-size: 1.142857rem;
    color: var(--text-muted);
}
.linked-channel-manager-name {
    flex: 1;
    min-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.928571rem;
}
.channel-mini-action {
    min-height: 24px;
    padding: 2px 8px;
    font-size: 0.785714rem;
}
.channel-manager-empty {
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.928571rem;
}

/* ===== Workspace Refresh ===== */
body::before,
body::after {
    content: '';
    position: fixed;
    inset: auto;
    pointer-events: none;
    z-index: 0;
    border-radius: 999px;
    filter: blur(60px);
    opacity: 0.65;
}
body::before {
    width: 340px;
    height: 340px;
    top: -90px;
    left: -70px;
    background: color-mix(in srgb, var(--tone-info) 18%, transparent);
}
body::after {
    width: 320px;
    height: 320px;
    right: -90px;
    bottom: -90px;
    background: color-mix(in srgb, var(--orange) 14%, transparent);
}

.discord-app,
.admin-page {
    position: relative;
    z-index: 1;
}

.server-list {
    width: 84px;
    background: var(--bg-darkest);
    border-right: 1px solid var(--border-soft);
    backdrop-filter: blur(14px);
}

.server-icon {
    width: 54px;
    height: 54px;
    background: linear-gradient(160deg, color-mix(in srgb, var(--white) 8%, transparent), color-mix(in srgb, var(--white) 3%, transparent));
    box-shadow: inset 0 0 0 1px var(--border-soft);
}

.server-icon:hover,
.server-icon.active {
    background: linear-gradient(135deg, var(--blurple), var(--tone-info));
    box-shadow: 0 16px 30px color-mix(in srgb, var(--green-dark) 45%, transparent);
}

.channel-sidebar {
    width: 290px;
    background: var(--bg-dark);
    border-right: 1px solid var(--border-soft);
    backdrop-filter: blur(18px);
}

.server-header {
    height: 68px;
    border-bottom: 1px solid var(--border-soft);
    box-shadow: none;
}

.server-header h2,
.channel-name,
.pd-header-title,
.kt-header-title,
.rp-header-title {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

.sidebar-insights {
    padding: 16px;
    border-bottom: 1px solid var(--border-soft);
}

.sidebar-card {
    border-radius: 18px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--white) 5%, transparent), color-mix(in srgb, var(--white) 3%, transparent));
    box-shadow: inset 0 0 0 1px var(--border-soft);
}

.channel-item {
    margin: 3px 10px;
    padding: 10px 12px;
    border-radius: 12px;
}

.channel-item:hover,
.channel-item.active {
    background: var(--surface-medium);
    box-shadow: inset 0 0 0 1px var(--border-soft);
}

.channel-item .material-icons {
    width: 28px;
    min-width: 28px;
    height: 28px;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    background: color-mix(in srgb, var(--text-muted) 16%, transparent);
    color: var(--text-primary);
    font-size: 1.142857rem;
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

.channel-item[data-channel="general"] .material-icons { background: color-mix(in srgb, var(--tone-info) 18%, transparent); color: var(--accent-text); }
.channel-item[data-channel="unassigned"] .material-icons { background: color-mix(in srgb, var(--orange) 17%, transparent); color: var(--orange); }
.channel-item[data-channel="schedule"] .material-icons { background: color-mix(in srgb, var(--tone-success) 16%, transparent); color: var(--tone-success); }
.channel-item[data-channel="calendar"] .material-icons { background: color-mix(in srgb, var(--tone-warning) 16%, transparent); color: var(--tone-warning); }
.channel-item[data-channel="campus"] .material-icons { background: color-mix(in srgb, var(--tone-danger) 16%, transparent); color: var(--tone-danger); }
.channel-item[data-channel="project"] .material-icons { background: color-mix(in srgb, var(--orange) 17%, transparent); color: var(--orange); }
.channel-item[data-channel="mytasks"] .material-icons { background: color-mix(in srgb, var(--blurple) 16%, transparent); color: var(--tone-success); }
.channel-item[data-channel="report"] .material-icons { background: color-mix(in srgb, var(--tone-info) 17%, transparent); color: var(--tone-info); }
.channel-item[data-channel="redmine"] .material-icons { background: color-mix(in srgb, var(--tone-success) 18%, transparent); color: var(--tone-success); }
.channel-item[data-channel="autopost"] .material-icons { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.channel-item[data-channel="notify"] .material-icons { background: color-mix(in srgb, var(--tone-danger) 16%, transparent); color: var(--tone-danger); }
.channel-item[data-channel^="discord_"] .material-icons,
.channel-item[data-channel^="linked_"] .material-icons { background: color-mix(in srgb, var(--text-muted) 16%, transparent); color: var(--text-muted); }
.channel-item.link-channel-item[data-channel-platform^="line_"] .material-icons {
    background: color-mix(in srgb, var(--brand-line) 18%, transparent);
    color: var(--tone-success);
}
.channel-item.link-channel-item[data-channel-platform="slack"] .material-icons {
    background: color-mix(in srgb, var(--violet) 18%, transparent);
    color: color-mix(in srgb, var(--brand-slack) 45%, var(--text-primary));
}
.channel-item.link-channel-item[data-channel-platform="mattermost"] .material-icons {
    background: color-mix(in srgb, var(--tone-info) 17%, transparent);
    color: var(--tone-info);
}
.channel-item.link-channel-item[data-channel-platform^="line_"] .channel-platform-badge {
    background: color-mix(in srgb, var(--brand-line) 13%, transparent);
    color: var(--accent-text);
}
.channel-item.link-channel-item[data-channel-platform="slack"] .channel-platform-badge {
    background: color-mix(in srgb, var(--violet) 16%, transparent);
    color: color-mix(in srgb, var(--brand-slack) 45%, var(--text-primary));
}
.channel-item.link-channel-item[data-channel-platform="mattermost"] .channel-platform-badge {
    background: color-mix(in srgb, var(--tone-info) 14%, transparent);
    color: var(--accent-text);
}

.channel-platform-badge {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 1px 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
    color: var(--text-muted);
    font-size: 0.785714rem;
    line-height: 1.2;
    white-space: nowrap;
}

.channel-current-link {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 5px 0 7px;
    color: var(--text-muted);
    font-size: 0.857143rem;
    flex-wrap: wrap;
}

.linked-channel-manager-host,
.webhook-test-result {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.785714rem;
    line-height: 1.35;
}

.linked-channel-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blurple);
}

.linked-channel-avatar[data-channel-platform^="line_"] {
    background: var(--brand-line);
}

.linked-channel-avatar[data-channel-platform="slack"] {
    background: var(--violet);
}

.linked-channel-avatar[data-channel-platform="mattermost"] {
    background: var(--brand-mattermost);
}

.linked-channel-target {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.857143rem;
    line-height: 1.4;
}

.linked-channel-target .material-icons {
    font-size: 1.071429rem;
    color: var(--text-muted);
}

.linked-settings-title {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 700;
}

.linked-settings-hint {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 0.857143rem;
    line-height: 1.4;
}

.channel-item:hover .material-icons,
.channel-item.active .material-icons {
    background: var(--blurple);
    color: var(--on-accent);
    box-shadow: 0 8px 18px color-mix(in srgb, var(--blurple) 18%, transparent);
}

.channel-item.link-channel-item[data-channel-platform^="line_"]:hover .material-icons,
.channel-item.link-channel-item[data-channel-platform^="line_"].active .material-icons {
    background: var(--brand-line);
    color: var(--on-accent);
}

.channel-item.link-channel-item[data-channel-platform="slack"]:hover .material-icons,
.channel-item.link-channel-item[data-channel-platform="slack"].active .material-icons {
    background: var(--violet);
    color: var(--on-strong);
}

.channel-item.link-channel-item[data-channel-platform="mattermost"]:hover .material-icons,
.channel-item.link-channel-item[data-channel-platform="mattermost"].active .material-icons {
    background: var(--brand-mattermost);
    color: var(--on-strong);
}

.sidebar-card-header > span > .material-icons {
    width: 24px;
    min-width: 24px;
    height: 24px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    background: color-mix(in srgb, var(--blurple) 14%, transparent);
    color: var(--blurple);
    font-size: 1.071429rem;
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

/* ===== Workspace chrome =====
   Each layer owns one job, so nothing is shown twice:
   - header: names the channel and carries the live numbers (plus the toolbar toggle);
   - toolbar: the channel's quick actions;
   - footer: typing. Quick actions move here only when the toolbar is collapsed, and on phones.
   Colours come from tokens, so the three themes need no per-component overrides. */
.chat-area {
    background: var(--chat-area-bg);
}

.chat-header {
    justify-content: space-between;
    gap: var(--space-4);
    min-height: 68px;
    padding: var(--space-3) var(--space-5);
    box-shadow: none;
}

.chat-header-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-header-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.chat-header-context {
    font-size: var(--type-label);
    color: var(--text-secondary);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.header-stat {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    min-height: 44px;
    padding: 6px var(--space-3) 6px 6px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-control);
    background: var(--surface-soft);
}

.header-stat-icon {
    width: 30px;
    min-width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent-text) 14%, transparent);
    color: var(--accent-text);
    font-size: 1.214286rem;
}

.header-stat-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.header-stat-label {
    font-size: var(--type-min);
    letter-spacing: 0.02em;
    line-height: 1.3;
    color: var(--text-muted);
    white-space: nowrap;
}

.header-stat-value {
    font-family: var(--font-display);
    font-size: 1.142857rem;
    line-height: 1.25;
    color: var(--text-primary);
}

.workspace-toolbar-toggle {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-control);
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 1.428571rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.workspace-toolbar-toggle:hover { background: var(--state-hover); color: var(--text-primary); }
.workspace-toolbar-toggle[aria-pressed="true"] {
    background: var(--state-active);
    border-color: var(--state-active-border);
    color: var(--accent-text);
}

.workspace-hero {
    padding: var(--space-3) var(--space-5) 0;
}
.workspace-hero:empty { display: none; }

.workspace-toolbar {
    display: flex;
    gap: var(--space-2);
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.workspace-hero-action {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    max-width: 260px;
    padding: 6px var(--space-3) 6px 6px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-control);
    background: var(--surface-soft);
    color: var(--text-primary);
    font-family: var(--font);
    text-align: left;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.workspace-hero-action:hover { background: var(--state-hover); border-color: var(--state-active-border); }

.workspace-hero-action-icon {
    display: inline-grid;
    place-items: center;
    width: 30px;
    min-width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent-text) 14%, transparent);
    color: var(--accent-text);
    font-size: 1.285714rem;
}

.workspace-hero-action-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.workspace-hero-action-copy strong,
.workspace-hero-action-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workspace-hero-action-copy strong { font-size: var(--type-label); }
.workspace-hero-action-copy small { font-size: var(--type-min); color: var(--text-muted); }

.messages-container {
    padding: var(--space-5) var(--space-6) var(--space-6);
    gap: var(--space-3);
}

.message {
    padding: 14px 16px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-card);
    background: var(--surface-card);
    box-shadow: var(--shadow-card);
}

.message-avatar {
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

.embed {
    border-radius: var(--radius-card);
    background: var(--surface-inset);
    box-shadow: inset 0 0 0 1px var(--border-soft);
}

.input-area {
    padding: var(--space-3) var(--space-6) var(--space-5);
    border-top: 1px solid var(--border-medium);
    background: var(--bg-dark);
}

.chat-area.quick-toolbar-open .slash-commands { display: none; }
.chat-area.settings-view-active :is(.workspace-hero, .input-area, .workspace-toolbar-toggle) { display: none; }

.slash-commands {
    flex-wrap: nowrap;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.slash-btn {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 4px var(--space-3) 4px var(--space-2);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-control);
    background: var(--surface-soft);
    color: var(--text-primary);
}
.slash-btn:hover { background: var(--state-hover); border-color: var(--state-active-border); box-shadow: none; transform: none; }
.slash-btn .material-icons { color: var(--accent-text); }
/* Compact chips: the detail and the Discord alias stay in the tooltip and the accessible name. */
.slash-btn :is(.cmd-desc, .cmd-alias) { display: none; }

.input-box {
    min-height: 48px;
    padding: 6px 14px;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-control);
    background: var(--surface-input);
    box-shadow: none;
}
.input-box:focus-within { border-color: var(--focus-color); }

.modal {
    border-radius: 24px;
    background: var(--bg-medium);
    box-shadow: 0 24px 60px color-mix(in srgb, var(--shadow-color) 45%, transparent);
}

.ticket-project-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--tone-info) 8%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone-info) 16%, transparent);
}

.ticket-project-summary strong {
    font-size: 1rem;
}

.ticket-project-summary span {
    font-size: 0.857143rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.member-list-empty {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px;
    padding: 12px;
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--text-secondary);
    box-shadow: inset 0 0 0 1px var(--border-soft);
}

.member-list-empty .material-icons {
    color: var(--blurple);
}

.user-bar {
    background: var(--bg-darkest);
    border-top: 1px solid var(--border-soft);
    backdrop-filter: blur(14px);
}

@media (max-width: 980px) {
    .channel-sidebar {
        width: 240px;
    }

    .cal-page {
        flex-direction: column;
        height: auto;
        min-height: 100%;
        overflow: visible;
    }

    .cal-page-left {
        overflow: visible;
        padding: 16px;
    }

    .cal-day-panel {
        width: 100%;
        min-height: 220px;
        border-left: 0;
        border-top: 1px solid var(--bg-lighter);
    }

    .chat-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chat-header-meta {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .discord-app {
        flex-direction: column;
        height: 100dvh;
        min-height: 100dvh;
    }

    .server-list {
        width: 100%;
        height: 60px;
        flex-direction: row;
        justify-content: flex-start;
        padding: 8px 16px;
    }

    .channel-sidebar {
        width: 100%;
        max-height: 27dvh;
        min-height: 156px;
    }

    .sidebar-scroll-area {
        max-height: calc(27dvh - 104px);
    }

    .sidebar-insights {
        display: none;
    }

    .chat-area {
        flex: 1;
        min-height: 0;
    }

    .workspace-hero,
    .messages-container,
    .input-area {
        padding-left: 16px;
        padding-right: 16px;
    }

    .workspace-hero {
        display: block;
        padding-top: 8px;
        padding-bottom: 0;
        flex-shrink: 0;
    }

    .messages-container {
        flex: 1;
        min-height: 0;
        padding-top: 12px;
        padding-bottom: 16px;
    }

    .input-area {
        position: sticky;
        bottom: 0;
        z-index: 5;
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, color-mix(in srgb, var(--bg-dark) 0%, transparent), var(--bg-dark) 18%, var(--bg-dark));
        backdrop-filter: blur(12px);
    }

    .slash-commands {
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .slash-btn {
        flex: 0 0 auto;
        min-width: 118px;
    }

    .footer-mode-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    .chat-mode-toggle {
        width: 100%;
        justify-content: center;
    }

    .chat-mode-hint {
        flex-basis: 100%;
        order: 3;
    }

    .chat-mode-count,
    .chat-jump-latest {
        min-height: 30px;
    }

    .cmd-desc,
    .cmd-alias {
        display: none;
    }

    .modal {
        width: 94vw;
        max-height: 88vh;
        max-height: 88dvh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 14px;
        padding-right: 14px;
    }

    .modal-footer {
        gap: 6px;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 132px;
        justify-content: center;
    }

    .ui-toast-region {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        width: calc(100vw - 24px);
    }

    .cal-page-nav,
    .cal-page-legend {
        flex-wrap: wrap;
    }

    .cal-page-title {
        min-width: 100%;
        order: -1;
        text-align: left;
        font-size: 1.285714rem;
    }

    .cal-page-action-btn {
        flex: 1 1 150px;
        justify-content: center;
    }

    .user-bar {
        gap: 8px;
    }

    .settings-page {
        padding: 16px;
        max-width: none;
    }

    .settings-role-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .settings-fields,
    .settings-theme-options,
    .settings-language-options,
    .settings-check-grid,
    .settings-account-link-row,
    .settings-integration-lamp-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-integration-header {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-integration-title {
        flex-wrap: wrap;
    }

    .settings-line-friend-qr {
        grid-template-columns: 1fr;
    }

    .settings-line-friend-qr-image {
        justify-self: center;
    }

    .settings-field-wide {
        grid-column: span 1;
    }

    .channel-manager-topline,
    .channel-manager-actions,
    .channel-link-row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .channel-manager-grid,
    .channel-manager-form-grid,
    .channel-manager-actions {
        grid-template-columns: 1fr;
    }

    .channel-manager-panel-primary,
    .channel-manager-map-panel,
    .channel-manager-direct-panel,
    .channel-manager-field-wide {
        grid-column: auto;
        grid-row: auto;
    }

    .channel-row-action,
    .channel-manager-refresh {
        justify-content: center;
        width: 100%;
    }

    .user-info {
        min-width: 0;
    }

    .header-stat {
        min-width: 0;
    }
}

/* ===== 予定登録モードトグル ===== */
.schedule-mode-toggle {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.mode-toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1.5px solid var(--channel-default, var(--border-control));
    background: transparent;
    color: var(--text-muted, var(--text-muted));
    font-size: 0.928571rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mode-toggle-btn .material-icons {
    font-size: 1.142857rem;
}
/* 予定登録モード（管理者が有効にしたものが並ぶ。多いときは折り返す） */
.schedule-mode-tabs {
    flex-wrap: wrap;
}
.schedule-mode-tabs .mode-toggle-btn {
    flex: 1 1 130px;
}
/* 長期休みなど、選んだ期間・週についての案内 */
.schedule-mode-notice {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--tone-warning-border);
    background: var(--tone-warning-soft);
    color: var(--tone-warning-text);
}
.schedule-mode-notice[hidden] {
    display: none;
}
.schedule-grid .grid-header {
    white-space: nowrap;
}
.grid-header .period-time {
    display: block;
    font-size: var(--type-min);
    font-weight: 400;
    color: var(--text-muted);
}
.mode-toggle-btn:hover {
    background: var(--bg-modifier-hover, var(--surface-medium));
    color: var(--text-normal, var(--tone-success));
}
.mode-toggle-btn.active {
    background: var(--blurple, var(--action-bg));
    border-color: var(--blurple, var(--blurple));
    color: var(--on-accent);
}

/* ===== Motion polish: 操作を邪魔しない軽いアニメーション ===== */
:root {
    --motion-fast: 120ms;
    --motion-normal: 220ms;
    --motion-slow: 340ms;
    --motion-ease: cubic-bezier(.2,.8,.2,1);
}

.discord-app,
.admin-page {
    animation: uiFadeIn var(--motion-normal) var(--motion-ease) both;
}

.server-list,
.channel-sidebar {
    animation: uiPanelIn var(--motion-slow) var(--motion-ease) both;
}

.chat-header,
.messages-container > .embed,
.messages-container > .message,
.settings-section,
.admin-card,
.cal-page,
.pd-page,
.kt-page,
.td-page,
.rp-page {
    animation: uiRise var(--motion-normal) var(--motion-ease) both;
}
.settings-section:nth-child(2),
.admin-card:nth-child(2) { animation-delay: 24ms; }
.settings-section:nth-child(3),
.admin-card:nth-child(3) { animation-delay: 48ms; }
.settings-section:nth-child(4),
.admin-card:nth-child(4) { animation-delay: 72ms; }
.settings-section:nth-child(5),
.admin-card:nth-child(5) { animation-delay: 96ms; }

.channel-item,
.server-icon,
.slash-btn,
.workspace-hero-action,
.btn,
.action-btn,
.settings-save-btn,
.cal-page-nav-btn,
.cal-page-action-btn,
.cdp-add-btn,
.pd-action-btn,
.kt-action-btn,
.kt-filter-btn,
.kt-card,
.rp-print-btn,
.mode-toggle-btn,
.chat-mode-toggle,
.chat-jump-latest,
.input-box,
.discord-input,
.discord-select,
.admin-card,
.settings-section {
    transition-duration: var(--motion-fast);
    transition-timing-function: var(--motion-ease);
}

.channel-item:active,
.server-icon:active,
.slash-btn:active,
.workspace-hero-action:active,
.btn:active,
.action-btn:active,
.settings-save-btn:active,
.cal-page-nav-btn:active,
.cal-page-action-btn:active,
.cdp-add-btn:active,
.pd-action-btn:active,
.kt-action-btn:active,
.kt-filter-btn:active,
.kt-card:active,
.rp-print-btn:active,
.mode-toggle-btn:active,
.chat-mode-toggle:active,
.chat-jump-latest:active {
    transform: translateY(0) scale(0.99);
}

.discord-input:focus,
.discord-select:focus,
.input-box:focus-within {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 42%, transparent), 0 0 0 3px color-mix(in srgb, var(--blurple) 8%, transparent);
}

.modal-overlay.show .modal {
    animation: uiModalIn var(--motion-normal) var(--motion-ease) both;
}

.admin-status.info,
.admin-status.ok,
.admin-status.warn,
.admin-status.err,
.settings-save-msg:not(:empty),
.channel-create-result:not(:empty),
.channel-manager-status:not(:empty) {
    animation: uiStatusIn var(--motion-normal) var(--motion-ease) both;
}

.cal-day:hover,
.chat-fullcal-cell:hover:not(.chat-fullcal-empty),
.settings-section:hover,
.admin-card:hover {
    transform: translateY(-1px);
}

.cal-day,
.chat-fullcal-cell,
.settings-section,
.admin-card {
    transition-property: transform, background, border-color, box-shadow;
}

.messages-container {
    scroll-behavior: smooth;
}

@keyframes uiFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes uiPanelIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes uiRise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes uiModalIn {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes uiStatusIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-delay: 0ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }

    .channel-item:hover,
.server-icon:hover,
.slash-btn:hover,
.workspace-hero-action:hover,
.btn:hover,
.action-btn:hover,
.settings-save-btn:hover,
.cal-page-nav-btn:hover,
.cal-page-action-btn:hover,
.cdp-add-btn:hover,
.pd-action-btn:hover,
.kt-action-btn:hover,
.kt-filter-btn:hover,
.kt-card:hover,
.rp-print-btn:hover,
.mode-toggle-btn:hover,
.chat-mode-toggle:hover,
.chat-jump-latest:hover,
.cal-day:hover,
.chat-fullcal-cell:hover:not(.chat-fullcal-empty),
.settings-section:hover,
.admin-card:hover {
        transform: none !important;
    }
}

/* ===== ウォッチャー: チェックボックスリスト ===== */
.watcher-checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
    max-height: 168px;
    overflow-y: auto;
    padding: 8px;
    border-radius: 8px;
    background: var(--bg-darkest);
    box-shadow: inset 0 0 0 1px var(--border-soft);
}
.watcher-checkbox-list:focus-within {
    box-shadow: inset 0 0 0 2px var(--blurple);
}
.watcher-checkbox-empty,
.watcher-checkbox-loading {
    grid-column: 1 / -1;
    padding: 12px;
    color: var(--text-muted);
    font-size: 0.857143rem;
    text-align: center;
}
.watcher-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text-primary);
    font-size: 0.928571rem;
    line-height: 1.3;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    min-width: 0;
}
.watcher-checkbox-item:hover {
    background: var(--surface-medium);
}
.watcher-checkbox-item input[type="checkbox"] {
    accent-color: var(--blurple);
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 0;
}
.watcher-checkbox-item.is-checked {
    background: color-mix(in srgb, var(--blurple) 14%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 32%, transparent);
}
[data-theme="navy"] .watcher-checkbox-item.is-checked {
    background: color-mix(in srgb, var(--blurple) 18%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 40%, transparent);
}
[data-theme="light"] .watcher-checkbox-item.is-checked {
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 40%, transparent);
}
.watcher-checkbox-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.watcher-checkbox-role {
    color: var(--text-muted);
    font-size: 0.785714rem;
    margin-left: 4px;
}

/* ===== 個人設定: テーマ選択 ===== */
.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid transparent;
    background: var(--surface-soft);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.928571rem;
    text-align: left;
    transition: background var(--transition), border-color var(--transition);
}
.theme-option:hover {
    background: var(--surface-medium);
}
.theme-option.active {
    border-color: var(--blurple);
    background: var(--surface-medium);
}
.theme-option-swatch {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px var(--border-medium);
}
.theme-option-swatch-default {
    background: linear-gradient(135deg, #08131b 0%, #4ad7b2 100%);
}
.theme-option-swatch-navy {
    background: linear-gradient(135deg, #000000 0%, #182242 60%, #6b7cff 100%);
}
.theme-option-swatch-light {
    background: linear-gradient(135deg, #ffffff 0%, #eaeef6 50%, #5865f2 100%);
}
.theme-option-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}
.theme-option-name {
    font-weight: 700;
    font-size: 0.928571rem;
}
.theme-option-desc {
    font-size: 0.785714rem;
    color: var(--text-muted);
}
.theme-option .check-mark {
    margin-left: auto;
    color: var(--blurple);
    opacity: 0;
}
.theme-option.active .check-mark {
    opacity: 1;
}

/* ===== ライトテーマ：個別オーバーライド ===== */
[data-theme="light"] .server-list {
    background: var(--bg-darkest);
}
[data-theme="light"] .server-icon {
    background: var(--surface-card);
    box-shadow: inset 0 0 0 1px var(--border-soft);
}
[data-theme="light"] .server-icon .material-icons {
    color: var(--blurple);
}
[data-theme="light"] .server-icon.active {
    background: var(--blurple);
}
[data-theme="light"] .server-icon.active .material-icons,
[data-theme="light"] .server-icon:hover .material-icons {
    color: var(--on-accent);
}

[data-theme="light"] .channel-sidebar {
    background: var(--bg-dark);
    box-shadow: inset -1px 0 0 var(--border-medium);
}
[data-theme="light"] .server-header {
    border-bottom: 1px solid var(--border-medium);
    box-shadow: none;
}
[data-theme="light"] .channel-category {
    color: var(--text-muted);
}
[data-theme="light"] .channel-item:hover {
    background: var(--surface-medium);
}
[data-theme="light"] .channel-item.active {
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
    color: var(--blurple);
}
[data-theme="light"] .channel-item.active .material-icons {
    color: var(--blurple);
}

[data-theme="light"] .sidebar-card {
    background: var(--surface-card);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--text-muted) 8%, transparent), inset 0 0 0 1px var(--border-medium);
}
[data-theme="light"] .sidebar-insights {
    border-bottom: 1px solid var(--border-medium);
}

[data-theme="light"] .user-bar {
    background: var(--surface-card);
    border-top: 1px solid var(--border-medium);
    backdrop-filter: none;
}

[data-theme="light"] .slash-command-palette {
    background: var(--surface-card);
    border-color: var(--border-medium);
    box-shadow: 0 16px 44px color-mix(in srgb, var(--text-muted) 22%, transparent);
}

[data-theme="light"] .modal {
    background: var(--surface-card);
    box-shadow: 0 16px 48px color-mix(in srgb, var(--text-muted) 25%, transparent), inset 0 0 0 1px var(--border-medium);
}
[data-theme="light"] .modal-header,
[data-theme="light"] .modal-footer {
    background: var(--surface-card);
    border-color: var(--border-medium);
}
[data-theme="light"] .discord-select,
[data-theme="light"] .discord-input {
    background: var(--bg-dark);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--border-medium);
}

[data-theme="light"] .embed-footer {
    border-color: var(--border-soft);
}
[data-theme="light"] .message-text,
[data-theme="light"] .embed-title,
[data-theme="light"] .embed-field-value {
    color: var(--text-primary);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: var(--border-strong);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* Filled states draw their own colour bar, so only empty cells get the hairline. */
[data-theme="light"] .grid-cell:is([data-state="empty"], :not([data-state])) {
    box-shadow: inset 0 0 0 1px var(--border-soft);
}
[data-theme="light"] .grid-header,
[data-theme="light"] .grid-period {
    background: var(--bg-light);
}

[data-theme="light"] .summary-table th {
    background: var(--bg-light);
}
[data-theme="light"] .summary-table td,
[data-theme="light"] .summary-table th {
    border-color: var(--border-medium);
    color: var(--text-primary);
}

[data-theme="light"] .channel-state-card,
[data-theme="light"] .channel-chat-panel {
    background: var(--surface-card);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--text-muted) 10%, transparent), inset 0 0 0 1px var(--border-medium);
}

[data-theme="light"] .ui-toast {
    background: var(--surface-card);
    color: var(--text-primary);
    box-shadow: 0 18px 36px color-mix(in srgb, var(--text-muted) 22%, transparent), inset 0 0 0 1px var(--border-medium);
}

[data-theme="light"] .mini-cal-cell {
    background: var(--bg-dark);
    border-color: var(--border-medium);
}
[data-theme="light"] .my-schedule-cell {
    background: var(--bg-light);
}
[data-theme="light"] .my-schedule-cell::after {
    background: var(--bg-lighter);
}
[data-theme="light"] .day-chip {
    background: var(--bg-light);
}


[data-theme="light"] .channel-chat-message.is-self {
    background: color-mix(in srgb, var(--blurple) 7%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 16%, transparent);
    border-left-color: color-mix(in srgb, var(--blurple) 55%, transparent);
}
[data-theme="light"] .channel-chat-date span,
[data-theme="light"] .channel-chat-date::before,
[data-theme="light"] .channel-chat-date::after {
    background: var(--border-medium);
}
[data-theme="light"] .channel-chat-date span {
    background: var(--bg-light);
}
[data-theme="light"] .chat-mode-toggle {
    background: var(--surface-card);
    border-color: var(--border-medium);
}
[data-theme="light"] .chat-mode-toggle:hover,
[data-theme="light"] .chat-mode-toggle.active {
    background: color-mix(in srgb, var(--blurple) 8%, transparent);
    border-color: color-mix(in srgb, var(--blurple) 50%, transparent);
}
[data-theme="light"] .chat-mode-count {
    background: var(--bg-light);
    border-color: var(--border-medium);
    color: var(--text-secondary);
}
[data-theme="light"] .chat-jump-latest {
    background: color-mix(in srgb, var(--blurple) 10%, transparent);
    border-color: color-mix(in srgb, var(--blurple) 40%, transparent);
}
[data-theme="light"] .watcher-checkbox-list {
    background: var(--bg-dark);
}
[data-theme="light"] .watcher-checkbox-item {
    background: var(--surface-card);
    box-shadow: inset 0 0 0 1px var(--border-soft);
}
[data-theme="light"] .watcher-checkbox-item:hover {
    background: var(--bg-light);
}
[data-theme="light"] .progress-bar-bg {
    background: var(--bg-lighter);
}
[data-theme="light"] .schedule-grid {
    background: var(--bg-lighter);
}
[data-theme="light"] .ev-type-tab,
[data-theme="light"] .mode-toggle-btn {
    background: var(--surface-card);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--border-medium);
}
[data-theme="light"] .ev-type-tab.active,
[data-theme="light"] .mode-toggle-btn.active {
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
    color: var(--blurple);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blurple) 40%, transparent);
}

/* ===== ネイビーテーマ：個別オーバーライド ===== */
[data-theme="navy"] .channel-item .material-icons,
[data-theme="navy"] .slash-btn .material-icons,
[data-theme="navy"] .modal-label .material-icons {
    color: var(--text-secondary);
}
[data-theme="navy"] .channel-item.active .material-icons,
[data-theme="navy"] .slash-btn:hover .material-icons {
    color: var(--blurple);
}

/* ===== LINE Sync Known Targets List ===== */
.line-sync-known-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 8px;
    background: var(--bg-secondary);
}
.line-sync-known-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-modifier-accent);
    transition: background 0.12s;
}
.line-sync-known-item:last-child { border-bottom: none; }
.line-sync-known-item:hover { background: var(--bg-hover); }
.line-sync-known-item.selected { background: color-mix(in srgb, var(--blurple) 18%, transparent); }
.line-sync-known-item.already-linked { opacity: 0.6; }
.line-sync-known-item .material-icons {
    font-size: 1.285714rem;
    color: var(--green);
    flex-shrink: 0;
}
.line-sync-known-item.already-linked .material-icons { color: var(--text-muted); }
.line-sync-known-info {
    flex: 1;
    min-width: 0;
}
.line-sync-known-name {
    font-size: 0.928571rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.line-sync-known-id {
    font-size: 0.785714rem;
    color: var(--text-muted);
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.line-sync-known-badge {
    font-size: var(--type-min);
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-modifier-accent);
    color: var(--text-muted);
    flex-shrink: 0;
}
.line-sync-known-badge.linked {
    background: color-mix(in srgb, var(--tone-success) 15%, transparent);
    color: var(--green);
}
.line-sync-known-loading {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.928571rem;
}
.line-sync-known-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.857143rem;
}
.line-sync-selected-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--blurple) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--blurple) 35%, transparent);
    margin-bottom: 8px;
    font-size: 0.928571rem;
}
.line-sync-selected-badge .material-icons {
    font-size: 1.142857rem;
    color: var(--blurple, var(--accent-text));
}

/* ===== Channel Manager v2: Sections / Form ===== */
.channel-manager-modal-v2 {
    max-width: 860px;
}
.cm-section {
    background: var(--bg-light);
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}
.cm-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;
    list-style: none;
}
.cm-section-header::-webkit-details-marker { display: none; }
.cm-section-header .material-icons { font-size: 1.285714rem; color: var(--text-muted); }
.cm-section[open] .cm-arrow { transform: rotate(0deg); }
.cm-arrow {
    transform: rotate(-90deg);
    transition: transform 0.15s;
}
.cm-section-title { flex: 1; }
.cm-section-badge {
    font-size: 0.785714rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-modifier-accent);
    color: var(--text-muted);
    font-weight: 600;
}
.cm-flow {
    display: grid;
    gap: 12px;
}
.cm-flow-step {
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 8px;
    background: var(--bg-light);
    overflow: hidden;
}
.cm-step-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--bg-modifier-accent);
}
.cm-step-number {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blurple, var(--action-bg));
    color: var(--on-accent);
    font-size: 0.928571rem;
    font-weight: 700;
}
.cm-step-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.cm-step-sub {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.857143rem;
    line-height: 1.35;
}
.cm-step-state {
    min-width: 62px;
    text-align: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--bg-modifier-accent);
    color: var(--text-secondary);
    font-size: 0.785714rem;
    font-weight: 700;
}
.cm-step-state.ok {
    color: var(--green);
    background: color-mix(in srgb, var(--tone-success) 10%, transparent);
}
.cm-step-state.warn {
    color: var(--orange, var(--tone-warning));
    background: color-mix(in srgb, var(--tone-warning) 12%, transparent);
}
.cm-step-state.error {
    color: var(--red);
    background: color-mix(in srgb, var(--tone-danger) 12%, transparent);
}
.cm-step-body {
    padding: 12px 14px 14px;
}
.cm-field-grid,
.cm-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.cm-field-wide {
    grid-column: 1 / -1;
}
.cm-choice-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.cm-choice {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 8px;
    background: var(--bg-secondary);
    cursor: pointer;
}
.cm-choice input {
    margin: 0;
}
.cm-choice .material-icons {
    font-size: 1.285714rem;
    color: var(--text-muted);
}
.cm-choice:has(input:checked) {
    border-color: color-mix(in srgb, var(--blurple) 75%, transparent);
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
}
.cm-substep {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 8px;
    background: var(--bg-secondary);
    margin-top: 10px;
}
.cm-substep-head,
.cm-advanced-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 0.928571rem;
}
.cm-substep-head .material-icons,
.cm-advanced-divider .material-icons {
    font-size: 1.285714rem;
    color: var(--text-muted);
}
.cm-inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.cm-status-card {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--bg-modifier-accent);
    background: var(--bg-dark);
    color: var(--text-muted);
    font-size: 0.928571rem;
}
.cm-status-card .material-icons {
    font-size: 1.285714rem;
}
.cm-status-card.ok {
    border-color: color-mix(in srgb, var(--tone-success) 35%, transparent);
    color: var(--green);
    background: color-mix(in srgb, var(--tone-success) 8%, transparent);
}
.cm-status-card.warn {
    border-color: color-mix(in srgb, var(--tone-warning) 35%, transparent);
    color: var(--orange, var(--tone-warning));
    background: color-mix(in srgb, var(--tone-warning) 8%, transparent);
}
.cm-status-card.error {
    border-color: color-mix(in srgb, var(--tone-danger) 35%, transparent);
    color: var(--red);
    background: color-mix(in srgb, var(--tone-danger) 8%, transparent);
}
.cm-assist {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--tone-warning) 8%, transparent);
    color: var(--text-secondary);
    font-size: 0.857143rem;
}
.cm-assist > strong {
    flex: 1 1 100%;
    color: var(--text-primary);
}
.cm-steps-list {
    flex: 1 1 100%;
    margin: 0;
    padding-left: 20px;
    line-height: 1.7;
}
.cm-intro {
    margin: 0 0 12px;
    color: var(--text-secondary);
    font-size: 0.928571rem;
    line-height: 1.6;
}
.cm-manual-id {
    margin-top: 8px;
}
.cm-manual-id > summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.857143rem;
    padding: 4px 0;
}
.cm-manual-id[open] > summary {
    margin-bottom: 6px;
}
.cm-done-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.link-role-picker {
    margin-top: 6px;
}
.link-role-toggle {
    background: none;
    border: none;
    padding: 6px 2px;
    color: var(--blurple);
    font-size: 0.785714rem;
    text-decoration: underline;
    cursor: pointer;
}
.modal-footer .link-settings-unlink {
    margin-right: auto;
    color: var(--red);
}
.cm-blocker-list {
    margin-top: 10px;
    padding: 9px 11px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--tone-danger) 28%, transparent);
    background: color-mix(in srgb, var(--tone-danger) 8%, transparent);
    color: var(--text-secondary);
    font-size: 0.857143rem;
}
.cm-blocker-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--red);
    font-weight: 700;
}
.cm-blocker-title .material-icons {
    font-size: 1.142857rem;
}
.cm-blocker-list ul {
    margin: 6px 0 0 18px;
    padding: 0;
}
.cm-blocker-list li {
    margin: 3px 0;
}
.cm-log-panel {
    max-height: 220px;
    overflow: auto;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--bg-modifier-accent);
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 0.857143rem;
}
.cm-log-title {
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 6px;
}
.cm-log-section {
    margin-top: 8px;
}
.cm-log-section ul {
    margin: 4px 0 0 18px;
    padding: 0;
}
.cm-log-line.error {
    color: var(--red);
}
.cm-advanced-divider {
    margin: 14px 0 10px;
    padding-top: 12px;
    border-top: 1px solid var(--bg-modifier-accent);
}
.cm-section-body {
    padding: 4px 14px 14px 14px;
    border-top: 1px solid var(--bg-modifier-accent);
}
.cm-field { margin-bottom: 10px; }
.cm-field .modal-label { margin-bottom: 4px; }
.cm-hint {
    font-size: 0.857143rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.cm-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.cm-check-result {
    flex: 1;
    min-width: 200px;
    font-size: 0.857143rem;
    padding: 7px 10px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--text-muted);
}
.cm-check-result.ok {
    border-left-color: var(--green);
    background: color-mix(in srgb, var(--tone-success) 8%, transparent);
    color: var(--green);
}
.cm-check-result.error {
    border-left-color: var(--red);
    background: color-mix(in srgb, var(--tone-danger) 8%, transparent);
    color: var(--red);
}
.cm-check-result ul { margin: 4px 0 0 0; padding-left: 18px; }
.cm-check-result li { margin: 2px 0; }
.cm-action-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 6px;
}
.cm-primary-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.cm-mention-member-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    background: var(--bg-secondary);
}
.cm-mention-member-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-modifier-accent);
}
.cm-mention-member-item:last-child { border-bottom: none; }
.cm-mention-member-item:hover { background: var(--bg-hover); }
.cm-mention-member-item input[type="checkbox"] { margin: 0; }
.cm-mention-member-item img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}
.cm-mention-member-item .cm-member-name {
    flex: 1;
    font-size: 0.928571rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cm-mention-role-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    margin-bottom: 6px;
    background: var(--bg-secondary);
}
.cm-mention-role-name {
    flex: 1;
    font-size: 0.928571rem;
    font-weight: 600;
}
.cm-mention-role-count {
    font-size: 0.785714rem;
    color: var(--text-muted);
    padding: 1px 6px;
    background: var(--bg-modifier-accent);
    border-radius: 4px;
}

/* ===== Sidebar hover gear icon ===== */
.channel-item { position: relative; }
.channel-gear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.142857rem !important;
    color: var(--text-muted) !important;
    opacity: 0;
    transition: opacity 0.12s, color 0.12s;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
}
.channel-item:hover .channel-gear { opacity: 0.9; }
.channel-gear:hover {
    color: var(--text-primary) !important;
    background: var(--bg-modifier-accent);
    opacity: 1 !important;
}
/* Touch screens have no hover, so the gear stays visible and gets a finger-sized target. */
@media (hover: none) {
    /* !important: the sidebar icon rule fixes every .material-icons to 26px wide, which would swallow the padding. */
    .channel-gear { opacity: 0.8; right: 4px; width: 40px !important; height: 40px !important; padding: 10px !important; font-size: 1.428571rem !important; }
    .channel-item:has(> .channel-gear) { padding-right: 48px !important; }
}

/* ===== Linked Channel Message History ===== */
.linked-channel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin: 0 14px 8px;
    max-height: 460px;
    min-height: 180px;
}
.linked-channel-messages-empty {
    color: var(--text-muted);
    font-size: 0.928571rem;
    padding: 24px 0;
    text-align: center;
}
.linked-channel-message {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--bg-modifier-accent);
}
.linked-channel-message:last-child { border-bottom: none; }
.linked-channel-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-modifier-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.linked-channel-message-avatar .material-icons {
    font-size: 1.142857rem;
    color: var(--text-muted);
}
.linked-channel-message.from-line .linked-channel-message-avatar {
    background: var(--brand-line);
}
.linked-channel-message.from-line .linked-channel-message-avatar .material-icons {
    color: var(--on-strong);
}
.linked-channel-message-body { flex: 1; min-width: 0; }
.linked-channel-message-header {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 2px;
}
.linked-channel-message-author {
    font-size: 0.928571rem;
    font-weight: 600;
    color: var(--text-primary);
}
.linked-channel-message-time {
    font-size: 0.785714rem;
    color: var(--text-muted);
}
.linked-channel-message-text {
    font-size: 0.928571rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}
.linked-channel-attachments {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.linked-channel-attachment-image {
    display: inline-block;
    max-width: 320px;
}
.linked-channel-attachment-image img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 6px;
    display: block;
    object-fit: cover;
    background: var(--bg-secondary);
}
.linked-channel-attachment-video,
.linked-channel-attachment-audio {
    max-width: 320px;
    width: 100%;
    border-radius: 6px;
}
.linked-channel-attachment-file {
    display: inline-block;
    color: var(--blurple, var(--accent-text));
    text-decoration: none;
    font-size: 0.857143rem;
    padding: 6px 10px;
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    width: fit-content;
}
.linked-channel-attachment-file:hover {
    background: color-mix(in srgb, var(--blurple) 8%, transparent);
}
.linked-channel-composer {
    padding: 12px 16px;
    border-top: 1px solid var(--bg-modifier-accent);
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 5;
}

.linked-channel-message.from-discord .linked-channel-message-avatar {
    background: var(--action-bg);
}
.linked-channel-message.from-discord .linked-channel-message-avatar .material-icons {
    color: var(--on-strong);
}
.linked-channel-message.from-webui .linked-channel-message-avatar {
    background: var(--blurple, var(--action-bg));
    opacity: 0.7;
}
.linked-channel-message.from-webui .linked-channel-message-avatar .material-icons {
    color: var(--on-strong);
}
.linked-channel-message.from-system .linked-channel-message-avatar {
    background: var(--green, var(--tone-success));
}
.linked-channel-message.from-system .linked-channel-message-avatar .material-icons {
    color: var(--on-strong);
}

/* ===== Link Test Log Panel ===== */
.link-test-log {
    margin-top: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--bg-modifier-accent);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.857143rem;
    max-height: 320px;
    overflow-y: auto;
}
.link-test-log-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.928571rem;
}
.link-test-log-header.ok { color: var(--green); }
.link-test-log-header.error { color: var(--red); }
.link-test-log-header .material-icons { font-size: 1.285714rem; }
.link-test-log-item {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--bg-modifier-accent);
}
.link-test-log-item:first-of-type { border-top: none; }
.link-test-log-item > .material-icons {
    font-size: 1.142857rem;
    margin-top: 1px;
    flex-shrink: 0;
}
.link-test-log-item.ok > .material-icons { color: var(--green); }
.link-test-log-item.error > .material-icons { color: var(--red); }
.link-test-log-body { flex: 1; min-width: 0; }
.link-test-log-step {
    color: var(--text-primary);
    margin-bottom: 4px;
}
.link-test-log-detail {
    background: var(--surface-inset);
    color: var(--text-muted);
    padding: 6px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.785714rem;
    margin: 4px 0 0;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 140px;
    overflow-y: auto;
}

/* ===== Compact channel overview ===== */

/* ===== Calendar focus layout ===== */
.chat-area.calendar-view-active .workspace-hero,
.chat-area.calendar-view-active .input-area {
    display: none;
}

.chat-area.calendar-view-active .messages-container {
    overflow: hidden;
    padding: 12px 16px 16px;
}

.calendar-view-active .cal-page-left {
    gap: 10px;
    padding: 12px 14px 14px;
}

.calendar-view-active .cal-page-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.calendar-view-active .cal-day {
    min-height: 104px;
}

.calendar-view-active .cal-day-panel {
    width: clamp(280px, 18vw, 340px);
}

.calendar-view-active .cal-page-actions {
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: var(--surface-soft);
}

.calendar-view-active .cal-page-action-btn {
    min-height: 38px;
    padding: 8px 13px;
    font-weight: 700;
}

/* ===== Calendar reminder: guided two-step form ===== */
.cal-reminder-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 14px;
}

.cal-reminder-section {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: var(--surface-soft);
}

.cal-reminder-section-head {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    margin-bottom: 2px;
}

.cal-reminder-step {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--blurple);
    color: var(--on-strong);
    font-size: 0.928571rem;
    font-weight: 800;
}

.cal-reminder-section-head strong,
.cal-reminder-section-head small {
    display: block;
}

.cal-reminder-section-head strong {
    color: var(--text-primary);
    font-size: 1rem;
}

.cal-reminder-section-head small,
.cal-reminder-field-note {
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 0.785714rem;
    line-height: 1.5;
}

.cal-reminder-section .modal-label {
    margin-top: 4px;
}

.cal-reminder-field-note {
    margin: -3px 0 2px;
}

.cal-reminder-summary {
    display: grid;
    grid-column: 1 / -1;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--blurple) 36%, transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--blurple) 12%, transparent);
}

.cal-reminder-summary:empty {
    display: none;
}

.cal-reminder-name > summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.857143rem;
    padding: 4px 0;
}

.cal-reminder-name[open] > summary {
    margin-bottom: 6px;
}

.cal-reminder-summary .cal-reminder-preview {
    margin: 4px 0;
    padding: 8px 10px;
    border-left: 3px solid var(--blurple);
    border-radius: 6px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 0.857143rem;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cal-reminder-summary .cal-reminder-preview-empty {
    color: var(--text-muted);
}

.cal-reminder-summary strong,
.cal-reminder-summary span,
.cal-reminder-summary small {
    display: block;
}

.cal-reminder-summary strong {
    color: var(--text-primary);
    font-size: 0.928571rem;
}

.cal-reminder-summary span {
    color: var(--text-secondary);
    font-size: 0.857143rem;
}

.cal-reminder-summary small {
    color: var(--blurple-soft, var(--accent-text));
    font-size: 0.785714rem;
    line-height: 1.5;
}

@media (max-width: 980px) {
    .chat-area.calendar-view-active .messages-container {
        overflow-y: auto;
    }

    .calendar-view-active .cal-page-action-btn {
        flex: 1 1 180px;
    }

    .calendar-view-active .cal-day-panel {
        width: 100%;
    }
}

@media (max-width: 680px) {
    .cal-reminder-body {
        grid-template-columns: 1fr;
    }
}

/* ===== Mobile navigation: full-screen content + on-demand drawer ===== */
.mobile-nav-toggle,
.mobile-nav-close,
.mobile-nav-backdrop {
    display: none;
}

/* Drawer navigation covers phones and portrait tablets (keep in sync with MOBILE_NAV_MEDIA_QUERY). */
@media (max-width: 1024px) {
    .discord-app {
        display: block;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
    }

    .server-list,
    .channel-sidebar {
        position: fixed;
        left: 0;
        width: min(88vw, 360px);
        animation: none;
        transform: translateX(calc(-100% - 24px));
        visibility: hidden;
        transition:
            transform 240ms cubic-bezier(.2,.8,.2,1),
            visibility 0s linear 240ms;
    }

    .server-list {
        z-index: 92;
        top: 0;
        height: calc(60px + env(safe-area-inset-top));
        flex-direction: row;
        justify-content: flex-start;
        gap: 8px;
        padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid var(--border-soft);
    }

    .server-list .server-icon {
        width: 44px;
        height: 44px;
        flex: 0 0 44px;
        border-radius: 14px;
    }

    .channel-sidebar {
        z-index: 91;
        top: calc(60px + env(safe-area-inset-top));
        height: calc(100dvh - 60px - env(safe-area-inset-top));
        min-height: 0;
        max-height: none;
        border-right: 1px solid var(--border-soft);
        box-shadow: 24px 0 60px color-mix(in srgb, var(--shadow-color) 42%, transparent);
    }

    .channel-sidebar .server-header {
        height: 58px;
        min-height: 58px;
        padding: 0 10px 0 16px;
    }

    .channel-sidebar .server-header h2 {
        flex: 1;
        min-width: 0;
    }

    .channel-sidebar .sidebar-scroll-area {
        max-height: none;
    }

    .channel-sidebar .sidebar-insights {
        display: none;
    }

    .channel-sidebar .channel-item {
        min-height: 48px;
    }

    .channel-sidebar .user-bar {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }

    body.mobile-nav-open .server-list,
    body.mobile-nav-open .channel-sidebar {
        transform: translateX(0);
        visibility: visible;
        transition-delay: 0s;
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 90;
        border: 0;
        background: var(--scrim);
        opacity: 0;
        pointer-events: none;
        backdrop-filter: blur(3px);
        transition: opacity 200ms ease;
    }

    body.mobile-nav-open .mobile-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-nav-toggle,
    .mobile-nav-close {
        display: inline-grid;
        place-items: center;
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        border: 1px solid var(--border-medium);
        border-radius: 13px;
        background: var(--surface-medium);
        color: var(--text-primary);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-nav-toggle svg,
    .mobile-nav-close svg {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .chat-area {
        width: 100%;
        height: 100dvh;
        min-height: 0;
    }

    .chat-header {
        min-height: calc(60px + env(safe-area-inset-top));
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
        background: var(--bg-dark);
        backdrop-filter: blur(16px);
    }

    .chat-header-main {
        min-width: 0;
        flex: 1 1 auto;
    }

    .chat-header-title-row {
        min-width: 0;
    }

    .chat-header-title-row .channel-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

}

@media (max-width: 720px) {
    .chat-header-context,
    .chat-header-meta {
        display: none;
    }
}

@media (max-width: 420px) {
    .server-list,
    .channel-sidebar {
        width: min(92vw, 360px);
    }

    .chat-header-title-row > .material-icons {
        display: none;
    }
}

/* ===== 自動投稿画面 (一覧 + 編集パネル) ===== */
.chat-area.autopost-view-active :is(.workspace-hero, .input-area, .workspace-toolbar-toggle) { display: none; }
.au-page {
    container: autopost / inline-size;
    --au-accent: var(--blurple);
    --au-tint: color-mix(in srgb, var(--blurple) 14%, transparent);
    --au-line: var(--border-medium);
    --au-card: var(--surface-soft);
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 1440px;
    flex: 0 0 auto;
    margin: 0 auto;
    color: var(--text-primary);
    font-family: var(--font);
}
.au-page [hidden] { display: none !important; }
.au-page button { font-family: inherit; }
.au-page :focus-visible { outline: 2px solid var(--au-accent); outline-offset: 2px; }

.au-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 64px 0;
    color: var(--text-secondary);
}

/* --- ヘッダー --- */
.au-head {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    padding: 12px 0;
    background: var(--bg-dark);
    border-bottom: 1px solid var(--au-line);
}
.au-head-copy h2 { font-size: 1.571429rem; font-weight: 800; line-height: 1.2; }
.au-head-copy p { margin-top: 3px; font-size: 0.928571rem; color: var(--text-secondary); line-height: 1.5; }
.au-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.au-dirty {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--tone-warning-soft);
    color: var(--tone-warning-text);
    font-size: 0.857143rem;
    font-weight: 700;
}
.au-dirty .material-icons { font-size: 1.071429rem; }

.au-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid var(--au-line);
    border-radius: 10px;
    background: var(--surface-medium);
    color: var(--text-primary);
    font-size: 0.928571rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.au-btn .material-icons { font-size: 1.285714rem; }
.au-btn:hover { background: var(--surface-strong); }
.au-btn:disabled { opacity: .6; cursor: wait; }
.au-btn:active { transform: translateY(1px); }
.au-btn.primary { background: var(--action-bg); border-color: transparent; color: var(--on-accent); }
.au-btn.primary:hover { background: var(--action-hover); }
.au-btn.primary.is-dirty { box-shadow: 0 0 0 3px color-mix(in srgb, var(--au-accent) 30%, transparent); }
.au-btn.ghost { background: transparent; padding: 0 10px; }
.au-btn.small { min-height: 34px; padding: 0 10px; border-radius: 8px; }

.au-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.au-icon-btn:hover { background: var(--surface-medium); color: var(--text-primary); }
.au-icon-btn.is-danger:hover { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }

/* --- ステータス --- */
.au-status {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--au-line);
    background: var(--surface-soft);
    font-size: 0.928571rem;
    line-height: 1.5;
}
.au-status.is-ok { border-color: color-mix(in srgb, var(--green) 40%, transparent); background: color-mix(in srgb, var(--green) 10%, transparent); }
.au-status.is-err { border-color: color-mix(in srgb, var(--red) 45%, transparent); background: color-mix(in srgb, var(--red) 10%, transparent); }
.au-status.is-info { border-color: color-mix(in srgb, var(--cyan) 40%, transparent); background: color-mix(in srgb, var(--cyan) 9%, transparent); }
.au-status button {
    border: 0;
    border-radius: 8px;
    padding: 5px 12px;
    background: var(--surface-strong);
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
}

/* --- 次の投稿 --- */
.au-next {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 16px;
    padding: 16px 18px;
    border: 1px solid color-mix(in srgb, var(--au-accent) 35%, transparent);
    border-radius: var(--radius);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--au-accent) 16%, transparent), transparent 70%),
        var(--au-card);
    overflow: hidden;
}
.au-next.is-empty { border-color: var(--au-line); background: var(--au-card); }
.au-next-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--au-tint);
    color: var(--au-accent);
}
.au-next-icon .material-icons { font-size: 1.857143rem; }
.au-next-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.au-next-kicker { font-size: 0.857143rem; font-weight: 700; color: var(--accent-text); }
.au-next-title { font-size: 1.285714rem; font-weight: 800; overflow-wrap: anywhere; }
.au-next-sub { font-size: 0.928571rem; color: var(--text-secondary); }
.au-next-count { text-align: right; line-height: 1.1; }
.au-next-count strong { display: block; font-family: var(--font-display); font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.au-next-count span { font-size: 0.857143rem; color: var(--text-muted); }
.au-next-bar { grid-column: 1 / -1; height: 4px; border-radius: 99px; background: var(--surface-medium); overflow: hidden; }
.au-next-bar i { display: block; height: 100%; border-radius: inherit; background: var(--au-accent); transition: width 0.9s linear; }
.au-next-more {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    list-style: none;
    font-size: 0.857143rem;
    color: var(--text-secondary);
}
.au-next-more li { display: inline-flex; gap: 8px; min-width: 0; }
.au-next-more span { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-next-more time { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- レイアウト --- */
.au-layout {
    display: grid;
    grid-template-columns: minmax(300px, 30%) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}
.au-page.is-empty .au-layout { grid-template-columns: minmax(0, 1fr); }
.au-page.is-empty .au-editor-col { display: none; }
.au-list-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.au-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.au-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.au-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--au-line);
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.928571rem;
    font-weight: 700;
    cursor: pointer;
}
.au-chip b { font-size: 0.785714rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-medium); font-variant-numeric: tabular-nums; }
.au-chip:hover { background: var(--surface-soft); }
.au-chip.is-active { background: var(--au-tint); border-color: color-mix(in srgb, var(--au-accent) 50%, transparent); color: var(--text-primary); }
.au-search {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 200px;
    flex: 1 1 220px;
    max-width: 320px;
    padding: 0 10px;
    border: 1px solid var(--au-line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--text-muted);
}
.au-search .material-icons { font-size: 1.357143rem; }
.au-search input {
    flex: 1;
    min-width: 0;
    height: 36px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.928571rem;
}

/* --- ルール行 --- */
.au-rules { display: flex; flex-direction: column; gap: 8px; }
.au-rule {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--au-line);
    border-radius: var(--radius);
    background: var(--au-card);
    transition: border-color var(--transition), background var(--transition);
}
.au-rule:hover { background: var(--surface-medium); }
.au-rule.is-active { border-color: var(--au-accent); background: var(--au-tint); }
.au-rule.has-issue:not(.is-active) { border-color: var(--tone-warning-border); }
.au-rule-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 6px 12px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    min-width: 0;
}
.au-rule-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--au-tint);
    color: var(--au-accent);
}
.au-rule.is-off .au-rule-icon { background: var(--surface-medium); color: var(--text-muted); }
.au-rule.is-off .au-rule-copy strong { color: var(--text-secondary); }
.au-rule-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.au-rule-copy strong { font-size: 1.071429rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-rule-when { font-size: 0.928571rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-rule-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.au-rule-tags em {
    font-style: normal;
    font-size: 0.785714rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--surface-medium);
    color: var(--text-secondary);
}
.au-rule-tags em.is-warn { background: var(--tone-warning-soft); color: var(--tone-warning-text); }
.au-rule-next { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 0.857143rem; color: var(--text-muted); white-space: nowrap; }
.au-rule-next b { font-size: 0.928571rem; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.au-rule.is-off .au-rule-next b { color: var(--text-muted); }
.au-rule > .au-switch { margin-right: 14px; }
.au-list-empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px; color: var(--text-muted); font-size: 1rem; }

/* --- スイッチ --- */
.au-switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; flex: none; }
.au-switch input { position: absolute; inset: 0; z-index: 1; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.au-switch-ui {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 99px;
    background: var(--surface-strong);
    transition: background var(--transition);
}
.au-switch-ui::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--shadow-color) 35%, transparent);
    transition: transform var(--transition);
}
.au-switch input:checked + .au-switch-ui { background: var(--au-accent); }
.au-switch input:checked + .au-switch-ui::after { transform: translateX(18px); }
.au-switch input:focus-visible + .au-switch-ui { outline: 2px solid var(--au-accent); outline-offset: 2px; }
.au-switch-text { font-size: 0.928571rem; font-weight: 700; color: var(--text-secondary); min-width: 3.2em; }

/* --- 履歴 --- */
.au-history { border: 1px solid var(--au-line); border-radius: var(--radius); background: var(--au-card); }
.au-history summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.au-history summary::-webkit-details-marker { display: none; }
.au-history summary b { margin-left: auto; font-size: 0.857143rem; padding: 1px 8px; border-radius: 99px; background: var(--surface-medium); }
.au-history ul { list-style: none; padding: 0 14px 12px; display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow: auto; }
.au-history li { display: flex; gap: 10px; font-size: 0.928571rem; }
.au-history li .material-icons { font-size: 1.285714rem; color: var(--text-muted); margin-top: 1px; }
.au-history li small { margin-left: 8px; color: var(--text-muted); }
.au-history li p { margin-top: 2px; color: var(--text-secondary); line-height: 1.5; word-break: break-word; }
.au-history-empty { color: var(--text-muted); }

/* --- 空状態 / テンプレート --- */
.au-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 20px;
    border: 1px dashed var(--au-line);
    border-radius: var(--radius);
    text-align: center;
}
.au-empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--au-tint); color: var(--au-accent); }
.au-empty-icon .material-icons { font-size: 2.142857rem; }
.au-empty h3 { font-size: 1.285714rem; }
.au-empty p { color: var(--text-secondary); font-size: 1rem; margin-bottom: 8px; }
.au-custom-templates { width: 100%; min-width: 0; border: 1px solid var(--au-line); border-radius: var(--radius); background: var(--au-card); text-align: left; }
.au-custom-templates > summary { display: flex; align-items: center; gap: 10px; padding: 16px; font-size: 1rem; font-weight: 700; cursor: pointer; list-style: none; }
.au-custom-templates > summary::-webkit-details-marker { display: none; }
.au-custom-templates > summary:hover { background: var(--au-tint); border-radius: var(--radius); }
.au-custom-templates > summary > .material-icons { color: var(--au-accent); }
.au-template-chevron { margin-left: auto; transition: transform var(--transition); }
.au-custom-templates[open] > summary .au-template-chevron { transform: rotate(180deg); }
.au-custom-templates-body { padding: 0 16px 16px; }
.au-post-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.au-post-type { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; min-width: 0; padding: 18px; border: 1px solid var(--au-line); border-radius: var(--radius); background: var(--au-card); }
.au-post-type h3 { display: flex; align-items: center; gap: 8px; font-size: 1.142857rem; }
.au-post-type h3 .material-icons { color: var(--au-accent); }
.au-post-type > p { color: var(--text-secondary); font-size: 0.928571rem; line-height: 1.7; }
.au-post-type > .au-custom-templates { margin-top: auto; }
.au-post-type .au-template-grid { padding-top: 12px; }
.au-rule-group { display: flex; flex-direction: column; gap: 10px; }
.au-rule-group > h3 { margin-top: 8px; font-size: 1rem; color: var(--text-secondary); }
.au-mention-picker { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.au-mention-picker > .au-toggle-row { align-items: flex-start; }
.au-mention-picker > .au-toggle-row > input { margin-top: 4px; accent-color: var(--au-accent); }
.au-mention-picker .au-hint:empty { display: none; }
.au-mention-picker select { max-width: 100%; }
@container autopost (max-width: 640px) { .au-post-types { grid-template-columns: minmax(0, 1fr); } }
.au-template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 10px; width: 100%; }
.au-template {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    row-gap: 3px;
    padding: 14px;
    border: 1px solid var(--au-line);
    border-radius: var(--radius);
    background: var(--au-card);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.au-template:hover { border-color: var(--au-accent); background: var(--au-tint); transform: translateY(-1px); }
.au-template-icon { grid-row: 1 / span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--au-tint); color: var(--au-accent); }
.au-template strong { font-size: 1rem; align-self: end; }
.au-template small { font-size: 0.857143rem; line-height: 1.5; color: var(--text-secondary); }

/* --- 編集パネル --- */
.au-editor-col { min-width: 0; scroll-margin-top: calc(var(--au-head-height, 96px) + 12px); }
.au-editor,
.au-editor-empty {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--au-line);
    border-radius: var(--radius);
    background: var(--bg-medium);
    box-shadow: var(--shadow-soft);
}
.au-editor { overflow: visible; }
.au-editor-empty { align-items: center; gap: 6px; padding: 36px 20px; text-align: center; color: var(--text-secondary); box-shadow: none; background: var(--au-card); }
.au-editor-empty .material-icons:first-child { font-size: 2.428571rem; color: var(--text-muted); }
.au-editor-empty strong { color: var(--text-primary); font-size: 1.142857rem; }
.au-editor-empty p { font-size: 0.928571rem; margin-bottom: 8px; }
.au-editor-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--au-line); }
.au-back { flex: none; }
.au-name-input {
    flex: 1;
    min-width: 0;
    height: 38px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 1.142857rem;
    font-weight: 800;
}
.au-name-input:hover { background: var(--surface-soft); }
.au-name-input:focus { outline: 0; border-color: var(--au-accent); background: var(--surface-soft); }
.au-editor-scroll { padding: 20px; display: flex; flex-direction: column; gap: 24px; }
.au-issues {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--tone-warning-soft);
    color: var(--tone-warning-text);
    font-size: 1rem;
    font-weight: 700;
}
.au-issues .material-icons { font-size: 1.285714rem; }
.au-block-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.au-block-head h3 { font-size: 1.071429rem; font-weight: 800; line-height: 26px; }
.au-block-head p { font-size: 0.857143rem; color: var(--text-secondary); }
.au-step { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--au-accent); color: var(--on-accent); font-size: 0.928571rem; font-weight: 800; }
[data-theme="navy"] .au-step, [data-theme="light"] .au-step { color: var(--on-accent); }
.au-block-body { display: flex; flex-direction: column; gap: 14px; }

.au-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.au-seg-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--au-line);
    border-radius: 12px;
    background: var(--au-card);
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
}
.au-seg-btn .material-icons { font-size: 1.571429rem; color: var(--text-muted); }
.au-seg-btn strong { display: block; font-size: 1rem; color: var(--text-primary); }
.au-seg-btn small { display: block; font-size: 0.785714rem; line-height: 1.4; }
.au-seg-btn:hover { background: var(--surface-medium); }
.au-seg-btn.is-active { border-color: var(--au-accent); background: var(--au-tint); }
.au-seg-btn.is-active .material-icons { color: var(--au-accent); }

.au-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.au-field.au-narrow { max-width: 280px; }
.au-label { font-size: 0.857143rem; font-weight: 700; color: var(--text-secondary); }
.au-label small { font-weight: 400; color: var(--text-muted); }
.au-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.au-hint { font-size: 0.857143rem; color: var(--text-muted); line-height: 1.5; }
.au-hint code, .au-callout code { font-family: ui-monospace, monospace; font-size: 0.785714rem; padding: 1px 5px; border-radius: 5px; background: var(--surface-medium); }
.au-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.au-grid-3 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 0.8fr); gap: 10px; }
/* 実行条件を「○○ が 0 より大きい とき」と1文で入力する */
.au-condition-sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.au-condition-sentence > select:first-child { flex: 1 1 220px; min-width: 0; }
.au-condition-sentence .au-condition-value { flex: 0 0 96px; width: 96px; }
.au-condition-sentence .au-condition-operator { flex: 0 1 150px; min-width: 0; }
.au-condition-word { color: var(--text-secondary); font-weight: 600; }
.au-inline { display: flex; gap: 8px; align-items: stretch; }
.au-inline .discord-select { flex: 1; min-width: 0; }
.au-textarea { width: 100%; resize: vertical; min-height: 96px; line-height: 1.6; }
.au-editor .discord-input, .au-editor .discord-select { width: 100%; }

.au-presets { display: inline-flex; gap: 4px; }
.au-presets button { border: 0; border-radius: 7px; padding: 3px 9px; background: var(--surface-medium); color: var(--text-secondary); font-size: 0.857143rem; font-weight: 700; cursor: pointer; }
.au-presets button:hover { background: var(--surface-strong); color: var(--text-primary); }
.au-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.au-day { position: relative; cursor: pointer; }
.au-day input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.au-day span { display: grid; place-items: center; height: 40px; border: 1px solid var(--au-line); border-radius: 10px; background: var(--au-card); font-weight: 700; color: var(--text-secondary); transition: background var(--transition), border-color var(--transition); }
.au-day:hover span { background: var(--surface-medium); }
.au-day input:checked + span { background: var(--au-accent); border-color: transparent; color: var(--on-accent); }
[data-theme="navy"] .au-day input:checked + span, [data-theme="light"] .au-day input:checked + span { color: var(--on-accent); }
.au-day input:focus-visible + span { outline: 2px solid var(--au-accent); outline-offset: 2px; }
.au-times { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.au-time-edit { display: flex; align-items: center; gap: 4px; }
.au-editor .au-time-edit .discord-input { width: 148px; min-height: 44px; }
.au-add-time-toggle { align-self: flex-start; }
.au-presets button[aria-pressed="true"] { background: var(--au-tint); color: var(--text-primary); }
.au-preview-inline { display: none; }
.au-day span { min-height: 44px; }
.au-editor [aria-invalid="true"] { border-color: var(--tone-danger-text); }
.au-time-chip { display: inline-flex; align-items: center; gap: 2px; padding: 6px 6px 6px 12px; border-radius: 99px; background: var(--au-tint); font-weight: 700; font-variant-numeric: tabular-nums; }
.au-time-chip:not(:has(button)) { padding-right: 12px; }
.au-time-chip button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); cursor: pointer; }
.au-time-chip button:hover { background: var(--surface-strong); color: var(--text-primary); }
.au-time-chip .material-icons { font-size: 1.071429rem; }
.au-time-add { display: inline-flex; flex-wrap: nowrap; gap: 6px; }
.au-time-add input { width: 132px; }
.au-page .au-btn { white-space: nowrap; }

.au-callout { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--au-tint); }
.au-callout .material-icons { font-size: 1.428571rem; color: var(--au-accent); margin-top: 1px; }
.au-callout strong { display: block; font-size: 1rem; }
.au-callout small { display: block; font-size: 0.857143rem; color: var(--text-secondary); margin-top: 1px; }
.au-toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.au-toggle-row strong { display: block; font-size: 1rem; }
.au-toggle-row small { display: block; font-size: 0.857143rem; color: var(--text-secondary); }
.au-more { border: 1px solid var(--au-line); border-radius: 10px; padding: 0 12px; }
.au-more[open] { padding-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.au-more summary { padding: 10px 0; font-size: 0.928571rem; font-weight: 700; color: var(--text-secondary); cursor: pointer; }
.au-vars { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.au-vars button { border: 1px dashed var(--au-line); border-radius: 99px; padding: 3px 10px; background: transparent; color: var(--text-secondary); font-size: 0.857143rem; cursor: pointer; }
.au-vars button:hover { border-style: solid; border-color: var(--au-accent); color: var(--text-primary); background: var(--au-tint); }

/* --- 投稿イメージ(Discord風) --- */
.au-preview { border: 1px solid var(--au-line); border-radius: 12px; background: var(--bg-dark); overflow: hidden; }
.au-preview-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--au-line); font-size: 0.857143rem; font-weight: 700; color: var(--text-secondary); }
.au-preview-head .material-icons { font-size: 1.142857rem; }
.au-preview-head small { margin-left: auto; font-weight: 400; color: var(--text-muted); }
.au-msg { display: flex; gap: 12px; padding: 12px; }
.au-msg-avatar { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--au-accent); color: var(--on-accent); }
[data-theme="navy"] .au-msg-avatar, [data-theme="light"] .au-msg-avatar { color: var(--on-accent); }
.au-msg-body { min-width: 0; }
.au-msg-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.au-msg-meta strong { font-size: 1rem; }
.au-msg-meta small { font-size: 0.785714rem; color: var(--text-muted); }
.au-bot-tag { padding: 0 5px; border-radius: 4px; background: var(--action-bg); color: var(--on-accent); font-size: var(--type-min); font-weight: 800; line-height: 15px; }
[data-theme="navy"] .au-bot-tag, [data-theme="light"] .au-bot-tag { color: var(--on-strong); }
.au-msg-text { margin-top: 3px; font-size: 1rem; line-height: 1.6; word-break: break-word; }
.au-mention { padding: 0 3px; border-radius: 4px; background: color-mix(in srgb, var(--au-accent) 25%, transparent); color: var(--au-accent); font-weight: 700; }
.au-link { color: var(--cyan); text-decoration: underline; }

/* --- 作成専用ページ --- */
.au-create-page { gap: 24px; padding-bottom: 16px; }
.au-create-head { padding: 12px 0 18px; gap: 16px; }
.au-breadcrumb { display: inline-flex; align-items: center; gap: 5px; margin-bottom: 12px; padding: 0; border: 0; background: transparent; color: var(--text-secondary); font: inherit; font-size: 0.928571rem; cursor: pointer; }
.au-breadcrumb:hover { color: var(--au-accent); }
.au-breadcrumb .material-icons { font-size: 1.214286rem; }
.au-create-progress { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; padding: 0; list-style: none; }
.au-create-progress li { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 0.857143rem; font-weight: 700; }
.au-create-progress li > span { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--au-line); border-radius: 50%; font-variant-numeric: tabular-nums; }
.au-create-progress .is-current { color: var(--text-primary); }
.au-create-progress .is-current > span { background: var(--au-accent); border-color: transparent; color: var(--on-accent); }
.au-create-progress .is-complete > span { background: var(--au-tint); border-color: transparent; color: var(--au-accent); }
.au-create-progress .material-icons { font-size: 1.142857rem; }
.au-create-choose { width: 100%; max-width: 1120px; align-self: center; padding-bottom: 24px; }
.au-create-intro { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0 22px; text-align: center; }
.au-create-intro h3 { font-size: 1.571429rem; }
.au-create-intro p { font-size: 1rem; line-height: 1.7; color: var(--text-secondary); }
.au-template-category { display: flex; align-items: center; gap: 8px; margin: 16px 0 12px; font-size: 1rem; }
.au-template-category .material-icons { font-size: 1.357143rem; color: var(--au-accent); }
.au-create-choose .au-template-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.au-create-choose .au-template { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 22px; min-height: 188px; }
.au-create-choose .au-template strong { align-self: auto; font-size: 1.071429rem; line-height: 1.6; }
.au-create-choose .au-template small { font-size: 0.928571rem; line-height: 1.7; }
.au-create-choose .au-template::after { content: '→'; position: absolute; top: 24px; right: 22px; color: var(--text-muted); }
.au-create-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 24px; align-items: start; }
.au-create-form, .au-create-review { min-width: 0; }
.au-create-form .au-editor { border: 0; background: transparent; box-shadow: none; gap: 20px; }
.au-create-form .au-editor-head { flex-wrap: wrap; padding: 16px 20px; gap: 10px; border: 1px solid var(--au-line); border-radius: var(--radius); background: var(--au-card); }
.au-create-form .au-editor-head > .au-label { flex: 1 0 100%; }
.au-create-form .au-name-input { padding: 0 10px; border-color: var(--au-line); background: var(--bg-dark); font-size: 1.071429rem; font-weight: 700; }
.au-create-form .au-editor-scroll { padding: 0; gap: 20px; }
.au-type-settings { background: var(--au-card); }
.au-type-settings summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.au-create-form .au-block { padding: 20px; border: 1px solid var(--au-line); border-radius: var(--radius); background: var(--au-card); scroll-margin-top: calc(var(--au-head-height, 130px) + 16px); }
.au-create-form .au-block-head { margin-bottom: 18px; }
.au-create-form .au-block-body { gap: 18px; }
.au-create-form .au-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.au-create-review { position: sticky; top: calc(var(--au-head-height, 130px) + 16px); display: flex; flex-direction: column; gap: 16px; }
.au-create-review .au-preview-head { flex-wrap: wrap; padding: 12px; }
.au-create-review .au-preview-head small { margin-left: 0; }
.au-create-review .au-msg { min-height: 140px; padding: 18px 14px; }
.au-review-card { border: 1px solid var(--au-line); border-radius: var(--radius); background: var(--au-card); overflow: hidden; scroll-margin-top: calc(var(--au-head-height, 130px) + 16px); }
.au-review-title { display: flex; align-items: center; gap: 7px; padding: 16px; border-bottom: 1px solid var(--au-line); }
.au-review-title > .material-icons { font-size: 1.357143rem; color: var(--au-accent); }
.au-review-title h3 { font-size: 1rem; }
.au-review-badge { margin-left: auto; padding: 3px 8px; border-radius: 99px; background: var(--au-tint); color: var(--au-accent); font-size: 0.785714rem; font-weight: 700; }
.au-review-badge.needs-input { background: var(--tone-warning-soft); color: var(--tone-warning-text); }
.au-review-list { display: flex; flex-direction: column; gap: 16px; padding: 16px; }
.au-review-list dt { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; font-size: 0.857143rem; color: var(--text-muted); }
.au-review-list dt .material-icons { font-size: 1.142857rem; }
.au-review-list dd { margin: 0 0 0 22px; font-size: 0.928571rem; line-height: 1.6; overflow-wrap: anywhere; }
.au-review-note { margin: 0; padding: 12px 16px; border-top: 1px solid var(--au-line); color: var(--text-secondary); font-size: 0.857143rem; line-height: 1.7; }
.au-create-tip { display: flex; align-items: flex-start; justify-content: center; gap: 7px; font-size: 0.857143rem; line-height: 1.7; color: var(--text-muted); }
.au-create-tip .material-icons { flex: none; margin-top: 1px; font-size: 1.214286rem; }
.au-create-footer { position: sticky; bottom: -1px; z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px 16px; padding: 16px; border: 1px solid var(--au-line); border-radius: var(--radius); background: var(--bg-medium); box-shadow: var(--shadow-soft); }
.au-create-footer > div { min-width: 0; }
.au-create-footer .au-status { grid-column: 1 / -1; margin: 0; padding: 10px; overflow-wrap: anywhere; }
.au-footer-state { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; align-items: center; }
.au-footer-state p { margin: 0; font-size: 0.928571rem; font-weight: 700; line-height: 1.5; }
.au-footer-state small { grid-column: 1 / -1; }
.au-footer-actions { display: flex; align-items: center; gap: 8px; }
.au-create-footer .au-dirty { font-size: 0.785714rem; padding: 3px 7px; }
.au-create-footer strong { display: block; font-size: 1rem; }
.au-create-footer small { display: block; margin-top: 3px; color: var(--text-secondary); font-size: 0.857143rem; line-height: 1.6; }
.au-batch-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.au-batch-tabs .au-btn { white-space: normal; text-align: left; }
@container autopost (max-width: 880px) {
    .au-create-layout { grid-template-columns: minmax(0, 1fr); }
    .au-create-review { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .au-create-review > .au-preview { display: none; }
    .au-create-review .au-review-card { grid-column: 1 / -1; }
    .au-preview-inline { display: block; }
    .au-create-review .au-create-tip { grid-column: 1 / -1; justify-content: flex-start; }
    .au-create-footer { grid-template-columns: minmax(0, 1fr); }
    .au-footer-actions { justify-content: flex-end; }
    .au-create-choose .au-template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container autopost (max-width: 560px) {
    .au-create-head { position: static; }
    .au-create-head .au-head-copy p { display: block; }
    .au-create-progress { width: 100%; justify-content: space-between; gap: 8px; }
    .au-create-progress li { gap: 5px; font-size: 0.785714rem; }
    .au-create-choose .au-template-grid, .au-create-review { grid-template-columns: minmax(0, 1fr); }
    .au-create-choose .au-template { min-height: 0; padding: 18px; }
    .au-create-form .au-block, .au-create-form .au-editor-head { padding: 16px; }
    .au-create-form .au-editor-head .au-name-input { flex-basis: 100%; }
    .au-create-form .au-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .au-create-footer { gap: 8px; padding: 12px; }
    .au-footer-state small { font-size: 0.785714rem; }
    .au-footer-actions { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.4fr); gap: 6px; }
    .au-create-footer .au-btn { padding: 0 8px; min-height: 44px; font-size: 0.857143rem; }
    .au-review-card { scroll-margin-top: 16px; }
}

/* --- 作業領域の幅に合わせる（サイドバーの幅も考慮） --- */
.au-page:not(.has-editor) .au-layout { grid-template-columns: minmax(0, 1fr); }
.au-page:not(.has-editor) .au-editor-col { display: none; }
.au-page.has-editor .au-rule-next { display: none; }
.au-page.has-editor .au-rule-main { grid-template-columns: auto minmax(0, 1fr); }
.au-rule-tags em, .au-seg-btn small, .au-next-more { font-size: 0.857143rem; }
.au-next-count strong { font-size: 1.571429rem; }
.au-page.has-editor .au-next { grid-template-columns: auto minmax(0, 1fr); }
.au-page.has-editor .au-next-count { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 6px; }
.au-next-more li { flex-wrap: wrap; }
@container autopost (max-width: 1000px) {
    .au-layout { grid-template-columns: minmax(0, 1fr); }
    .au-page.has-editor .au-list-col { display: none; }
}
@container autopost (max-width: 560px) {
    .au-head-copy p { display: none; }
    .au-head-actions { width: 100%; justify-content: flex-end; }
    .au-editor-head { flex-wrap: wrap; }
    .au-name-input { flex-basis: calc(100% - 100px); }
    .au-editor-scroll { padding: 16px; }
    .au-next { grid-template-columns: auto minmax(0, 1fr); }
    .au-next-count { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 6px; }
    .au-rule-next { display: none; }
    .au-rule-main { grid-template-columns: auto minmax(0, 1fr); }
    .au-grid-2, .au-grid-3, .au-seg { grid-template-columns: 1fr; }
    .au-days { gap: 4px; }
    .au-search { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
    .au-page *, .au-page *::before, .au-page *::after { transition: none !important; animation: none !important; }
}
[data-reduced-motion="true"] .au-page *, [data-reduced-motion="true"] .au-page *::before, [data-reduced-motion="true"] .au-page *::after { transition: none !important; animation: none !important; }

/* ===== 集合日・出欠集計 ===== */
.chat-area.gathering-view-active :is(.workspace-hero, .input-area, .workspace-toolbar-toggle) { display: none; }
.ga-page { container: gathering / inline-size; --au-accent: var(--blurple); --au-line: var(--border-medium); --au-tint: color-mix(in srgb, var(--blurple) 14%, transparent); display: flex; flex-direction: column; gap: 22px; width: 100%; max-width: 1440px; margin: 0 auto; flex: 0 0 auto; padding-bottom: 24px; color: var(--text-primary); }
.ga-page [hidden] { display: none !important; }
.ga-page a { overflow-wrap: anywhere; }
.ga-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0 20px; border-bottom: 1px solid var(--border-medium); }
.ga-eyebrow { display: block; margin-bottom: 7px; font-size: 0.857143rem; font-weight: 800; color: var(--au-accent); letter-spacing: .06em; }
.ga-header h2 { font-size: 1.714286rem; line-height: 1.4; }
.ga-header p { margin-top: 6px; color: var(--text-secondary); font-size: 0.928571rem; line-height: 1.7; }
.ga-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.ga-create-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 24px; align-items: start; }
.ga-form { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.ga-card { min-width: 0; display: flex; flex-direction: column; gap: 18px; padding: 22px; border: 1px solid var(--border-medium); border-radius: var(--radius); background: var(--surface-soft); }
.ga-card h3 { font-size: 1.142857rem; line-height: 1.5; }
.ga-section-title { display: flex; align-items: center; gap: 10px; }
.ga-section-title > span { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: var(--au-accent); color: var(--on-accent); font-size: 0.928571rem; font-weight: 800; flex: none; }
.ga-mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ga-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; border: 1px solid var(--border-medium); border-radius: 12px; background: var(--surface-soft); color: var(--text-primary); text-align: left; cursor: pointer; }
.ga-mode .material-icons { color: var(--au-accent); font-size: 1.642857rem; }
.ga-mode strong { font-size: 1rem; line-height: 1.5; }
.ga-mode small { font-size: 0.857143rem; color: var(--text-secondary); line-height: 1.6; }
.ga-mode.active { border-color: var(--au-accent); background: var(--au-tint); }
.ga-field { display: flex; flex-direction: column; min-width: 0; gap: 8px; font-size: 0.928571rem; font-weight: 700; }
.ga-field > span > small { color: var(--text-muted); font-weight: 400; margin-left: 5px; font-size: 0.785714rem; }
.ga-page .discord-input, .ga-page .discord-select { width: 100%; min-height: 44px; }
.ga-page textarea.discord-input { line-height: 1.7; resize: vertical; }
.ga-field .au-btn { align-self: flex-start; }
.ga-card details > summary { cursor: pointer; padding: 10px 0; font-size: 0.928571rem; color: var(--text-secondary); }
.ga-card details[open] > .ga-field { margin-top: 16px; }
.ga-card select[multiple] { min-height: 120px; }
.ga-field input[type="checkbox"] { width: 18px; height: 18px; vertical-align: middle; margin-right: 6px; }
.ga-custom-rules { display: grid; gap: 18px; }
.ga-custom-rule { display: grid; gap: 14px; min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--border-medium); border-radius: 10px; }
.ga-custom-rule legend { padding: 0 8px; font-size: 0.928571rem; font-weight: 700; }
.ga-custom-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.928571rem; }
.ga-custom-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
@media (max-width: 600px) { .ga-custom-grid { grid-template-columns: minmax(0,1fr); } }
.ga-help { display: block; font-size: 0.857143rem; font-weight: 400; color: var(--text-secondary); line-height: 1.8; overflow-wrap: anywhere; }
.ga-date-list { display: flex; flex-direction: column; gap: 10px; }
.ga-date-row { display: grid; grid-template-columns: 24px minmax(0, 1.5fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.ga-date-row > b { color: var(--text-muted); font-size: 0.857143rem; }
.ga-date-row label { min-width: 0; }
.ga-page .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; white-space: nowrap; }
.ga-delivery { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ga-delivery-alt { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 6px; border: 0; background: none; color: var(--text-secondary); font-size: 0.857143rem; text-decoration: underline; cursor: pointer; }
.ga-delivery-alt .material-icons { font-size: 1.142857rem; }
.ga-delivery-alt.active { color: var(--text-primary); font-weight: 700; }
.ga-rule-sentence { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--bg-dark); color: var(--text-primary); font-size: 0.857143rem; line-height: 1.6; }
.ga-notify-details > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.ga-notify-details > summary::-webkit-details-marker { display: none; }
.ga-notify-details[open] > summary { margin-bottom: 14px; }
.ga-notify-details[open] { display: flex; flex-direction: column; gap: 18px; }
.ga-notify-summary { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ga-notify-summary strong { font-size: 1.071429rem; }
.ga-notify-summary span { color: var(--text-secondary); font-size: 0.857143rem; overflow-wrap: anywhere; }
.ga-notify-change { flex: 0 0 auto; color: var(--blurple); font-size: 0.857143rem; font-weight: 600; text-decoration: underline; }
.ga-notify-details[open] .ga-notify-change { display: none; }
.ga-preview { overflow: hidden; border: 1px solid var(--border-medium); border-radius: var(--radius); background: var(--bg-dark); }
.ga-preview-side { position: sticky; top: 16px; }
.ga-preview-inline { display: none; }
.ga-preview-head { display: flex; align-items: center; gap: 7px; padding: 14px 16px; border-bottom: 1px solid var(--border-medium); color: var(--text-secondary); font-size: 0.857143rem; font-weight: 700; }
.ga-preview-head .material-icons { font-size: 1.285714rem; }
.ga-preview-content { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.ga-preview-label { font-size: 0.785714rem; font-weight: 700; color: var(--au-accent); }
.ga-preview-content h3 { font-size: 1.285714rem; line-height: 1.6; overflow-wrap: anywhere; }
.ga-preview-content > p { color: var(--text-secondary); font-size: 0.928571rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.ga-preview-option { display: flex; gap: 10px; align-items: flex-start; padding-top: 12px; border-top: 1px solid var(--border-medium); }
.ga-preview-option > span { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; background: var(--surface-medium); color: var(--text-muted); font-size: 0.857143rem; flex: none; }
.ga-preview-option strong { font-size: 0.928571rem; line-height: 1.7; }
.ga-preview-option small { display: block; font-size: 0.857143rem; color: var(--text-muted); margin-top: 4px; }
.ga-preview-answers { display: flex; gap: 6px; }
.ga-preview-answers span { flex: 1; padding: 7px 4px; text-align: center; border-radius: 7px; font-size: 0.857143rem; border: 1px solid var(--border-medium); color: var(--text-secondary); }
.ga-submit { position: sticky; bottom: -1px; z-index: 4; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border-medium); border-radius: var(--radius); padding: 14px 16px; background: var(--bg-medium); box-shadow: var(--shadow-soft); }
.ga-submit-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ga-submit-row p { color: var(--text-secondary); font-size: 0.857143rem; line-height: 1.6; }
.ga-page .au-btn { min-height: 44px; }
.ga-status { padding: 12px 14px; border: 1px solid var(--border-medium); border-radius: 9px; background: var(--surface-soft); color: var(--text-primary); font-size: 0.928571rem; line-height: 1.7; overflow-wrap: anywhere; }
.ga-status.error { background: var(--tone-danger-soft); border-color: var(--tone-danger-border); color: var(--tone-danger-text); }
.ga-status.success { background: var(--tone-success-soft); border-color: var(--tone-success-border); color: var(--tone-success-text); }
.ga-submit .ga-status { margin: 0; }
.ga-command-text { min-height: 150px; margin-top: 8px; }
.ga-poll-list { display: flex; flex-direction: column; gap: 10px; }
.ga-poll-row { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border-medium); border-radius: 12px; background: var(--surface-soft); color: var(--text-primary); text-align: left; cursor: pointer; }
.ga-poll-row > .material-icons:first-child { padding: 10px; color: var(--au-accent); border-radius: 12px; background: var(--au-tint); }
.ga-poll-row > span:nth-child(2) { flex: 1; min-width: 0; }
.ga-poll-row strong { display: block; font-size: 1.071429rem; overflow-wrap: anywhere; }
.ga-poll-row small { display: block; margin-top: 5px; color: var(--text-secondary); font-size: 0.857143rem; }
.ga-poll-detail { scroll-margin-top: 16px; }
.ga-poll-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.ga-poll-heading h3 { font-size: 1.428571rem; margin-top: 9px; overflow-wrap: anywhere; }
.ga-poll-heading p { margin-top: 5px; color: var(--text-secondary); font-size: 0.928571rem; line-height: 1.7; }
.ga-tag { display: inline-block; padding: 3px 9px; border-radius: 99px; color: var(--tone-success-text); background: var(--tone-success-soft); font-size: 0.857143rem; font-weight: 700; }
.ga-tag.closed { color: var(--text-secondary); background: var(--surface-medium); }
.ga-respondents { font-size: 2.142857rem; font-variant-numeric: tabular-nums; flex: none; }
.ga-respondents small { display: block; font-size: 0.785714rem; color: var(--text-muted); font-weight: 400; }
.ga-result-options { display: flex; flex-direction: column; gap: 10px; }
.ga-result-option { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; background: var(--surface-soft); border: 1px solid var(--border-medium); border-radius: 10px; }
.ga-result-option strong { font-size: 1rem; }
.ga-counts { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-secondary); font-size: 0.857143rem; margin-top: 7px; }
.ga-counts b { margin-left: 4px; font-size: 1.071429rem; color: var(--text-primary); }
.ga-answer-buttons, .ga-poll-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.ga-empty { padding: 44px 16px; text-align: center; color: var(--text-secondary); }
.ga-empty > .material-icons { display: block; font-size: 2.571429rem; color: var(--au-accent); margin-bottom: 14px; }
.ga-empty h3 { color: var(--text-primary); font-size: 1.214286rem; }
.ga-empty p { margin-top: 9px; font-size: 0.928571rem; line-height: 1.7; }
@container gathering (max-width: 920px) {
    .ga-create-layout { grid-template-columns: minmax(0,1fr); }
    .ga-preview-side { display: none; }
    .ga-preview-inline { display: block; }
}
@container gathering (max-width: 560px) {
    .ga-header h2 { font-size: 1.571429rem; }
    .ga-card { padding: 16px; }
    .ga-mode-grid { grid-template-columns: minmax(0,1fr); }
    .ga-mode { display: grid; grid-template-columns: auto minmax(0,1fr); column-gap: 12px; row-gap: 3px; }
    .ga-mode .material-icons { grid-row: 1 / span 2; align-self: center; }
    .ga-date-row { grid-template-columns: 16px minmax(0,1.4fr) minmax(0,1fr); gap: 6px; }
    .ga-date-row .au-icon-btn { grid-column: 3; justify-self: end; }
    .ga-date-row input { padding: 8px; font-size: 0.928571rem; }
    .ga-submit { padding: 12px; }
    .ga-submit-row { flex-direction: column; align-items: stretch; gap: 6px; }
    .ga-submit-row .au-btn { width: 100%; }
    .ga-submit-row p { font-size: 0.785714rem; }
    .ga-delivery .au-btn { flex: 1; padding: 0 9px; font-size: 0.857143rem; }
    .ga-result-option { align-items: stretch; flex-direction: column; gap: 12px; padding: 13px; }
    .ga-answer-buttons .au-btn { flex: 1; padding: 0 10px; }
}

/* ===== Workspace visual system: shared by operations, administration and permissions ===== */
:root { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
body { font-size: var(--type-body); line-height: var(--leading-body); }
button, input, select, textarea { font-family: inherit; }
input, select, textarea { min-width: 0; max-width: 100%; }
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--action-bg); }

/* Explicit selectors keep focus visible despite older control-specific outline resets. */
body :is(a, button, input, select, textarea, summary, [tabindex], [role="button"]):focus-visible {
    outline: var(--focus-width) solid var(--focus-color);
    outline-offset: var(--focus-offset);
}
body :is(input, select, textarea):focus-visible { outline-offset: 2px; }
body :is(button, input, select, textarea):disabled {
    opacity: var(--state-disabled-opacity);
    cursor: not-allowed;
    filter: none;
    transform: none;
    box-shadow: none;
}
body [aria-disabled="true"] { opacity: var(--state-disabled-opacity); cursor: not-allowed; }
/* Sits on the text baseline when an icon replaces an emoji inside a sentence. */
.material-icons { flex-shrink: 0; vertical-align: -0.15em; }
.material-icons[data-icon-fallback="svg"] { font-feature-settings: normal; }
.material-icons svg { stroke-width: var(--icon-stroke); }

/* A quiet frame makes the selected destination and its icon the strongest navigation cue. */
.ui-workspace .server-list { background: var(--bg-darkest); border-color: var(--border-medium); }
.ui-workspace .channel-sidebar { background: var(--bg-dark); border-color: var(--border-medium); box-shadow: none; }
.ui-workspace .server-header { border-color: var(--border-medium); }
.ui-workspace .server-header h2 { font-size: 1.071429rem; letter-spacing: 0; gap: var(--space-2); }
.ui-workspace .server-icon {
    border-radius: var(--radius-card);
    background: var(--surface-soft);
    color: var(--text-secondary);
    box-shadow: inset 0 0 0 1px var(--border-medium);
}
.ui-workspace .server-icon:is(:hover, .active) { background: var(--action-bg); color: var(--on-accent); box-shadow: none; }
.ui-workspace .server-icon:is(:hover, .active) .material-icons { color: var(--on-accent); }
.ui-workspace .channel-category { font-size: var(--type-caption); letter-spacing: 0.04em; color: var(--text-muted); }
.ui-workspace .channel-item {
    gap: var(--space-3);
    min-height: 42px;
    margin: 3px var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-control);
    color: var(--text-secondary);
    font-size: var(--type-label);
    font-weight: 500;
    box-shadow: none;
}
.ui-workspace .channel-item:hover { background: var(--state-hover); color: var(--text-primary); transform: none; box-shadow: none; }
.ui-workspace .channel-item.active {
    background: var(--state-active);
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--blurple);
}
body.ui-workspace .channel-sidebar .channel-item .material-icons {
    width: 26px;
    min-width: 26px;
    height: 26px;
    font-size: 1.428571rem;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    box-shadow: none;
}
body.ui-workspace .channel-sidebar .channel-item:is(:hover, .active) .material-icons { color: var(--blurple); background: transparent; box-shadow: none; }
.ui-workspace .sidebar-insights { padding: var(--space-3); gap: var(--space-3); border-color: var(--border-medium); }
.ui-workspace .sidebar-card {
    padding: var(--space-3);
    background: var(--surface-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}
.ui-workspace .sidebar-card-header { font-size: var(--type-caption); color: var(--text-secondary); }
.ui-workspace .sidebar-card-header > span > .material-icons {
    width: 24px;
    height: 24px;
    font-size: 1.285714rem;
    color: var(--blurple);
    background: transparent;
    box-shadow: none;
}
.ui-workspace .sidebar-toggle { width: 32px; height: 32px; border-radius: var(--radius-sm); color: var(--text-muted); }
.ui-workspace .user-bar { background: var(--bg-darkest); border-color: var(--border-medium); }
.ui-workspace .chat-header { background: var(--bg-dark); border-bottom: 1px solid var(--border-medium); }
.ui-workspace .chat-header-title-row { gap: var(--space-2); }
.ui-workspace .chat-header-title-row > .material-icons { color: var(--blurple); }
.ui-workspace .channel-name { font-size: var(--type-heading); letter-spacing: 0; }
.ui-workspace .chat-header-context { color: var(--text-secondary); }

/* Cards share the same edge, corner and elevation; content remains in its existing layout. */
body :is(.settings-section, .admin-card, .channel-state-card, .channel-chat-panel, .kt-card, .unassigned-card, .pd-project-card, .au-editor, .au-history, .au-rule) {
    background: var(--surface-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}
body :is(.settings-section, .admin-card):hover { transform: none; }
body :is(.discord-input, .discord-select) {
    min-height: var(--control-height);
    padding: 9px var(--space-3);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-control);
    background: var(--surface-input);
    color: var(--text-primary);
    font-size: var(--type-body);
    line-height: 1.5;
}
body :is(.discord-input, .discord-select):focus { border-color: var(--focus-color); box-shadow: none; }
body :is(.discord-input, .discord-select)[aria-invalid="true"] { border-color: var(--red); }
body :is(.modal-label, .settings-field label, .au-label) { color: var(--text-secondary); font-size: var(--type-label); font-weight: 600; }
body :is(.modal-hint, .settings-hint, .au-hint) { color: var(--text-muted); font-size: var(--type-caption); line-height: var(--leading-body); }

body :is(.btn, .discord-btn, .action-btn, .settings-save-btn, .settings-link-btn, .permission-btn,
    .cal-page-action-btn, .au-btn, .admin-back) {
    min-height: var(--control-height);
    gap: var(--space-2);
    border-radius: var(--radius-control);
    font-size: var(--type-label);
    font-weight: 600;
    line-height: 1.4;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}
body :is(.btn, .discord-btn, .action-btn, .settings-save-btn, .cal-page-action-btn, .au-btn):hover { filter: none; transform: none; }
/* リンクで作ったボタンも、ボタンと同じ見た目にする */
body a:is(.btn, .discord-btn) { display: inline-flex; align-items: center; text-decoration: none; }
body :is(.btn-primary, .btn-blurple, .discord-btn.primary, .settings-save-btn, .permission-btn:not(.secondary), .au-btn.primary) {
    background: var(--action-bg);
    border-color: transparent;
    color: var(--on-accent);
    box-shadow: none;
}
body :is(.btn-primary, .btn-blurple, .discord-btn.primary, .settings-save-btn, .permission-btn:not(.secondary), .au-btn.primary):hover:not(:disabled) { background: var(--action-hover); color: var(--on-accent); }
body :is(.btn-gray, .permission-btn.secondary) { background: var(--surface-medium); color: var(--text-primary); }
body :is(.btn-gray, .permission-btn.secondary):hover { background: var(--surface-strong); }
body :is(.discord-btn.danger, .au-btn.danger, .au-btn.is-danger) { background: var(--danger-soft); border-color: var(--red); color: var(--red); }
body :is(.discord-btn.danger, .au-btn.danger, .au-btn.is-danger):hover { background: var(--danger-soft); color: var(--red); }
body :is(.btn, .discord-btn, .permission-btn) > .material-icons { font-size: 1.285714rem; }
body :is(.admin-mode-tabs, .settings-mode-tabs, .admin-theme-picker) {
    padding: var(--space-1);
    gap: var(--space-1);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-control);
    background: var(--surface-soft);
}
body :is(.admin-mode-tab, .settings-mode-tab, .admin-theme-picker .theme-option) { color: var(--text-secondary); border-radius: var(--radius-sm); min-height: 32px; }
body :is(.admin-mode-tab, .settings-mode-tab, .admin-theme-picker .theme-option):hover { background: var(--state-hover); color: var(--text-primary); }
body :is(.admin-mode-tab.is-active, .settings-mode-tab.is-active, .admin-theme-picker .theme-option.active) {
    background: var(--state-active);
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1px var(--state-active-border);
}
body :is(.ev-type-tab, .mode-toggle-btn).active { background: var(--action-bg); color: var(--on-accent); border-color: var(--action-bg); }
body :is(.au-step, .au-msg-avatar, .au-bot-tag, .cal-reminder-step) { background: var(--action-bg); color: var(--on-accent); }
body .au-day input:checked + span { background: var(--action-bg); color: var(--on-accent); }

body .modal-overlay { padding: var(--space-4); background: var(--scrim); }
body .modal {
    max-width: 100%;
    max-height: calc(100dvh - 32px);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-dialog);
    background: var(--surface-card);
    box-shadow: var(--shadow-dialog);
}
body :is(.modal-header, .modal-footer) { background: var(--surface-card); border-color: var(--border-medium); padding: var(--space-4) var(--space-5); }
body .modal-header h3 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--type-heading); }
body .modal-header h3 > .material-icons { color: var(--blurple); font-size: 1.571429rem; }
body .modal-body { padding: var(--space-5); overflow-wrap: anywhere; }
body .modal-close { flex-shrink: 0; width: 36px; height: 36px; border-radius: var(--radius-sm); }

/* Administration uses the same typography and selection language as the workspace. */
.ui-admin .admin-page { background: var(--body-bg); }
.ui-admin .admin-topbar { background: var(--bg-dark); border-color: var(--border-medium); }
.ui-admin .admin-container { gap: var(--space-5); }
.ui-admin .admin-layout { gap: var(--space-5); }
.ui-admin .admin-content { gap: var(--space-5); }
.ui-admin .admin-nav { background: var(--bg-dark); border-color: var(--border-medium); border-radius: var(--radius-card); box-shadow: none; gap: var(--space-4); }
body :is(.admin-nav-link, .settings-nav-link) {
    white-space: normal;
    overflow-wrap: anywhere;
    min-height: var(--control-height);
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
    color: var(--text-secondary);
    border-radius: var(--radius-control);
    font-size: var(--type-label);
}
body :is(.admin-nav-link, .settings-nav-link) .material-icons { color: var(--text-muted); font-size: 1.285714rem; }
body :is(.admin-nav-link, .settings-nav-link):hover { background: var(--state-hover); color: var(--text-primary); }
body :is(.admin-nav-link, .settings-nav-link).is-active { background: var(--state-active); color: var(--text-primary); box-shadow: inset 3px 0 0 var(--blurple); }
body :is(.admin-nav-link, .settings-nav-link).is-active .material-icons { color: var(--blurple); }
body :is(.admin-nav-group-title, .settings-nav-group-title) { font-size: 0.785714rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.04em; }
body :is(.admin-card-header, .settings-section-title) { padding: var(--space-4) var(--space-5); border-color: var(--border-medium); background: var(--surface-soft); color: var(--text-primary); font-size: var(--type-body); }
.ui-admin .admin-card-body { padding: var(--space-5); }
body :is(.admin-card-header, .settings-section-title) .material-icons { color: var(--blurple); font-size: 1.428571rem; }
body :is(.admin-status, .settings-role-box, .cal-reminder-section, .au-more) { border-color: var(--border-medium); border-radius: var(--radius-control); background: var(--surface-soft); }
body :is(.settings-link-status.is-ok, .admin-status.ok) { background: var(--success-soft); border-color: var(--green); }
body :is(.settings-link-status.is-warn, .admin-status.warn) { background: var(--warning-soft); border-color: var(--yellow); }
body :is(.settings-link-status.is-error, .admin-status.err) { background: var(--danger-soft); border-color: var(--red); }
body .settings-link-status.is-ok .material-icons { color: var(--green); }
body .settings-link-status.is-warn .material-icons { color: var(--yellow); }
body .settings-link-status.is-error .material-icons { color: var(--red); }
body :is(.summary-table, .rp-table, .subscription-table) { border-collapse: collapse; font-size: var(--type-label); }
body :is(.summary-table, .rp-table, .subscription-table) :is(th, td) { padding: 10px var(--space-3); border-color: var(--border-medium); }
body :is(.summary-table, .rp-table, .subscription-table) th { background: var(--bg-dark); color: var(--text-secondary); font-size: var(--type-caption); font-weight: 600; }
body :is(.summary-table, .rp-table, .subscription-table) tbody tr:hover { background: var(--state-hover); }

.ui-permission { height: auto; min-height: 100dvh; padding: var(--space-4); overflow-y: auto; background: var(--body-bg); }
.ui-permission .permission-panel { width: min(560px, 100%); padding: var(--space-8); border-color: var(--border-medium); border-radius: var(--radius-dialog); box-shadow: var(--shadow-dialog); }
.ui-permission .permission-icon { width: 52px; height: 52px; font-size: 1.857143rem; border-radius: var(--radius-card); background: var(--danger-soft); }
.ui-permission .permission-title { line-height: 1.4; }
.ui-permission .permission-text { font-size: var(--type-body); }

[data-ui-density="compact"] .ui-workspace .channel-item { min-height: 36px; padding-block: 5px; }
[data-ui-density="compact"] .ui-workspace .sidebar-card { padding: var(--space-2) var(--space-3); }
@media (min-width: 1025px) {
    .ui-workspace .server-list { width: 72px; }
    .ui-workspace .server-icon { width: 48px; height: 48px; }
    .ui-workspace .channel-sidebar { width: 276px; }
}
@media (max-width: 760px) {
    .ui-admin .admin-layout { grid-template-columns: minmax(0, 1fr); }
    .ui-admin .admin-container { padding: var(--space-3); }
    .ui-admin .admin-card-body { padding: var(--space-4); }
    .ui-admin .admin-topbar { height: auto; padding: var(--space-3); }
    .ui-admin .admin-topbar-left { align-items: flex-start; }
    .ui-admin .admin-mode-tabs { max-width: 100%; flex-wrap: wrap; }
    .ui-admin .admin-nav { position: static; max-height: none; }
    .ui-admin :is(.admin-nav-link, .admin-mode-tab) { white-space: normal; }
    .ui-admin :is(.admin-nav, .admin-content, .admin-card, .admin-card-body, .admin-topbar-left, .admin-topbar-right) { min-width: 0; max-width: 100%; }
    .ui-admin :is(.admin-card-body, .admin-status) { overflow-wrap: anywhere; }
    .ui-admin .link-box { flex-wrap: wrap; }
    .ui-admin .link-box input { flex: 1 1 180px; }
    .ui-admin .guild-calendar-card { grid-template-columns: minmax(0, 1fr); }
    .ui-admin .guild-calendar-card-body { grid-template-columns: minmax(0, 1fr); }
    .ui-admin .period-row { flex-wrap: wrap; }
}
@media (max-width: 720px) {
    .ui-workspace :is(.chat-area, .chat-header-main, .messages-container, .workspace-hero, .input-area) { min-width: 0; max-width: 100%; }
    .ui-workspace .channel-sidebar { box-shadow: var(--shadow-dialog); }
    .ui-workspace .channel-sidebar .channel-item { min-height: 44px; }
    body .modal-overlay { padding: var(--space-3); }
    body .modal { width: 100%; max-height: calc(100dvh - 24px); border-radius: var(--radius-card); }
    body :is(.modal-header, .modal-body, .modal-footer) { padding: var(--space-4); }
    .ui-permission .permission-panel { padding: var(--space-5); }
    .ui-permission .permission-actions > a { justify-content: center; flex: 1 1 100%; }
}

/* Command cards stay legible in both wide and narrow workspace headers. */

@media (max-width: 720px) {
    .ui-workspace .footer-mode-row { gap: var(--space-2); }
    .ui-workspace .chat-mode-toggle { width: auto; min-height: 32px; }
    .ui-workspace .chat-mode-hint { font-size: 0.785714rem; }
    /* The section nav is one strip of links that scrolls sideways and stays at the top while the page scrolls
       (a two-column grid in a 260px box meant scrolling inside scrolling). The layout becomes a flex column
       so the sticky strip has the whole page as its range; the group titles give way to the links. */
    .ui-workspace .settings-layout,
    .ui-admin .admin-layout { display: flex; flex-direction: column; align-items: stretch; gap: var(--space-3); }
    .ui-workspace .settings-nav,
    .ui-admin .admin-nav {
        position: sticky;
        top: 0;
        z-index: 4;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: var(--space-1);
        padding: var(--space-1);
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }
    .ui-workspace .settings-nav::-webkit-scrollbar,
    .ui-admin .admin-nav::-webkit-scrollbar { display: none; }
    /* The messages area pads its top by --space-3; offset the sticky strip so scrolled content cannot show above it. */
    .ui-workspace .settings-nav { top: calc(var(--space-3) * -1); }
    .ui-workspace .settings-nav-group,
    .ui-admin .admin-nav-group { display: contents; }
    .ui-workspace .settings-nav-group-title,
    .ui-admin .admin-nav-group-title { display: none; }
    .ui-workspace .settings-nav-link,
    .ui-admin .admin-nav-link { flex: 0 0 auto; min-height: 44px; padding: 6px var(--space-3); font-size: var(--type-caption); white-space: nowrap; }
    /* Jumping to a section must not leave its heading under the sticky strip. */
    .ui-workspace [data-settings-section],
    .ui-admin .admin-card[id^="admin-card-"] { scroll-margin-top: 72px; }
}

/* Filled controls and date badges use a matching foreground in every theme. */
body :is(.pd-action-btn, .kt-action-btn, .unassigned-claim-btn, .btn-discord-login,
    .pd-proj-tab.active, .kt-filter-btn.active, .rp-proj-tab.active, .cal-tab.active,
    .message-badge, .pd-member-avatar, .rp-member-avatar, .login-member-card-initial, .cm-step-number,
    .cal-today .cal-date, .mini-cal2-cell.mini-cal2-today .mini-cal2-num, .chat-fullcal-today .chat-fullcal-num) {
    background: var(--action-bg);
    color: var(--on-accent);
    border-color: var(--action-bg);
}
body :is(.pd-action-btn, .kt-action-btn, .unassigned-claim-btn, .btn-discord-login) {
    min-height: var(--control-height);
    border-radius: var(--radius-control);
    font-size: var(--type-label);
}
body :is(.pd-action-btn, .kt-action-btn, .unassigned-claim-btn, .btn-discord-login):hover:not(:disabled) { background: var(--action-hover); color: var(--on-accent); transform: none; }
body .btn-discord-login svg { fill: currentColor; }
body :is(.cal-page-nav-btn, .cal-page-today-btn, .rp-print-btn):hover { background: var(--action-bg); color: var(--on-accent); }
body .action-btn.btn-red { background: var(--action-danger); color: var(--white); }
body .action-btn.btn-red:hover { background: var(--action-danger-hover); }


@media (max-width: 420px) {
    /* Keep day cells tappable; only the table scrolls on the narrowest screens. */
    .ui-workspace .schedule-grid { min-width: 294px; width: 100%; grid-template-columns: 64px repeat(5, minmax(44px, 1fr)); }
    .ui-workspace .schedule-grid :is(.grid-header, .grid-cell) { min-width: 0; padding-inline: 2px; overflow-wrap: anywhere; }
    .ui-workspace .schedule-grid .grid-period { padding-inline: 6px; }
    .ui-workspace .schedule-grid .period-time { font-size: var(--type-min); }
}

/* ===== Component roles and responsive structure =====
   Builds on the tokens at the top of the file. Superseded rules were removed from the earlier
   sections, so these rules are the single definition rather than another override layer. */

/* Status markers drawn by the icon set in place of the former emoji. */
.material-icons.icon-tone-success { color: var(--tone-success); }
.material-icons.icon-tone-danger { color: var(--tone-danger); }
.material-icons.icon-tone-warning { color: var(--tone-warning); }
.material-icons.icon-tone-info { color: var(--tone-info); }
.material-icons.icon-tone-muted { color: var(--tone-muted); }

/* Button roles: one filled primary per group, neutral secondaries, and the old colour kept
   only on the icon so it still hints at the kind of action without competing for attention. */
body :is(.cal-page-action-btn, .action-btn),
body :is(.cal-page-action-btn, .action-btn):is(.btn-gray, .btn-green, .btn-cyan, .btn-orange) {
    border: 1px solid var(--border-medium);
    background: var(--surface-medium);
    color: var(--text-primary);
    box-shadow: none;
}
body :is(.cal-page-action-btn, .action-btn):is(:hover, .btn-gray:hover, .btn-green:hover, .btn-cyan:hover, .btn-orange:hover) { background: var(--surface-strong); filter: none; }
body :is(.cal-page-action-btn, .action-btn).btn-blurple {
    border-color: transparent;
    background: var(--action-bg);
    color: var(--on-accent);
}
body :is(.cal-page-action-btn, .action-btn).btn-blurple:hover { background: var(--action-hover); }
body :is(.cal-page-action-btn, .action-btn).btn-orange .material-icons { color: var(--tone-warning); }
body :is(.cal-page-action-btn, .action-btn).btn-cyan .material-icons { color: var(--tone-info); }
body :is(.cal-page-action-btn, .action-btn).btn-green .material-icons { color: var(--tone-success); }
body :is(.cal-page-action-btn, .action-btn).btn-red {
    border-color: var(--tone-danger-border);
    background: var(--tone-danger-soft);
    color: var(--tone-danger);
}
body :is(.cal-page-action-btn, .action-btn).btn-red:hover { background: color-mix(in srgb, var(--tone-danger) 22%, transparent); }
body .action-btn .action-btn-icon { background: color-mix(in srgb, currentColor 12%, transparent); }
body .action-btn .action-btn-detail { opacity: 1; color: var(--text-secondary); }
body .action-btn.btn-blurple .action-btn-detail { color: inherit; opacity: 0.85; }

/* Month caption for the calendar modal; the calendar page names the month in its own navigation. */
.cal-month-caption {
    margin-bottom: var(--space-2);
    text-align: center;
    font-size: 1.071429rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Admin period table: on phones each period becomes a two-line row instead of five squeezed columns. */
@media (max-width: 560px) {
    .ui-admin .periods-table thead { display: none; }
    .ui-admin .periods-table tbody tr {
        display: grid;
        grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr) 40px;
        grid-template-areas: "num name name del" "num start end del";
        align-items: center;
        gap: var(--space-2);
        padding: var(--space-2) 0;
        border-bottom: 1px solid var(--border-medium);
    }
    .ui-admin .periods-table td { padding: 0; }
    .ui-admin .periods-table td:nth-child(1) { grid-area: num; }
    .ui-admin .periods-table td:nth-child(2) { grid-area: name; }
    .ui-admin .periods-table td:nth-child(3) { grid-area: start; }
    .ui-admin .periods-table td:nth-child(4) { grid-area: end; }
    .ui-admin .periods-table td:nth-child(5) { grid-area: del; justify-self: center; }
}
.ui-admin .period-del-btn { min-width: 36px; min-height: 36px; justify-content: center; }

/* Drawer widths (tablet and phone): the header keeps its numbers but in a tighter form. */
@media (max-width: 1024px) {
    .chat-header { gap: var(--space-3); }
    .header-stat { min-height: 40px; padding: 4px 10px 4px 4px; }
    .header-stat-icon { width: 26px; min-width: 26px; height: 26px; font-size: 1.071429rem; }
    .workspace-hero { padding-inline: var(--space-4); }
    .messages-container { padding-inline: var(--space-4); }
    .input-area { padding-inline: var(--space-4); }
}
/* Tablets keep the two-line page description; phones hide it (the title says where you are). */
@media (min-width: 721px) and (max-width: 1024px) {
    .chat-header-context { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; }
}

/* Phones: the toolbar would push content down, so quick actions always sit above the input,
   as one scrollable row, and the footer drops its explanatory hint. */
@media (max-width: 720px) {
    .workspace-hero { display: none; }
    .chat-area.quick-toolbar-open .slash-commands { display: flex; }
    .chat-area.settings-view-active .input-area { display: none; }
    .messages-container { padding-inline: var(--space-3); }
    .input-area {
        padding: var(--space-2) var(--space-3) calc(var(--space-3) + env(safe-area-inset-bottom));
        background: var(--bg-dark);
        backdrop-filter: none;
    }
    .slash-btn { min-width: 0; min-height: 40px; }
    .footer-mode-row { flex-wrap: nowrap; }
    .chat-mode-toggle { width: auto; }
    .chat-mode-hint { display: none; }
    .cal-page-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
    .cal-page-actions .cal-page-action-btn { width: auto; justify-content: center; }
}

/* Landscape phones are too short for the header text, the quick-action cards and the full input dock
   together (the messages were left about 100px), so they take the phone layout. */
@media (orientation: landscape) and (max-height: 500px) {
    .chat-header-context,
    .chat-mode-hint,
    .workspace-hero { display: none; }
    .chat-area.quick-toolbar-open .slash-commands { display: flex; }
    .chat-header {
        min-height: calc(52px + env(safe-area-inset-top));
        padding-top: calc(4px + env(safe-area-inset-top));
        padding-bottom: 4px;
    }
    .input-area { padding-block: var(--space-2); }
    .slash-btn { min-width: 0; min-height: 36px; }
}

/* Touch screens get 44px targets on the small icon buttons. */
@media (pointer: coarse) {
    :is(.sidebar-toggle, .user-bar-settings-btn, .unassigned-icon-link, .ui-admin .period-del-btn, .modal-close) {
        min-width: 44px;
        min-height: 44px;
    }
    /* Tabs, filters, page actions and dialog buttons were 32-40px tall. The quick-action row and the chat-mode
       toggle above the input stay compact on purpose: they share the screen with the keyboard. */
    :is(.cal-page-nav-btn, .cal-page-today-btn, .cal-page-action-btn, .rp-print-btn, .kt-filter-btn, .rp-type-tab,
        .rp-proj-tab, .pd-proj-tab, .settings-mode-tab, .admin-mode-tab, .theme-option, .pd-action-btn, .kt-action-btn,
        .modal-footer .btn, .unassigned-sort button, .campus-bus-add, .action-btn) {
        min-height: 44px;
    }
    /* iOS Safari zooms the page when a field under 16px gets focus. !important because fields set their own
       size in many component rules (and some inline <style> blocks) that would otherwise out-specify this. */
    :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="button"], [type="submit"], [type="reset"], [type="image"]), select, textarea) {
        font-size: max(16px, 1rem) !important;
    }
}

/* ===== Small components and utilities =====
   These replace former inline style="" attributes in the HTML. Values sit on the shared spacing
   and type scale. display:none stays inline in the markup: it is state that JS toggles. */
.loading-state { padding: var(--space-8) 0; text-align: center; }
.loading-icon { font-size: 2.285714rem; color: var(--text-muted); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.divider-line { flex: 1; height: 1px; background: var(--border-medium); }
.divider-short { width: 32px; height: 1px; margin: var(--space-1) auto; background: var(--border-medium); }
.inset-panel {
    padding: 10px var(--space-3);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: var(--surface-inset);
}
.callout {
    padding: var(--space-4);
    border-left: 4px solid var(--accent-text);
    border-radius: var(--radius-sm);
    background: var(--bg-light);
}
.callout-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--space-2);
    font-size: var(--type-body);
    font-weight: 700;
    color: var(--text-primary);
}
.section-sep { padding-top: var(--space-3); border-top: 1px solid var(--border-medium); }
.result-box { padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--type-label); }
body .btn.btn-chip { min-height: 32px; padding: 2px var(--space-2); font-size: var(--type-min); }
.modal-overlay.modal-overlay--top { z-index: 10000; }
.modal-overlay.modal-overlay--raised { z-index: 9999; }
.modal.modal--sm { max-width: 440px; }
.modal.modal--md { max-width: 520px; }
.modal.modal--lg { max-width: 720px; }
.modal.modal--xl { width: 95vw; max-width: 800px; }
th.col-num { width: 36px; }
th.col-time { width: 110px; }
th.col-action { width: 40px; }

/* Utilities stand in for the inline styles they replaced, so like inline styles they must win over
   component rules: spacing and type use !important. Display and colour do not, because JS toggles
   el.style.display and sets el.style.color on status messages, and those writes must still apply. */
.u-mt-0 { margin-top: 0 !important; }
.u-mt-2 { margin-top: var(--space-2) !important; }
.u-mt-3 { margin-top: var(--space-3) !important; }
.u-mt-4 { margin-top: var(--space-4) !important; }
.u-mt-5 { margin-top: var(--space-5) !important; }
.u-mb-1 { margin-bottom: var(--space-1) !important; }
.u-mb-2 { margin-bottom: var(--space-2) !important; }
.u-mb-3 { margin-bottom: var(--space-3) !important; }
.u-mb-4 { margin-bottom: var(--space-4) !important; }
.u-mb-5 { margin-bottom: var(--space-5) !important; }
.u-ml-2 { margin-left: var(--space-2) !important; }
.u-pt-2 { padding-top: var(--space-2) !important; }
.u-pb-5 { padding-bottom: var(--space-5) !important; }
.u-py-4 { padding-block: var(--space-4) !important; }
.u-flex { display: flex; }
.u-block { display: block; }
.u-col { flex-direction: column !important; }
.u-flex-1 { flex: 1 !important; }
.u-items-center { align-items: center !important; }
.u-justify-between { justify-content: space-between !important; }
.u-justify-end { justify-content: flex-end !important; }
.u-wrap { flex-wrap: wrap !important; }
.u-gap-2 { gap: var(--space-2) !important; }
.u-gap-3 { gap: var(--space-3) !important; }
.u-text-xs { font-size: var(--type-min) !important; }
.u-text-sm { font-size: var(--type-caption) !important; }
.u-text-md { font-size: var(--type-label) !important; }
.u-text-base { font-size: var(--type-body) !important; }
.u-text-lg { font-size: 1.142857rem !important; }
.u-text-danger { color: var(--tone-danger); }
.u-text-muted { color: var(--text-muted); }
.u-text-secondary { color: var(--text-secondary); }
.u-text-primary { color: var(--text-primary); }
.u-text-center { text-align: center !important; }
.u-nowrap { white-space: nowrap !important; }
.u-mono { font-family: ui-monospace, Consolas, monospace !important; }
.u-align-middle { vertical-align: middle !important; }
.u-font-normal { font-weight: 400 !important; }
.u-leading-normal { line-height: 1.5 !important; }
.u-pointer { cursor: pointer !important; }
.u-relative { position: relative !important; }
.u-resize-y { resize: vertical !important; }
.u-w-full { width: 100% !important; }
.u-maxw-xs { max-width: 240px !important; }
.u-maxw-sm { max-width: 320px !important; }

/* Personal events and the mention-role label icon, formerly coloured inline. */
.cal-event.cal-event-personal { margin: 0 4px; border-radius: 3px; background: var(--violet); }
.cm-mention-role-icon { color: var(--accent-text); }

/* Parts of JS-rendered views that used to carry inline styles. Only per-item values (progress widths,
   calendar chip colours) remain inline in the templates. */
a.btn { text-decoration: none; }
.avatar-initial { font-size: var(--type-body); font-weight: 700; color: var(--text-secondary); }
.channel-item .material-icons.channel-unread-icon { color: var(--tone-danger); }
.channel-unread-label { font-weight: 700; color: var(--text-primary); }
.cal-event.cal-event-spacer { visibility: hidden; margin: 0; padding: 3px 6px; border: none; }

.embed.embed--narrow { width: 100%; max-width: 440px; }
.embed.embed--wide { max-width: 600px; }
.material-icons.embed-title-icon { font-size: 1.142857rem; vertical-align: text-bottom; }
.embed-link { color: var(--accent-text); }
.embed-footnote {
    margin-bottom: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-medium);
    font-size: var(--type-min);
    color: var(--text-muted);
}
.message-badge.embed-date-badge { margin-right: var(--space-2); padding: 2px 6px; background: var(--bg-light); }
.message-badge.embed-date-badge--task { color: var(--tone-danger-text); }
.message-badge.embed-date-badge--meeting { color: var(--tone-success-text); }
.message-badge.embed-date-badge--event { color: var(--tone-info-text); }

.linked-channel-avatar .material-icons { font-size: 1.285714rem; color: var(--on-strong); }
.message-text.linked-channel-note { color: var(--text-secondary); }
.linked-channel-attachment-file .material-icons { font-size: 1.142857rem; vertical-align: middle; }
body .channel-mini-action .material-icons { font-size: 1rem; }

.kt-filter-btn .material-icons { font-size: 1rem; }
.td-val.td-val--overdue { color: var(--tone-danger-text); }
.td-val.td-val--soon { color: var(--tone-warning-text); }
.rp-sum-num.rp-sum-num--open { color: var(--blurple); }
.rp-sum-num.rp-sum-num--done { color: var(--green); }
.rp-sum-num.rp-sum-num--overdue { color: var(--red); }
.rp-section-body.rp-section-body--table { padding: 0; overflow-x: auto; }
.rp-table th.col-progress { min-width: 120px; }
.rp-row-link { cursor: pointer; }
.rp-table td.rp-col-id { color: var(--text-muted); }
.rp-prog-pct { flex-shrink: 0; width: 32px; font-size: var(--type-min); text-align: right; color: var(--text-muted); }

.pd-donut-svg { flex-shrink: 0; }
.pd-donut-dot.pd-donut-dot--open { background: var(--blurple); }
.pd-donut-dot.pd-donut-dot--overdue { background: var(--red); }
.pd-donut-dot.pd-donut-dot--done { background: var(--green); }

/* English labels run longer than the Japanese ones these components were sized for. */
.settings-integration-main small {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    overflow-wrap: anywhere;
}
@media (max-width: 480px) {
    /* Both settings tabs stay visible: they share the row and long labels wrap instead of scrolling away. */
    .settings-mode-tabs { display: flex; width: 100%; }
    .settings-mode-tab { flex: 1 1 0; min-width: 0; justify-content: center; line-height: 1.25; text-align: center; white-space: normal; }
}

/* Link test dialog (built by app-link-test.js). Status colour comes from .lt-tone-*. */
.link-test-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    background: var(--scrim);
}
.link-test-modal {
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    overflow: auto;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-dialog);
    background: var(--surface-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-dialog);
}
.lt-head { display: flex; align-items: center; gap: var(--space-2); padding: 14px 18px; border-bottom: 1px solid var(--border-medium); }
.lt-head-icon { color: var(--accent-text); }
.lt-title { flex: 1; }
.lt-head .discord-btn { padding: 4px var(--space-4); }
.lt-phase { font-size: var(--type-caption); color: var(--text-muted); }
.lt-instruction { padding: var(--space-3) 18px; background: var(--action-bg); color: var(--on-accent); font-weight: 600; text-align: center; }
.lt-countdown { font-size: 1.285714rem; }
.lt-summary { padding: 10px 18px; border-bottom: 1px solid var(--border-medium); font-size: var(--type-label); color: var(--text-secondary); }
.lt-list { padding: 6px 6px 14px; }
.lt-category { padding: 10px var(--space-3) var(--space-1); font-size: var(--type-min); letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.lt-row { margin: var(--space-1) var(--space-3); padding: var(--space-2) var(--space-3); border-left: 3px solid var(--lt-tone); border-radius: var(--radius-sm); background: var(--surface-inset); }
.lt-row-head { display: flex; align-items: center; gap: var(--space-2); }
.lt-row-icon { font-size: 1.285714rem; color: var(--lt-tone); }
.lt-row-label { flex: 1; font-size: var(--type-label); }
.lt-row-status { font-size: var(--type-min); text-transform: uppercase; color: var(--text-muted); }
.lt-row-detail { margin-top: var(--space-1); padding-left: 26px; font-size: var(--type-caption); color: var(--text-secondary); }
.lt-row-logs {
    margin-top: 6px;
    padding: var(--space-2) 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-darkest);
    color: var(--tone-danger-text);
    font-family: Consolas, Monaco, monospace;
    font-size: var(--type-min);
    white-space: pre-wrap;
    word-break: break-all;
}
.lt-error { margin: var(--space-3); padding: var(--space-3); border: 1px solid var(--tone-danger-border); border-radius: var(--radius-sm); background: var(--tone-danger-soft); color: var(--tone-danger-text); }
.lt-tone-success { --lt-tone: var(--tone-success); color: var(--tone-success-text); }
.lt-tone-danger { --lt-tone: var(--tone-danger); color: var(--tone-danger-text); }
.lt-tone-warning { --lt-tone: var(--tone-warning); color: var(--tone-warning-text); }
.lt-tone-info { --lt-tone: var(--tone-info); }
.lt-tone-muted { --lt-tone: var(--text-muted); }
.lt-row:is(.lt-tone-success, .lt-tone-danger, .lt-tone-warning) { color: var(--text-primary); }

/* Web app invite link */
.registration-banner[hidden] { display: none; }
.registration-banner { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-control); background: var(--surface-card); color: var(--text-primary); }
.registration-items { display: grid; gap: 12px; margin: 16px 0; }
.registration-policy-options { display: grid; gap: 12px; margin: 16px 0; }
.registration-item { padding: 14px; border: 1px solid var(--border-control); border-radius: var(--radius-card); }
.registration-item-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.registration-progress { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--state-active); }
.registration-progress > span { color: var(--text-secondary); font-size: var(--type-label); }
.registration-state { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 10px 0; color: var(--text-secondary); }
.registration-state > .material-icons { font-size: 20px; }
.registration-state > span:last-child { flex-basis: 100%; font-size: var(--type-label); }
.registration-item.is-complete { border-color: var(--tone-success); background: color-mix(in srgb, var(--tone-success) 6%, var(--surface-card)); }
.registration-item.is-complete .registration-state > :is(strong, .material-icons) { color: var(--tone-success-text); }
.registration-item.is-required-missing { border-color: var(--tone-warning); }
.registration-item.is-required-missing .registration-state > :is(strong, .material-icons) { color: var(--tone-warning-text); }
.registration-item.is-optional-missing .registration-state > strong { color: var(--text-primary); }
.registration-item .btn { max-width: 100%; white-space: normal; }
.registration-item .btn { margin-top: 8px; }
.registration-badge { padding: 2px 8px; border: 1px solid var(--border-control); border-radius: 99px; font-size: 12px; }
.registration-badge.is-required { color: var(--blurple); border-color: var(--blurple); }
@media (max-width: 720px) { .registration-banner { flex-wrap: wrap; } .registration-item .btn { width: 100%; } }
.web-invite-launcher { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; min-width: 44px; padding: 8px 12px; color: var(--text-primary); background: var(--surface-card); border: 1px solid var(--border-control); border-radius: var(--radius-control); font: inherit; white-space: nowrap; cursor: pointer; }
.web-invite-launcher:hover { background: var(--state-active); border-color: var(--blurple); }
.web-invite-launcher:focus-visible { outline: 3px solid var(--blurple); outline-offset: 2px; }
@media (max-width: 1024px) { .web-invite-label { display: none; } .web-invite-launcher { padding: 8px; } }
