@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   CSS Custom Properties (Design Tokens)
   ============================================================ */
:root {
  /* Brand Colors */
  --primary:        #1d6fa4;
  --primary-dark:   #155a87;
  --primary-light:  #e8f4fd;
  --accent:         #2ab758;
  --accent-dark:    #229849;
  --danger:         #e53e3e;
  --danger-dark:    #c53030;
  --warning:        #d97706;
  --warning-bg:     #fef3c7;
  --info:           #2563eb;

  /* Backgrounds */
  --bg:             #f4f5f7;
  --bg-card:        #ffffff;
  --bg-hover:       #ebecf0;
  --bg-active:      #deebff;

  /* Text */
  --text:           #172b4d;
  --text-sub:       #5e6c84;
  --text-muted:     #8993a4;
  --text-on-dark:   #ffffff;

  /* Header / Sidebar */
  --header-bg:      #172b4d;
  --header-h:       52px;
  --sidebar-w:      240px;
  --sidebar-bg:     #f4f5f7;
  --sidebar-border: #dfe1e6;
  --sidebar-active: #deebff;
  --sidebar-active-text: #0052cc;

  /* Borders */
  --border:         #dfe1e6;
  --border-dark:    #c1c7d0;

  /* Shadows */
  --shadow-xs:      0 1px 2px rgba(9,30,66,.07);
  --shadow-sm:      0 1px 3px rgba(9,30,66,.12);
  --shadow-md:      0 4px 12px rgba(9,30,66,.15);
  --shadow-lg:      0 8px 24px rgba(9,30,66,.18);

  /* Radii */
  --r-sm:           3px;
  --r-md:           6px;
  --r-lg:           10px;
  --r-xl:           14px;

  /* Typography */
  --font:           'Inter', 'Noto Sans JP', system-ui, sans-serif;

  /* Transitions */
  --tr:             0.15s ease;

  /* Status Colors */
  --s-todo:         #5e6c84;
  --s-todo-bg:      #ebecf0;
  --s-wip:          #0052cc;
  --s-wip-bg:       #deebff;
  --s-resolved:     #008060;
  --s-resolved-bg:  #e3fcef;
  --s-done:         #2ab758;
  --s-done-bg:      #e3fcef;
  --s-blocked:      #de350b;
  --s-blocked-bg:   #ffebe6;

  /* Priority Colors */
  --p-highest:      #de350b;
  --p-high:         #f39c12;
  --p-normal:       #0052cc;
  --p-low:          #5e6c84;
  --p-lowest:       #8993a4;

  /* Issue Type Colors */
  --t-bug:          #e53e3e;
  --t-task:         #0052cc;
  --t-request:      #8a2be2;
  --t-other:        #5e6c84;
}

/* ============================================================
   Reset / Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 { margin: 0; line-height: 1.3; }

/* ============================================================
   Utilities
   ============================================================ */
.hidden       { display: none !important; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.gap-4        { gap: 4px; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.w-full       { width: 100%; }
.mt-auto      { margin-top: auto; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   Auth Layout
   ============================================================ */
#auth-layout {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #101d36 0%, #1d3461 50%, #172b4d 100%);
  padding: 20px;
}

.auth-card {
  background: #fff;
  border-radius: var(--r-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.auth-card-header {
  background: linear-gradient(135deg, var(--header-bg) 0%, #1d3b70 100%);
  padding: 32px 36px 24px;
  text-align: center;
}

.auth-logo {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.auth-logo span { color: #5bc4ff; }

.auth-tagline {
  color: rgba(255,255,255,.65);
  font-size: 13px;
  margin-top: 4px;
}

.auth-card-body { padding: 28px 36px 32px; }

.auth-switch {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-sub);
  text-align: center;
}

/* ============================================================
   App Layout (Sidebar + Header + Main)
   ============================================================ */
#app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  transition: width 0.22s ease, transform var(--tr);
  z-index: 100;
  overflow: hidden;
}

/* Desktop collapsed state */
#app-layout.sidebar-collapsed #sidebar {
  width: 0;
  border-right: none;
}

/* Sidebar toggle button (desktop only) */
.sidebar-toggle {
  position: relative;
  z-index: 101;
  flex-shrink: 0;
  width: 16px;
  background: var(--bg-card);
  border: none;
  border-right: 1px solid var(--sidebar-border);
  border-left: 1px solid var(--sidebar-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 0;
  transition: background var(--tr), color var(--tr), width 0.22s ease;
  align-self: stretch;
}
.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--primary);
}
.sidebar-toggle svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex-shrink: 0;
  transition: transform 0.22s ease;
}
#app-layout.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-header {
  padding: 0 12px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: var(--header-bg);
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo span { color: #5bc4ff; }

.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-sm);
}

.sidebar-close:hover { color: #fff; }

.sidebar-close svg { width: 18px; height: 18px; fill: currentColor; display: block; }

.sidebar-search {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.sidebar-nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  padding: 10px 14px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-nav-section-title button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  transition: background var(--tr), color var(--tr);
}

.sidebar-nav-section-title button:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-nav-section-title button svg { width: 16px; height: 16px; fill: currentColor; }

.project-list { list-style: none; padding: 0; margin: 0; }

.project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  border-radius: 0;
  transition: background var(--tr);
  position: relative;
}

.project-item:hover { background: var(--bg-hover); }

.project-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
  font-weight: 500;
}

