/* Linear ローカルクローン
   カラー・タイポは linear.app の実 CSS 変数から採取した値に合わせている
   （--sidebar-width: 244px / Inter / font-size-regular .9375rem など）。 */

:root {
  --font-regular: "Inter Variable", "SF Pro Display", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-mono: "Berkeley Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --font-size-micro: 0.6875rem;
  --font-size-mini: 0.75rem;
  --font-size-small: 0.8125rem;
  --font-size-regular: 0.9375rem;
  --font-size-large: 1.125rem;
  --font-size-title3: 1.25rem;
  --font-size-title2: 1.5rem;
  --font-size-title1: 2.25rem;

  --fw-normal: 450;
  --fw-medium: 510;
  --fw-semibold: 590;
  --fw-bold: 680;

  --sidebar-width: 244px;
  --header-height: 48px;
  --row-height: 36px;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-round: 9999px;

  --speed-quick: 0.1s;
  --speed-regular: 0.25s;
  --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);

  --accent: #5e6ad2;
  --accent-hover: #6c78e0;
  --focus-ring: #5e69d1;

  --prio-urgent: #f2994a;
  --danger: #eb5757;
  --success: #4cb782;
}

:root,
[data-theme="dark"] {
  --bg-page: #060607;
  --bg-sidebar: #090909;
  --bg-content: #0f0f11;
  --bg-elevated: #18181a;
  --bg-overlay: #1c1c1f;
  --bg-hover: #1a1a1c;
  --bg-active: #232326;
  --bg-selected: #1f2023;
  --bg-input: #101011;

  --border: #1f1f21;
  --border-strong: #2c2c2e;
  --border-subtle: #18181a;

  --text-primary: #f7f8f8;
  --text-secondary: #d2d3d6;
  --text-tertiary: #8a8f98;
  --text-quaternary: #62666d;

  --shadow-popover: 0 3px 8px #0000003d, 0 2px 5px #00000038, 0 1px 1px #0000002e;
  --shadow-modal: 0 16px 70px #00000080, 0 4px 16px #00000059;
  --scrim: #00000099;
}

[data-theme="light"] {
  --bg-page: #ffffff;
  --bg-sidebar: #f4f5f8;
  --bg-content: #ffffff;
  --bg-elevated: #ffffff;
  --bg-overlay: #ffffff;
  --bg-hover: #f1f2f4;
  --bg-active: #e8e9ec;
  --bg-selected: #eef0f5;
  --bg-input: #ffffff;

  --border: #e6e6e8;
  --border-strong: #d8d9db;
  --border-subtle: #efeff1;

  --text-primary: #17181c;
  --text-secondary: #3c3f44;
  --text-tertiary: #6b6f76;
  --text-quaternary: #9598a1;

  --shadow-popover: 0 4px 12px #0000001a, 0 1px 2px #00000014;
  --shadow-modal: 0 16px 70px #00000029, 0 2px 8px #0000001f;
  --scrim: #1c1c1f33;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-regular);
  font-size: var(--font-size-regular);
  font-weight: var(--fw-normal);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  letter-spacing: -0.00666667em;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: #5e6ad24d;
}

:focus-visible {
  outline: 1px solid var(--focus-ring);
  outline-offset: 1px;
}

/* スクロールバー: Linear は細くて控えめ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: #ffffff1a;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #ffffff2e;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: #00000024;
}

/* --- レイアウト --------------------------------------------------------- */

.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.boot {
  margin: auto;
  color: var(--text-tertiary);
  font-size: var(--font-size-small);
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  height: 100%;
  user-select: none;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  overflow: hidden;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 8px 8px 8px 0;
  display: flex;
}

.content {
  flex: 1;
  min-width: 0;
  background: var(--bg-content);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- サイドバー --------------------------------------------------------- */

.sb-top {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 14px;
}

.workspace-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 4px;
  border-radius: var(--radius);
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  flex: 1;
  min-width: 0;
}
.workspace-btn:hover {
  background: var(--bg-hover);
}
.workspace-btn .ws-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-logo {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: linear-gradient(140deg, #f2994a, #eb5757 45%, #5e6ad2);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: var(--fw-bold);
  color: #fff;
  flex-shrink: 0;
}

.sb-icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.sb-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.sb-icon-btn.filled {
  background: var(--bg-active);
  color: var(--text-secondary);
}

.sb-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
}

.sb-section {
  margin-top: 14px;
}

