.panel-frame:not(:has(.panel)) { display: none; }
.panel-backdrop { display: none; }
.panel__mode .icon:last-child { display: none; }

html[data-panel-mode="popup"] {
  .board-layout:has(.panel) .panel-backdrop { display: block; position: fixed; inset: 0; z-index: 9; background: rgb(0 0 0 / 0.45); }
  .panel-frame {
    position: fixed; inset: 5vh auto auto 50%; translate: -50% 0; z-index: 10;
    width: min(760px, 92vw); max-height: 90vh;
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 24px 64px rgb(0 0 0 / 0.35);
  }
  .panel-resizer { display: none; }
  .panel__mode .icon:first-child { display: none; }
  .panel__mode .icon:last-child { display: inline; }
}
.board-layout:not(:has(.panel)) .panel-resizer { display: none; }

.panel-resizer {
  flex: none; width: 6px; margin-right: -6px; cursor: col-resize; z-index: 1; touch-action: none;
  &:hover, &.is-active { background: var(--accent); opacity: 0.5; }
}
.board-layout.is-resizing { user-select: none; cursor: col-resize; }

.panel-frame {
  flex: none; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border);
}

.panel { display: flex; flex-direction: column; gap: 16px; padding: 12px 20px 24px; }
.panel__header { display: flex; align-items: center; gap: 8px; }
.panel__actions { display: flex; margin-left: auto; }
.copy-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; margin-left: -8px;
  border: 0; border-radius: var(--radius); background: transparent; cursor: pointer; color: var(--text-muted);
  .icon { width: 14px; height: 14px; opacity: 0; transition: opacity 0.15s; }
  &:hover { background: var(--surface-2); .icon { opacity: 1; } }
}
.copy-link__done { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--success); .icon { opacity: 1; } }
.badge--muted { color: var(--text-2); background: var(--surface-2); }
.field {
  min-width: 0; max-width: 100%; height: 32px; padding: 0 10px;
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  &:hover { border-color: var(--text-muted); }
  &:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
  &:disabled { color: var(--text-2); background: transparent; border-color: var(--border); }
}

textarea.field { height: auto; padding: 6px 10px; }

.panel__title { width: 100%; font-size: 18px; font-weight: 700; line-height: 1.3; field-sizing: content; resize: none; }
.field--area { width: 100%; min-height: 120px; resize: vertical; line-height: 1.5; color: var(--text-2); }
.panel__section { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }

.props {
  display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; align-items: center;
  dt { display: flex; align-items: center; gap: 6px; color: var(--text-muted); .icon { width: 14px; height: 14px; } }
  dd { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 32px; }
  .priority { font-size: inherit; }
  .meta { font-size: inherit; color: var(--text); }
  .status { margin-left: 0; }
}

.status {
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500;
  color: var(--text-2); background: var(--surface-2);
  &[data-category="in_progress"] { color: var(--accent); background: var(--accent-soft); }
  &[data-category="done"] { color: var(--success); background: light-dark(#DCF5E7, #12301F); }
}


@media (max-width: 1199px) {
  .panel-resizer { display: none; }
  .panel-frame { position: fixed; inset: 0 0 0 auto; z-index: 10; width: min(var(--panel-w), 100vw); box-shadow: var(--shadow); }
}

@media (max-width: 599px) {
  .panel-frame { width: 100vw; border-left: 0; }
}

.panel__form, .panel__fields { display: contents; }
.panel__fields[disabled] .field { pointer-events: none; }
.field--short { width: 80px; }
.unit { color: var(--text-muted); }
.count { color: var(--text-muted); font-weight: 400; }

.picker { position: relative; flex: 1; min-width: 0; }
.picker__summary { display: flex; align-items: center; gap: 8px; .avatars { margin-left: 0; } }
.picker__names { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker__menu { left: -8px; width: 260px; max-height: 280px; overflow-y: auto; padding: 4px; }
.picker__search { height: 32px; margin-bottom: 4px; }
.picker__empty { padding: 6px 8px; }
.picker__option {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
  &:hover { background: var(--surface-2); }
  input { accent-color: var(--brand); }
}

.markdown--editable { margin-left: -8px; padding: 4px 8px; border-radius: var(--radius); cursor: text; &:hover { background: var(--surface-2); } }

.attachments { display: grid; gap: 6px; }
.attachment { display: flex; align-items: center; gap: 4px; }
.attachment__link {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: var(--radius);
  &:hover { background: var(--surface-2); }
}
.attachment__thumb { flex: none; width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.attachment__thumb--file { display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--text-muted); }
.attachment__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment__size { font-size: 12px; color: var(--text-muted); }

.comment { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment__header { display: flex; align-items: center; gap: 8px; time { font-size: 12px; color: var(--text-muted); } }
.comment .markdown { padding-left: 32px; color: var(--text-2); }
.comment__actions {
  display: flex; gap: 10px; margin-left: auto; opacity: 0; transition: opacity 0.15s;
  a, button { padding: 0; border: 0; background: none; font-size: 12px; color: var(--text-muted); cursor: pointer; &:hover { color: var(--text); } }
}
.comment:hover .comment__actions, .comment:focus-within .comment__actions { opacity: 1; }
.comment .attachments { padding-left: 32px; }

.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form__time { display: flex; align-items: center; gap: 8px; color: var(--text-muted); .icon { width: 16px; height: 16px; } }
.comment-form__duration { width: 170px; height: 32px; }
.timelog {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; color: var(--accent); background: var(--accent-soft);
  .icon { width: 12px; height: 12px; }
  &.is-over { color: var(--danger); background: light-dark(#F4D6D6, #3A1414); }
}
.comment-form__actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.comment-form__files {
  flex: 1; min-width: 0; font-size: 12px; color: var(--text-muted);
  &::file-selector-button { margin-right: 8px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); font: inherit; color: var(--text-2); background: transparent; cursor: pointer; }
}
.comment-form__input { height: auto; padding: 8px 12px; resize: vertical; }

.mentions {
  position: fixed; z-index: 20; width: 280px; max-height: 260px; overflow-y: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow);
  li { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
  li[aria-selected="true"] { background: var(--accent-soft); }
  span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  small { color: var(--text-muted); }
}

.preview {
  width: min(1100px, 94vw); height: min(90vh, 900px); padding: 0; overflow: hidden;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  &::backdrop { background: rgb(0 0 0 / 0.6); }
  &[open] { display: flex; flex-direction: column; }
}
.preview__header { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); }
.preview__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.preview__body {
  flex: 1; min-height: 0; display: grid; place-items: center; background: var(--bg);
  img, video { max-width: 100%; max-height: 100%; object-fit: contain; }
  iframe { width: 100%; height: 100%; border: 0; color-scheme: light; background: #fff; }
}