.project-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--sidebar-active-text);
  border-radius: 0 2px 2px 0;
}

.project-badge {
  font-size: 10px;
  font-weight: 600;
  background: rgba(0,82,204,.12);
  color: var(--sidebar-active-text);
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

.project-item.active .project-badge {
  background: rgba(0,82,204,.2);
}

.project-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.project-item .del-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 3px;
}

.project-item:hover .del-btn { display: flex; }
.project-item .del-btn:hover { color: var(--danger); }
.project-item .del-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* My Tasks in sidebar */
.sidebar-my-tasks {
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* Accordion header button */
.my-tasks-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--tr);
  flex-shrink: 0;
}
.my-tasks-header:hover { background: var(--bg-hover); }

.my-tasks-count {
  font-size: 10px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 2px;
}
.my-tasks-count:empty { display: none; }

.my-tasks-chevron {
  width: 14px; height: 14px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform .2s ease;
}
.my-tasks-header.collapsed .my-tasks-chevron { transform: rotate(-90deg); }

/* Body: scrollable */
.my-tasks-body {
  overflow: hidden;
  flex-shrink: 0;
}

.my-tasks-list {
  padding: 2px 0;
  max-height: 200px;
  overflow-y: auto;
}

.my-tasks-more-list { max-height: 160px; overflow-y: auto; }

.my-task-empty {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.my-task-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--tr);
  color: var(--text);
}
.my-task-item:hover { background: var(--bg-hover); }

.my-task-proj {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--bg-lighter);
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.my-task-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.my-task-due {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}
.my-task-due.overdue { color: var(--danger); font-weight: 600; }
.my-task-due.today   { color: #e07000; font-weight: 600; }
.my-task-due.soon    { color: #e07000; }

.my-task-toggle {
  padding: 4px 12px;
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
  list-style: none;
}
.my-task-toggle:hover { text-decoration: underline; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
}

.sidebar-overlay.active { display: block; }

/* ---- Header ---- */
#header {
  height: var(--header-h);
  background: var(--header-bg);
  color: var(--text-on-dark);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 80;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

.menu-toggle:hover { color: #fff; background: rgba(255,255,255,.1); }
.menu-toggle svg { width: 20px; height: 20px; fill: currentColor; display: block; }

.header-project-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-icon-btn {
  background: rgba(255,255,255,.1);
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--tr), color var(--tr);
  position: relative;
}

.header-icon-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.header-icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

.header-icon-btn .badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: #ff5630;
  border-radius: 50%;
  border: 2px solid var(--header-bg);
}

.header-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.1);
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--tr);
}

.header-user-btn:hover { background: rgba(255,255,255,.2); }

.header-user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ---- Main Wrapper ---- */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

#main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---- View Tabs & Toolbar ---- */
.view-tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.view-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  transition: color var(--tr), border-color var(--tr);
  white-space: nowrap;
}

.view-tab-btn svg { width: 15px; height: 15px; fill: currentColor; }
.view-tab-btn:hover { color: var(--text); }

.view-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.view-tab-settings-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-sub);
  transition: color var(--tr), background var(--tr);
  flex-shrink: 0;
}
.view-tab-settings-btn:hover { color: var(--text); background: var(--bg-hover); }
.view-tab-settings-btn svg { width: 18px; height: 18px; fill: currentColor; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar-left  { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--tr);
}

.filter-select:focus { outline: none; border-color: var(--primary); }

/* ============================================================
   Kanban Board
   ============================================================ */
#kanban-view {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  flex: 1;
  overflow-x: auto;
  align-items: flex-start;
}

.kanban-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 272px;
  min-width: 272px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
}