.sb-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  padding: 0 6px;
  color: var(--text-tertiary);
  font-size: var(--font-size-mini);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-sm);
}
.sb-section-head:hover {
  color: var(--text-secondary);
}
.sb-section-head .chev {
  transition: transform var(--speed-quick);
  opacity: 0.7;
}
.sb-section-head.collapsed .chev {
  transform: rotate(-90deg);
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  width: 100%;
  text-align: left;
  position: relative;
}
.sb-item:hover {
  background: var(--bg-hover);
}
.sb-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
}
.sb-item .ico {
  color: var(--text-tertiary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.sb-item.active .ico {
  color: var(--text-secondary);
}
.sb-item .label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-item .count {
  color: var(--text-quaternary);
  font-size: var(--font-size-mini);
  font-variant-numeric: tabular-nums;
}
.sb-item.nested {
  padding-left: 26px;
}

.sb-team-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius);
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  width: 100%;
}
.sb-team-head:hover {
  background: var(--bg-hover);
}
.team-avatar {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: var(--fw-bold);
  color: #fff;
  flex-shrink: 0;
}

/* --- ヘッダー ----------------------------------------------------------- */

.header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  flex-shrink: 0;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  min-width: 0;
}
.crumbs .sep {
  color: var(--text-quaternary);
}
.crumbs .crumb-team {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}
.crumbs .crumb-team:hover {
  background: var(--bg-hover);
}
.crumbs h1 {
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  padding: 2px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header .spacer {
  flex: 1;
}

.star-btn {
  color: var(--text-quaternary);
  padding: 4px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}
.star-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}
.star-btn.on {
  color: #e2b203;
}

/* --- ツールバー（タブ + フィルタ） --------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 8px;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tab {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-round);
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}
.tab.active {
  color: var(--text-primary);
  background: var(--bg-active);
}

.tool-btn {
  height: 28px;
  min-width: 28px;
  padding: 0 8px;
  border-radius: var(--radius);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-small);
}
.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tool-btn.on {
  color: var(--text-primary);
  background: var(--bg-active);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  font-size: var(--font-size-mini);
  color: var(--text-secondary);
}
.chip .chip-key {
  color: var(--text-tertiary);
}
.chip .chip-x {
  color: var(--text-quaternary);
  display: grid;
  place-items: center;
  border-radius: 3px;
}
.chip .chip-x:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* --- Issue リスト ------------------------------------------------------- */

.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px 0 12px;
  background: var(--bg-hover);
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
}
.group-header .g-collapse {
  color: var(--text-quaternary);
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  transition: transform var(--speed-quick);
}
.group-header .g-collapse:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}
.group-header.collapsed .g-collapse {
  transform: rotate(-90deg);
}
.group-header .g-count {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-normal);
}
.group-header .spacer {
  flex: 1;
}
.group-header .g-add {
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  opacity: 0;
}
.group-header:hover .g-add {
  opacity: 1;
}
.group-header .g-add:hover {
  background: var(--bg-active);
  color: var(--text-primary);
}

.issue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--row-height);
  padding: 0 16px 0 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  position: relative;
}
.issue-row:hover {
  background: var(--bg-hover);
}
.issue-row.focused {
  background: var(--bg-hover);
}
.issue-row.focused::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
}
.issue-row.selected {
  background: var(--bg-selected);
}

.row-check {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  opacity: 0;
  color: #fff;
}
.issue-row:hover .row-check,
.issue-row.selected .row-check,
.list-selecting .row-check {
  opacity: 1;
}
.row-check.on {
  background: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

.row-id {
  color: var(--text-quaternary);
  font-size: var(--font-size-small);
  font-variant-numeric: tabular-nums;
  width: 66px;
  flex-shrink: 0;
}

.row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-small);
  color: var(--text-primary);
}
.issue-row.done .row-title {
  color: var(--text-tertiary);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-size-mini);
  color: var(--text-tertiary);
  max-width: 160px;
}
.badge .badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge.plain {
  border-color: transparent;
}

.label-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.row-date {
  color: var(--text-quaternary);
  font-size: var(--font-size-mini);
  width: 46px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: var(--fw-semibold);
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.empty {
  border: 1px dashed var(--border-strong);
  color: var(--text-quaternary);
  background: none;
}
.avatar.sm {
  width: 16px;
  height: 16px;
  font-size: 8px;
}
.avatar.lg {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.empty-state {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--font-size-small);
}
.empty-state h3 {
  color: var(--text-secondary);
  font-size: var(--font-size-regular);
  font-weight: var(--fw-medium);
  margin-bottom: 6px;
}

/* --- ボード ------------------------------------------------------------- */

.board {
  flex: 1;
  display: flex;
  gap: 12px;
  padding: 4px 12px 12px;
  overflow-x: auto;
  overflow-y: hidden;
}

.board-col {
  width: 320px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.board-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 6px;
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  flex-shrink: 0;
}
.board-col-head .g-count {
  color: var(--text-tertiary);
  font-weight: var(--fw-normal);
}
.board-col-head .spacer {
  flex: 1;
}

.board-col-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px;
  border-radius: var(--radius-md);
}
.board-col-body.drag-over {
  background: #5e6ad214;
  outline: 1px dashed var(--accent);
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}
.card:hover {
  border-color: var(--border-strong);
}
.card.dragging {
  opacity: 0.4;
}
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-quaternary);
  font-size: var(--font-size-mini);
}
.card-top .spacer {
  flex: 1;
}
.card-title {
  font-size: var(--font-size-small);
  color: var(--text-primary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- Issue 詳細 --------------------------------------------------------- */

.detail {
  flex: 1;
  display: flex;
  min-height: 0;
}

.detail-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 32px 0 120px;
}

.detail-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 40px;
}