.kanban-col-header {
  padding: 10px 12px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-top: 3px solid var(--col-accent, #5e6c84);
  background: rgba(0,0,0,.02);
}

.kanban-col-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kanban-col[data-status="todo"]        .kanban-col-dot { background: var(--s-todo); }
.kanban-col[data-status="in_progress"] .kanban-col-dot { background: var(--s-wip); }
.kanban-col[data-status="resolved"]    .kanban-col-dot { background: var(--s-resolved); }
.kanban-col[data-status="done"]        .kanban-col-dot { background: var(--s-done); }
.kanban-col[data-status="blocked"]     .kanban-col-dot { background: var(--s-blocked); }

.kanban-col-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.kanban-col-count {
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,.12);
  color: var(--text-sub);
  padding: 1px 7px;
  border-radius: 10px;
}

.col-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0 4px 0 0;
  user-select: none;
}
.col-drag-handle:active { cursor: grabbing; }

.col-dragging { opacity: 0.4; }
.col-drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }

.kanban-add-col {
  background: transparent;
  border: 2px dashed var(--text-muted);
  border-radius: var(--r-lg);
  width: 200px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 16px;
  transition: border-color .15s, color .15s;
  align-self: flex-start;
  min-height: 80px;
}
.kanban-add-col:hover { border-color: var(--primary); color: var(--primary); }
.kanban-add-col-icon { font-size: 24px; line-height: 1; }

.kanban-col-body {
  flex: 1;
  padding: 6px 8px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 60px;
}

/* ── Kanban Card ── */
.issue-card {
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 10px 12px 9px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04);
  cursor: pointer;
  border-left: 3px solid #d0d3db;
  transition: box-shadow var(--tr), transform var(--tr);
  position: relative;
}

/* Priority border */
.issue-card[data-priority="highest"] { border-left-color: var(--p-highest); }
.issue-card[data-priority="high"]    { border-left-color: var(--p-high); }
.issue-card[data-priority="normal"]  { border-left-color: var(--p-normal); }
.issue-card[data-priority="low"]     { border-left-color: var(--p-low); }
.issue-card[data-priority="lowest"]  { border-left-color: var(--p-lowest); }

.issue-card:hover {
  box-shadow: 0 4px 10px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.06);
  transform: translateY(-2px);
}
.issue-card.dragging { opacity: .4; transform: rotate(1.5deg) scale(.98); }

/* Card header: type badge + key */
.card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.card-key {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Type badge */
.card-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  flex-shrink: 0;
  letter-spacing: .02em;
}
.card-type-bug     { background: #ffe8e8; color: var(--t-bug); }
.card-type-task    { background: #e8f0ff; color: var(--t-task); }
.card-type-request { background: #f0e8ff; color: var(--t-request); }
.card-type-other   { background: #f0f0f4; color: var(--t-other); }

/* Title: max 2 lines */
.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 9px;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 22px;
}

.card-footer-left {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.card-footer-right { flex-shrink: 0; }

/* Due date */
.card-due {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.card-due--overdue {
  color: var(--danger);
  font-weight: 600;
  animation: card-pulse 1.8s ease-in-out infinite;
}
.card-due--today { color: #e07000; font-weight: 600; }
.card-due--soon  { color: #e07000; }

@keyframes card-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* Assignee avatar */
.card-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.card-avatar--none {
  background: #e0e2e8;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
}
.card-avatar--img {
  object-fit: cover;
  background: none;
}

/* ============================================================
   Avatar / Icon upload
   ============================================================ */
.avatar-upload-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-sub, #f5f6f8);
  border-radius: var(--r-md, 8px);
}
.avatar-preview-wrap {
  position: relative;
  flex-shrink: 0;
}
.avatar-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-preview--project {
  border-radius: 12px;
}
.avatar-upload-btn {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: background .15s;
}
.avatar-upload-btn:hover { background: var(--primary-dark, #1a5fc7); }
.avatar-upload-btn svg {
  width: 13px;
  height: 13px;
  fill: #fff;
  pointer-events: none;
}
.avatar-upload-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.btn-xs {
  font-size: 11px;
  padding: 2px 8px;
  line-height: 1.5;
}

/* Project icon in sidebar */
.project-item-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 6px;
  line-height: 1;
}
.project-item-icon--img {
  object-fit: cover;
  background: transparent;
}

/* ============================================================
   Issue List View
   ============================================================ */
#list-view {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}

.issue-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.issue-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background var(--tr);
}

.issue-table th:hover { background: var(--bg-hover); }
.issue-table th.sorted { color: var(--primary); }

.issue-table td {
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f4;
  vertical-align: middle;
}

.issue-table tr:last-child td { border-bottom: none; }

.issue-table tbody tr {
  cursor: pointer;
  transition: background var(--tr);
}

.issue-table tbody tr:hover { background: #f8f9fb; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

.status-todo     { background: var(--s-todo-bg); color: var(--s-todo); }
.status-in_progress { background: var(--s-wip-bg); color: var(--s-wip); }
.status-resolved { background: var(--s-resolved-bg); color: var(--s-resolved); }
.status-done     { background: var(--s-done-bg); color: var(--s-done); }
.status-blocked  { background: var(--s-blocked-bg); color: var(--s-blocked); }

.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.pri-highest { background: #ffe8e8; color: var(--p-highest); }
.pri-high    { background: #fef3c7; color: var(--warning); }
.pri-normal  { background: #e8f0ff; color: var(--p-normal); }
.pri-low     { background: #f0f4f8; color: var(--p-low); }
.pri-lowest  { background: #f4f5f7; color: var(--p-lowest); }

/* ============================================================
   Gantt Chart
   ============================================================ */
#gantt-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 16px;
}

.gantt-wrapper {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gantt-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fb;
  flex-shrink: 0;
}

.gantt-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gantt-month-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  min-width: 108px;
  text-align: center;
}

/* ── Scrollable body ── */
.gantt-body {
  flex: 1;
  overflow: auto;
}

/* ── Table container ── */
.gantt-table {
  display: inline-block;
  min-width: 100%;
  position: relative;
}

/* ── Row ── */
.gantt-row {
  display: flex;
  height: 40px;
  border-bottom: 1px solid #f0f0f4;
  align-items: stretch;
  background: var(--bg-card);
}

.gantt-row.gantt-hdr {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 50px;
  border-bottom: 2px solid var(--border);
  background: #f8f9fb;
}

.gantt-row:not(.gantt-hdr):hover { background: #f8f9fb; }
.gantt-row:not(.gantt-hdr):hover .gantt-info-cell { background: #f8f9fb; }

/* ── Info (left sticky) column ── */
.gantt-info-cell {
  width: 240px;
  min-width: 240px;
  flex-shrink: 0;
  position: sticky;
  left: 0;
  z-index: 6;
  background: var(--bg-card);
  border-right: 2px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  overflow: hidden;
}

.gantt-hdr .gantt-info-cell {
  z-index: 11;
  background: #f8f9fb;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.gantt-issue-title {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
}
.gantt-issue-title:hover { text-decoration: underline; }

/* ── Days wrap ── */
.gantt-days-wrap {
  display: flex;
  position: relative;
  align-items: stretch;
}

/* ── Day header cells ── */
.gantt-day-hdr {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-right: 1px solid #ebebef;
  background: #f8f9fb;
  color: var(--text-muted);
}

.gantt-day-hdr.is-weekend { background: #eff1f6; color: #a0aec0; }
.gantt-day-hdr.is-today   { background: var(--primary-light) !important; color: var(--primary) !important; }

.gantt-day-num { font-weight: 700; font-size: 11px; line-height: 1; }
.gantt-day-dow { font-size: 9px; line-height: 1; opacity: .75; }
.gantt-day-hdr.is-weekend .gantt-day-dow { color: var(--s-blocked); opacity: 1; }
.gantt-day-hdr.is-today   .gantt-day-num { font-size: 12px; }

/* ── Day cells (body rows) ── */
.gantt-day-cell {
  flex-shrink: 0;
  border-right: 1px solid #f2f2f6;
  position: relative;
  height: 100%;
}

.gantt-day-cell.is-weekend { background: rgba(0,0,0,.018); }
.gantt-day-cell.is-today   { background: rgba(29,111,164,.07); }

/* Today vertical hairline */
.gantt-day-cell.is-today::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: rgba(29,111,164,.28);
  pointer-events: none;
}

/* ── Gantt Bar ── */
.gantt-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 3px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  transition: filter .15s, box-shadow .15s;
  min-width: 8px;
  z-index: 2;
}

.gantt-bar:hover {
  filter: brightness(1.09);
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
}

.gantt-bar-label {
  font-size: 11px;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.gantt-bar-arrow {
  font-size: 8px;
  color: rgba(255,255,255,.8);
  flex-shrink: 0;
}

/* ── Drag cursor ── */
.gantt-bar { cursor: grab; }
.gantt-bar.is-dragging { cursor: grabbing !important; opacity: .82; z-index: 20; }
.gantt-days-wrap { user-select: none; }

/* ── Resize handles ── */
.gantt-resize-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 7px;
  cursor: ew-resize;
  z-index: 3;
  border-radius: inherit;
  flex-shrink: 0;
}
.gantt-resize-handle--left  { left: 0; }
.gantt-resize-handle--right { right: 0; }
.gantt-resize-handle:hover  { background: rgba(255,255,255,.28); }

/* ============================================================
   Wiki View
   ============================================================ */
/* ============================================================
   Wiki View — Backlog style: content(left) | page-list(right)
   ============================================================ */
#wiki-view {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: #fff;
}

/* ── Left: main content ── */
.wiki-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* View mode */
.wiki-view-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wiki-view-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 28px 40px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.wiki-view-title {
  flex: 1;
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}

.wiki-view-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding-top: 4px;
}

.wiki-view-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 40px 48px;
}

/* Edit mode */
.wiki-editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wiki-editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.wiki-title-input {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  border: none;
  border-bottom: 2px solid var(--border);
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 4px 2px;
  transition: border-color var(--tr);
}
.wiki-title-input:focus { border-bottom-color: var(--primary); }

.wiki-editor-actions { display: flex; gap: 6px; flex-shrink: 0; }

.wiki-editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wiki-quill-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wiki-quill-wrap .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  order: 1;
}
.wiki-quill-wrap .ql-container {
  border: none;
  flex: 1;
  overflow-y: auto;
  order: 2;
}
.wiki-quill-wrap .ql-editor {
  height: 100%;
  min-height: 300px;
  font-size: 14px;
  line-height: 1.8;
  padding: 24px 40px;
}

/* Empty state */
.wiki-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* ── Right: page list sidebar ── */
.wiki-nav {
  width: 220px;
  min-width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border);
  background: var(--bg);
}

.wiki-nav-header {
  padding: 14px 14px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.wiki-nav-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wiki-page-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 12px;
  list-style: none;
  margin: 0;
}

.wiki-page-item {
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  border-right: 3px solid transparent;
  transition: background var(--tr), border-color var(--tr);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wiki-page-item:hover  { background: var(--bg-hover); }
.wiki-page-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-right-color: var(--primary);
}

/* ============================================================
   Rich Editor (Quill)
   ============================================================ */
.rich-editor-wrap {
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: #fafbfc;
  transition: border-color var(--tr), outline var(--tr);
  overflow: hidden;
  display: flex;
  flex-direction: column;   /* 通常順 + orderで並び替え */
}
.rich-editor-wrap:focus-within { border-color: var(--primary); background: #fff; }

/* ツールバーをorderで下に移動（column-reverseによるスクロール起点のズレを防ぐ） */
.rich-editor-wrap .ql-toolbar  { order: 2; }
.rich-editor-wrap .ql-container { order: 1; }

/* Quill toolbar */
.rich-editor-wrap .ql-toolbar {
  border: none;
  border-top: 1px solid var(--border);
  background: #f8f9fb;
  padding: 5px 8px;
  font-family: inherit;
  flex-shrink: 0;
}
.rich-editor-wrap .ql-toolbar .ql-formats { margin-right: 8px; }
.rich-editor-wrap .ql-toolbar button { padding: 3px 4px; position: relative; }
.rich-editor-wrap .ql-toolbar button:hover,
.rich-editor-wrap .ql-toolbar button.ql-active { color: var(--primary); }
.rich-editor-wrap .ql-toolbar .ql-stroke { stroke: currentColor; }
.rich-editor-wrap .ql-toolbar .ql-fill   { fill:   currentColor; }
.rich-editor-wrap .ql-toolbar .ql-picker-label { border-color: var(--border); }

/* ツールバーボタンのツールチップ（title属性をCSSで素早く表示） */
.rich-editor-wrap .ql-toolbar button[title] {
  position: relative;
}
.rich-editor-wrap .ql-toolbar button[title]::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  font-size: 11px;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease 0.4s;   /* 0.4s遅延後にフワッと表示 */
  z-index: 9999;
}
.rich-editor-wrap .ql-toolbar button[title]:hover::after {
  opacity: 1;
}

/* Quill content area */
.rich-editor-wrap .ql-container {
  border: none;
  font-family: inherit;
  font-size: 14px;
  flex: 1;
  min-height: 0;
}
.rich-editor-wrap .ql-editor {
  height: 130px;
  overflow-y: auto;
  padding: 10px 12px;
  line-height: 1.6;
  position: relative;
}
.rich-editor-wrap .ql-editor.ql-blank::before {
  color: var(--text-muted);
  font-style: normal;
  font-size: 13px;
}

/* 詳細モーダルの説明欄は少し高く */
#detail-desc-editor .ql-editor { height: 150px; }

/* コメントエディタ */
#comment-editor .ql-editor { height: 100px; }

/* ファイルドロップ時のハイライト（ツールバー含む全体） */
.rich-editor-wrap.file-drag-over {
  border-color: var(--primary);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}
.rich-editor-wrap.file-drag-over .ql-editor,
.rich-editor-wrap.file-drag-over .ql-toolbar {
  background: var(--primary-light);
}
.rich-editor-wrap.file-drag-over .ql-editor::before {
  content: 'ここにドロップ' !important;   /* ql-blank::before を上書き */
  display: flex !important;
  align-items: center;
  justify-content: center;
  position: absolute;
  inset: 0;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  font-style: normal;
  pointer-events: none;
  left: 0 !important;
}

/* 画像は最大幅いっぱいに */
.rich-editor-wrap .ql-editor img {
  max-width: 100%;
  border-radius: var(--r-sm);
  cursor: pointer;
}

/* コードブロック */
.rich-editor-wrap .ql-editor pre.ql-syntax {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 13px;
  overflow-x: auto;
}

/* コメント添付プレビューゾーン */
.comment-attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.comment-attach-preview:empty { display: none; }

/* 添付チップ */
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg-main);
  max-width: 240px;
}
.attach-chip--loading {
  color: var(--text-muted);
  animation: pulse 1.2s ease-in-out infinite;
}
.attach-chip--done { border-color: var(--primary); background: var(--primary-light); }
.attach-chip--error { border-color: var(--danger); color: var(--danger); }
.attach-chip-icon { flex-shrink: 0; }
.attach-chip-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--primary);
  text-decoration: none;
}
.attach-chip-name:hover { text-decoration: underline; }
.attach-chip-status { color: var(--text-muted); font-size: 11px; }
.attach-chip-remove {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  padding: 0 2px;
  line-height: 1;
}
.attach-chip-remove:hover { color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* コメント本文内の添付ファイルブロック（テキストと分離して表示） */
.comment-file-block {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.comment-file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px 3px 8px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comment-file-link:hover { background: var(--primary); color: #fff; }

/* ── Activity Timeline ── */
.activity-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-left: 4px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 5px 0;
  position: relative;
}

/* 縦線 */
.activity-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 18px;
  bottom: -5px;
  width: 1px;
  background: var(--border);
}

.activity-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg-card);
  flex-shrink: 0;
  margin-top: 3px;
  outline: 2px solid var(--border);
}
.activity-dot--create { background: var(--accent); outline-color: var(--accent); }
.activity-dot--status { background: var(--primary); outline-color: var(--primary); }

.activity-body {
  flex: 1;
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
}

.activity-actor { font-weight: 600; color: var(--text); }
.activity-field { color: var(--text); font-weight: 500; }

.activity-from {
  background: var(--bg-hover);
  color: var(--text-sub);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 11px;
  text-decoration: line-through;
}

.activity-to {
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
}

.activity-time {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.activity-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 0;
}

.activity-more { display: none; }

.activity-toggle {
  display: block;
  margin-top: 4px;
  padding: 3px 0;
  font-size: 11px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.activity-toggle:hover { text-decoration: underline; }

/* コメント表示用 */
.comment-body-display { line-height: 1.6; }
.comment-body-display img { max-width: 100%; border-radius: var(--r-sm); }
.comment-body-display p { margin: 0 0 6px; }
.comment-body-display pre { background: #1e1e2e; color: #cdd6f4; padding: 8px 12px; border-radius: var(--r-sm); overflow-x: auto; font-size: 12px; }
.comment-body-display a { color: var(--primary); text-decoration: underline; }
.comment-body-display a:hover { opacity: 0.8; }

/* Comment item layout */
.comment-item {
  background: var(--bg-main);
  padding: 10px 12px;
  border-radius: var(--r-sm, 6px);
  font-size: 13px;
}
.comment-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.comment-author {
  color: var(--text-main);
}
.comment-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.comment-date {
  font-size: 11px;
  color: var(--text-muted);
}
.comment-action-btn {
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 1px 4px;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1.4;
}
.comment-action-btn:hover { background: var(--bg-hover, rgba(0,0,0,.06)); color: var(--text-main); }
.comment-action-btn--danger:hover { color: var(--danger); }

/* Inline edit area */
.comment-edit-area {
  width: 100%;
  min-height: 72px;
  margin-top: 6px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.6;
}
.comment-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

/* Ctrl+Enter ヒント */
.comment-hint {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* @メンションボタン */
.comment-mention-trigger {
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
}

/* ============================================================
   @Mention Dropdown
   ============================================================ */
.mention-dropdown {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 10000;
  min-width: 200px;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.mention-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-main);
  transition: background var(--tr);
}
.mention-dropdown-item:hover,
.mention-dropdown-item.is-active {
  background: var(--primary-light, #eef2ff);
}
.mention-avatar-sm {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rich-editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fb;
}

.editor-toolbar-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-sub);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  transition: background var(--tr), color var(--tr);
  display: flex;
  align-items: center;
  gap: 4px;
}

.editor-toolbar-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }
.editor-toolbar-btn svg { width: 14px; height: 14px; fill: currentColor; }

.editor-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #f0f1f4;
}