.detail-title {
  font-size: var(--font-size-title2);
  font-weight: var(--fw-semibold);
  line-height: 1.3;
  width: 100%;
  resize: none;
  overflow: hidden;
  background: none;
  letter-spacing: -0.012em;
}

.detail-desc {
  margin-top: 16px;
  font-size: var(--font-size-regular);
  line-height: 1.6;
  color: var(--text-secondary);
  min-height: 60px;
}
.detail-desc.editing {
  outline: none;
}
.detail-desc textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  line-height: 1.6;
  font-family: var(--font-regular);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.md h1,
.md h2,
.md h3 {
  color: var(--text-primary);
  font-weight: var(--fw-semibold);
  margin: 22px 0 8px;
  line-height: 1.35;
}
.md h1 {
  font-size: 1.35rem;
}
.md h2 {
  font-size: 1.15rem;
}
.md h3 {
  font-size: 1rem;
}
.md p {
  margin: 10px 0;
}
.md ul,
.md ol {
  margin: 10px 0 10px 22px;
}
.md li {
  margin: 4px 0;
}
.md code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
}
.md pre {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
  margin: 12px 0;
}
.md pre code {
  border: none;
  background: none;
  padding: 0;
}
.md a {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.md blockquote {
  border-left: 2px solid var(--border-strong);
  padding-left: 12px;
  color: var(--text-tertiary);
  margin: 12px 0;
}
.md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}
.md table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: var(--font-size-small);
  display: block;
  overflow-x: auto;
}
.md th,
.md td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.md th {
  background: var(--bg-hover);
}
.md input[type="checkbox"] {
  margin-right: 6px;
}

.detail-side {
  width: 260px;
  min-width: 260px;
  border-left: 1px solid var(--border);
  padding: 24px 20px;
  overflow-y: auto;
}

.side-group {
  margin-bottom: 22px;
}
.side-label {
  font-size: var(--font-size-mini);
  color: var(--text-tertiary);
  font-weight: var(--fw-medium);
  margin-bottom: 8px;
}
.side-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 6px;
  margin-left: -6px;
  border-radius: var(--radius);
  font-size: var(--font-size-small);
  color: var(--text-secondary);
  width: calc(100% + 12px);
  text-align: left;
}
.side-row:hover {
  background: var(--bg-hover);
}
.side-row .placeholder {
  color: var(--text-tertiary);
}

.section-title {
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  margin: 28px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-issue-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  font-size: var(--font-size-small);
  cursor: pointer;
}
.sub-issue-row:hover {
  background: var(--bg-hover);
}

.activity {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.act-row {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  font-size: var(--font-size-small);
  color: var(--text-tertiary);
  align-items: flex-start;
}
.act-row .act-body {
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}
.act-row b {
  color: var(--text-secondary);
  font-weight: var(--fw-medium);
}
.act-time {
  color: var(--text-quaternary);
  font-size: var(--font-size-mini);
  white-space: nowrap;
}

.comment {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 10px 0;
  background: var(--bg-elevated);
}
.comment-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: var(--font-size-small);
}
.comment-head .spacer {
  flex: 1;
}
.comment-body {
  font-size: var(--font-size-small);
  line-height: 1.6;
  color: var(--text-secondary);
}
.comment-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
}
.comment:hover .comment-actions {
  opacity: 1;
}

.composer {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  padding: 10px 12px;
}
.composer textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  font-size: var(--font-size-small);
  line-height: 1.6;
}
.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* --- ボタン ------------------------------------------------------------- */

.btn {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-elevated);
}
.btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: var(--accent-hover);
}
.btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.ghost {
  border-color: transparent;
  background: none;
}
.btn.ghost:hover {
  background: var(--bg-hover);
}
.btn.danger {
  color: var(--danger);
}

/* --- ポップオーバー / モーダル ------------------------------------------- */

#overlay-root:empty {
  display: none;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.scrim.dim {
  background: var(--scrim);
}