.editor-tab {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  transition: color var(--tr);
}

.editor-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.editor-textarea {
  width: 100%;
  min-height: 120px;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 13px;
  background: transparent;
  resize: vertical;
  color: var(--text);
  line-height: 1.6;
}

.editor-preview {
  min-height: 120px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

/* Shortcode suggestions */
.shortcode-suggestions {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
}

.shortcode-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--tr);
  font-size: 13px;
}

.shortcode-item:hover, .shortcode-item.selected { background: var(--primary-light); }

.shortcode-item code {
  font-size: 11px;
  background: #ebecf0;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  color: var(--text-sub);
  flex-shrink: 0;
}

/* Rendered shortcodes in preview */
.sc-mention { color: var(--primary); font-weight: 600; }
.sc-issue-link { color: var(--primary); border-bottom: 1px dashed; cursor: pointer; }
.sc-code {
  background: #1e2330;
  color: #e8eaf6;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  overflow-x: auto;
  display: block;
  margin: 8px 0;
}
.sc-quote {
  border-left: 4px solid var(--border-dark);
  background: #f8f9fb;
  padding: 8px 14px;
  margin: 8px 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-sub);
  font-style: italic;
}
.sc-source {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}
.sc-date {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(29,111,164,.3);
  border-radius: var(--r-sm);
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
}

/* Image upload area */
/* 添付バー（コンパクト表示） */
.attach-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-radius: var(--r-sm);
  transition: background var(--tr);
}
.attach-bar.drag-over {
  background: var(--primary-light);
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}
.attach-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.attach-drop-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* 旧ドロップゾーン（後方互換） */
.img-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  padding: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--tr), background var(--tr);
}
.img-drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* ============================================================
   Notification Panel
   ============================================================ */
.notif-panel {
  position: fixed;
  top: var(--header-h);
  right: 0;
  width: 340px;
  max-height: calc(100vh - var(--header-h));
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.notif-panel.open { transform: translateX(0); }

.notif-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notif-panel-header h3 { font-size: 14px; font-weight: 600; }

.notif-list { flex: 1; overflow-y: auto; }

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f1f4;
  cursor: pointer;
  transition: background var(--tr);
}

.notif-item:hover { background: #f8f9fb; }
.notif-item.unread { background: var(--primary-light); }

.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 5px;
}

.notif-item.unread .notif-dot { background: var(--primary); }
.notif-item:not(.unread) .notif-dot { background: transparent; }

.notif-body { flex: 1; min-width: 0; }
.notif-text { font-size: 12px; color: var(--text); line-height: 1.5; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9,30,66,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { transform: translateY(-12px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 600; flex: 1; }
.modal-subtitle { font-size: 12px; color: var(--text-muted); }

.modal-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--tr), color var(--tr);
  flex-shrink: 0;
}