.popover {
  position: fixed;
  z-index: 60;
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  min-width: 200px;
  max-width: 340px;
  padding: 4px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pop-search {
  height: 32px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
  margin: -4px -4px 4px;
}
.pop-search input {
  width: 100%;
  height: 100%;
  font-size: var(--font-size-small);
}
.pop-search input::placeholder {
  color: var(--text-quaternary);
}

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

.pop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-small);
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
}
.pop-item:hover,
.pop-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.pop-item .spacer {
  flex: 1;
}
.pop-item .kbd {
  color: var(--text-quaternary);
  font-size: var(--font-size-micro);
}
.pop-item .check {
  color: var(--text-secondary);
}
.pop-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.pop-head {
  font-size: var(--font-size-micro);
  color: var(--text-quaternary);
  padding: 6px 8px 4px;
  font-weight: var(--fw-medium);
}

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 13vh;
  pointer-events: none;
}

.modal {
  pointer-events: auto;
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 640px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 0;
  font-size: var(--font-size-mini);
  color: var(--text-tertiary);
}
.modal-head .spacer {
  flex: 1;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-mini);
  color: var(--text-secondary);
}

.modal-body {
  padding: 8px 16px 12px;
}
.modal-body input.title-input {
  width: 100%;
  font-size: var(--font-size-large);
  font-weight: var(--fw-medium);
  padding: 6px 0;
}
.modal-body input.title-input::placeholder {
  color: var(--text-quaternary);
}
.modal-body textarea.desc-input {
  width: 100%;
  min-height: 72px;
  font-size: var(--font-size-small);
  line-height: 1.6;
  resize: vertical;
  color: var(--text-secondary);
}
.modal-body textarea.desc-input::placeholder {
  color: var(--text-quaternary);
}

.modal-props {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 16px 12px;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.modal-foot .spacer {
  flex: 1;
}

/* コマンドパレット */
.cmdk {
  width: 640px;
}
.cmdk-input {
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.cmdk-input input {
  flex: 1;
  font-size: var(--font-size-regular);
}
.cmdk-input input::placeholder {
  color: var(--text-quaternary);
}
.cmdk-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: var(--font-size-small);
  color: var(--text-secondary);
  width: 100%;
  text-align: left;
}
.cmdk-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.cmdk-item .sub {
  color: var(--text-quaternary);
  font-size: var(--font-size-mini);
}
.cmdk-item .spacer {
  flex: 1;
}
.cmdk-foot {
  height: 36px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  font-size: var(--font-size-micro);
  color: var(--text-quaternary);
}

kbd {
  font-family: var(--font-regular);
  font-size: var(--font-size-micro);
  border: 1px solid var(--border);
  background: var(--bg-hover);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-tertiary);
}

/* --- 一括操作バー ------------------------------------------------------- */

.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 14px;
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  font-size: var(--font-size-small);
}

/* --- トースト ----------------------------------------------------------- */

.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.toast {
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: 9px 14px;
  font-size: var(--font-size-small);
  color: var(--text-secondary);
  animation: toast-in 0.2s var(--ease-out-quint);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* --- プロジェクト一覧 --------------------------------------------------- */

.proj-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.proj-row:hover {
  background: var(--bg-hover);
}
.proj-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.proj-name {
  font-size: var(--font-size-small);
  font-weight: var(--fw-medium);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-ring {
  flex-shrink: 0;
}

.progress-bar {
  height: 4px;
  background: var(--bg-active);
  border-radius: 2px;
  overflow: hidden;
  width: 120px;
  flex-shrink: 0;
}
.progress-bar > div {
  height: 100%;
  background: var(--accent);
}

/* --- 設定 --------------------------------------------------------------- */

.settings {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.settings h2 {
  font-size: var(--font-size-title3);
  font-weight: var(--fw-semibold);
  margin-bottom: 4px;
}
.settings .muted {
  color: var(--text-tertiary);
  font-size: var(--font-size-small);
  margin-bottom: 24px;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--font-size-small);
}
.set-row .spacer {
  flex: 1;
}
.set-row .set-label {
  font-weight: var(--fw-medium);
}
.set-row .set-desc {
  color: var(--text-tertiary);
  font-size: var(--font-size-mini);
  margin-top: 2px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin: 18px 0 8px;
}
.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--bg-elevated);
}
.stat .k {
  color: var(--text-tertiary);
  font-size: var(--font-size-mini);
}
.stat .v {
  font-size: var(--font-size-title3);
  font-weight: var(--fw-semibold);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .detail-side {
    display: none;
  }
  .sidebar {
    position: absolute;
    z-index: 30;
    height: 100%;
    box-shadow: var(--shadow-modal);
  }
}