.modal-close-btn:hover { background: var(--bg-hover); color: var(--text); }
.modal-close-btn svg { width: 18px; height: 18px; fill: currentColor; }

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

.modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-footer .spacer { flex: 1; }

/* List View Badges */
.issue-type-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.issue-type-bug     { background: #ffe0e0; color: var(--t-bug); }
.issue-type-task    { background: #e0ecff; color: var(--t-task); }
.issue-type-request { background: #f0e0ff; color: var(--t-request); }
.issue-type-other   { background: var(--bg-hover); color: var(--text-sub); }

.kanban-status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-sub);
}

/* Issue Detail Modal Layout */
.issue-detail-layout {
  display: flex;
  gap: 20px;
  min-height: 0;
}

.issue-detail-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.issue-detail-sidebar {
  width: 210px;
  min-width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.detail-meta-item { display: flex; flex-direction: column; gap: 3px; }

/* 2-column row for 種別+優先度 / 開始日+期限日 */
.detail-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Compact read-only info block (作成者/日時) */
.detail-meta-info {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.detail-meta-info-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.detail-meta-info-row span:last-child {
  font-size: 11px;
  color: var(--text-sub);
}

.detail-meta-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ============================================================
   Forms & Inputs
   ============================================================ */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  border: 2px solid var(--border);
  border-radius: var(--r-sm);
  background: #fafbfc;
  color: var(--text);
  transition: border-color var(--tr), background var(--tr);
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%235e6c84' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
  padding-right: 30px;
}

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.error-message {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

.error-message:empty { display: none; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--tr), border-color var(--tr), color var(--tr), box-shadow var(--tr);
  white-space: nowrap;
  line-height: 1.4;
}

.btn svg { width: 15px; height: 15px; fill: currentColor; flex-shrink: 0; }

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

.btn-primary    { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success    { background: var(--accent); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--accent-dark); }

.btn-danger     { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-dark); }

.btn-secondary  { background: rgba(9,30,66,.06); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: rgba(9,30,66,.1); }

.btn-ghost      { background: transparent; color: var(--text-sub); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }

.btn-outline-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-outline-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; }

/* ============================================================
   Attachments
   ============================================================ */
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f0f1f4;
  border-radius: var(--r-sm);
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--tr);
  max-width: 200px;
}

.attachment-item:hover { background: var(--bg-hover); }

.attachment-item img {
  width: 40px; height: 30px;
  object-fit: cover;
  border-radius: 2px;
}

.attachment-item svg { width: 14px; height: 14px; fill: var(--text-muted); flex-shrink: 0; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ============================================================
   Comment Section
   ============================================================ */
.comment-timeline { display: flex; flex-direction: column; gap: 14px; }

.comment-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.comment-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.comment-bubble {
  flex: 1;
  background: #f4f5f7;
  border-radius: 0 var(--r-md) var(--r-md) var(--r-md);
  padding: 10px 14px;
  min-width: 0;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.comment-author { font-size: 13px; font-weight: 600; }
.comment-time   { font-size: 11px; color: var(--text-muted); }

.comment-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--tr);
}

.comment-item:hover .comment-actions { opacity: 1; }

.comment-body-display {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}

/* @メンションのハイライト */
.mention-tag {
  color: #1a73e8;
  font-weight: 600;
}

/* アバター画像（コメント・カンバン共通） */
.comment-avatar--img {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
  display: block;
}

/* URLから飛んできたコメントをハイライト */
.comment-highlight {
  animation: comment-flash 2.5s ease-out forwards;
}
@keyframes comment-flash {
  0%   { background: #fff3cd; }
  70%  { background: #fff3cd; }
  100% { background: transparent; }
}

/* ============================================================
   Comment Input Card
   ============================================================ */
.comment-input-card {
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  background: #fafbfc;
  transition: border-color var(--tr);
  overflow: hidden;
}
.comment-input-card:focus-within {
  border-color: var(--primary);
  background: #fff;
}
/* カード内のQuillはボーダー・背景を除去 */
.comment-input-card .rich-editor-wrap {
  border: none;
  border-radius: 0;
  background: transparent;
}
.comment-input-card .rich-editor-wrap:focus-within {
  border: none;
  background: transparent;
}
.comment-input-card .ql-toolbar {
  border-top: 1px solid var(--border) !important;
  background: #f4f5f7 !important;
}

.comment-input-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: #f4f5f7;
}

.comment-input-icon-btn {
  padding: 4px 6px;
  color: var(--text-muted);
}

/* Subtask list */
.subtask-list { display: flex; flex-direction: column; gap: 4px; }

.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f8f9fb;
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background var(--tr);
}

.subtask-item:hover { background: var(--bg-hover); }

.subtask-checkbox {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* ============================================================
   Pollings / Real-time indicator
   ============================================================ */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--accent);
  padding: 2px 7px;
  background: rgba(42,183,88,.1);
  border-radius: 10px;
}

.sync-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

/* ============================================================
   Tables (Member list, settings)
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: #f8f9fb;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f1f4;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

/* ============================================================
   Settings / Tabs
   ============================================================ */
.settings-tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.settings-tab-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--tr);
}

.settings-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-tab-btn:hover:not(.active) { color: var(--text); }

.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* ============================================================
   Misc / Toast
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e2330;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: 350px;
  animation: toast-in 0.25s ease;
  border-left: 4px solid var(--accent);
}

.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }

.toast svg { width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }

@keyframes toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  gap: 10px;
  text-align: center;
}

.empty-state svg { width: 48px; height: 48px; fill: var(--border-dark); }
.empty-state p { font-size: 14px; margin: 0; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
  }
  #sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay.active { display: block; }
  .sidebar-close { display: flex; }
  .menu-toggle  { display: flex; }
  .sidebar-toggle { display: none; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  #kanban-view { flex-wrap: wrap; overflow-x: hidden; }
  .kanban-col  { width: 100%; min-width: 100%; max-height: none; }

  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }

  .issue-detail-layout { flex-direction: column; }
  .issue-detail-sidebar { width: 100%; min-width: 0; overflow-y: visible; }

  .modal-box { border-radius: var(--r-md); }

  #wiki-view { flex-direction: column-reverse; }
  .wiki-nav { width: 100%; min-width: 0; border-left: none; border-bottom: 1px solid var(--border); max-height: 160px; }
  .wiki-view-header, .wiki-view-body, .wiki-quill-wrap .ql-editor { padding-left: 16px; padding-right: 16px; }
  .wiki-view-header { padding-top: 16px; }

  .notif-panel { width: 100%; right: 0; }
}