:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #11151c;
  --panel-soft: #151a22;
  --panel-raised: #191f29;
  --ink: #f2f5f8;
  --muted: #8f9aa8;
  --line: #27303d;
  --line-strong: #394454;
  --accent: #cf0a2c;
  --accent-ink: #ffffff;
  --accent-soft: rgba(207, 10, 44, 0.16);
  --focus: #2ec7d3;
  --monitor: #7c6ee6;
  --execute: #2ec7d3;
  --success: #31c48d;
  --warning: #f5b84b;
  --danger: #ff5b6e;
}

* {
  box-sizing: border-box;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

* {
  scrollbar-color: var(--line-strong) var(--bg);
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #111621 0, var(--bg) 220px),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
}

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

a:hover {
  color: #ff6b7d;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.86);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px);
}

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

nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.logout-form {
  margin: 0;
}

nav a,
.icon-button,
button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 7px 12px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

nav a:hover,
button:hover {
  border-color: var(--accent);
  background: #1b222d;
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.topbar-workspace {
  display: flex;
  align-items: center;
  gap: 8px;
}

.create-current-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

.section-title {
  margin-bottom: 16px;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

p {
  margin: 0 0 10px;
}

.section-title p,
.meta,
.empty {
  color: var(--muted);
}

.panel,
.task-card,
.time-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c1016;
  color: var(--ink);
  padding: 7px 9px;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(46, 199, 211, 0.14);
}

textarea {
  resize: vertical;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(207, 10, 44, 0.24);
}

.ghost {
  background: transparent;
}

.project-grid,
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.workspace-shell {
  display: grid;
  gap: 22px;
}

.workspace-switcher {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(118px, 1fr));
  width: min(340px, calc(100vw - 220px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 21, 28, 0.9);
  padding: 5px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(16px);
}

.workspace-slider {
  position: absolute;
  top: 5px;
  left: 5px;
  width: calc((100% - 10px) / 2);
  height: calc(100% - 10px);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #ff4d64);
  box-shadow: 0 8px 24px rgba(207, 10, 44, 0.32);
  transition: transform 220ms ease;
}

.workspace-switcher button {
  position: relative;
  z-index: 1;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.workspace-switcher button:hover {
  background: transparent;
  box-shadow: none;
}

.workspace-switcher button.active {
  color: var(--accent-ink);
}

.workspace-view {
  display: none;
}

.workspace-view.active {
  display: block;
  animation: workspaceIn 220ms ease both;
}

@keyframes workspaceIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-home {
  display: grid;
  gap: 16px;
}

.project-home-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 0;
}

.activity-strip {
  position: sticky;
  top: 74px;
  z-index: 8;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 21, 28, 0.92);
  padding: 12px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
  transition: padding 160ms ease, gap 160ms ease;
}

.activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.activity-head h2,
.activity-head p {
  margin-bottom: 0;
}

.activity-head p {
  color: var(--muted);
  font-size: 13px;
}

.activity-head strong {
  white-space: nowrap;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(10, minmax(48px, 1fr));
  gap: 8px;
}

.heat-cell {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #121821;
  padding: 8px;
}

.heat-cell span,
.heat-cell small {
  color: var(--muted);
  font-size: 12px;
}

.heat-cell strong {
  font-size: 20px;
}

.heat-cell small {
  grid-column: 1 / -1;
}

.heat-cell.level-1 {
  background: rgba(207, 10, 44, 0.18);
  border-color: rgba(207, 10, 44, 0.32);
}

.heat-cell.level-2 {
  background: rgba(207, 10, 44, 0.32);
  border-color: rgba(207, 10, 44, 0.48);
}

.heat-cell.level-3 {
  background: rgba(207, 10, 44, 0.56);
  border-color: rgba(255, 91, 110, 0.68);
  color: var(--ink);
}

.heat-cell.level-4 {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.heat-cell.level-4 span,
.heat-cell.level-4 small {
  color: rgba(255, 255, 255, 0.82);
}

.activity-strip.is-condensed {
  gap: 8px;
  padding: 8px 12px;
}

.activity-strip.is-condensed .activity-head p,
.activity-strip.is-condensed .heat-cell small {
  display: none;
}

.activity-strip.is-condensed .heat-cell {
  min-height: 34px;
  padding: 5px 8px;
}

.activity-strip.is-condensed .heat-cell strong {
  font-size: 15px;
}

.project-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.project-column {
  display: grid;
  gap: 12px;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 19, 26, 0.78);
  padding: 12px;
}

.column-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.column-head h2,
.column-head p {
  margin-bottom: 0;
}

.column-head p {
  color: var(--muted);
  font-size: 13px;
}

.project-dropzone {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 330px;
}

.project-column.drag-over {
  border-color: var(--accent);
  background: rgba(207, 10, 44, 0.08);
}

.task-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-left-width: 5px;
}

.task-card.execute {
  border-left-color: var(--execute);
}

.task-card.monitor {
  border-left-color: var(--monitor);
}

.project-card {
  min-height: 170px;
}

.board-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  padding: 14px;
  cursor: grab;
}

.board-card:active {
  cursor: grabbing;
}

.board-card.is-dragging {
  opacity: 0.55;
}

.column-empty {
  min-height: 92px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.task-head,
.project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-head a,
.project-head a {
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: #1d2530;
  color: var(--muted);
  padding: 2px 9px;
  white-space: nowrap;
  font-size: 12px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}

.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #202733;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.schedule-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.period-form {
  grid-template-columns: 1fr 1fr auto;
}

.schedule-form input[name="note"] {
  grid-column: 1 / -1;
}

.schedule-form button {
  grid-column: 1 / -1;
}

.period-form button {
  grid-column: 1 / -1;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.check input {
  width: 16px;
  min-height: 16px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
}

.time-block {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 80px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
}

.time-block p {
  grid-column: 2 / -1;
  color: var(--muted);
  margin: 0;
}

.detail-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 20px;
  align-items: start;
}

.detail-panel {
  margin-bottom: 0;
}

.detail-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-titlebar > div:first-child {
  min-width: 0;
}

.detail-titlebar form {
  margin: 0;
}

.detail-read {
  display: grid;
  gap: 18px;
}

.read-section {
  display: grid;
  gap: 8px;
}

.read-section h2 {
  margin-bottom: 0;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.detail-facts div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.detail-facts dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-facts dd {
  margin: 0;
}

.panel-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-titlebar h2 {
  margin-bottom: 0;
}

.panel-titlebar button {
  min-height: 30px;
  padding: 5px 9px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-builder {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.builder-head h3 {
  margin: 0;
  font-size: 15px;
}

.repeatable-rows {
  display: grid;
  gap: 10px;
}

.repeatable-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 8px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.attachment-row {
  grid-template-columns: 1fr auto;
}

.attachment-row .wide {
  grid-column: 1 / -1;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.side-stack .panel {
  margin-bottom: 0;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.project-task-row {
  justify-content: start;
}

.project-task-row a {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.project-task-row form {
  margin: 0;
}

.project-task-row button {
  min-height: 30px;
  padding: 5px 9px;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.attachment {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--panel-soft);
}

.attachment summary {
  cursor: pointer;
  font-weight: 700;
}

.progress-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.progress-item {
  display: grid;
  gap: 6px;
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 10px;
}

.progress-item time {
  color: var(--muted);
  font-size: 12px;
}

.progress-item .markdown-preview {
  margin-top: 0;
}

.progress-empty {
  list-style: none;
  margin: 0;
}

.markdown-preview {
  margin-top: 10px;
}

.markdown-preview,
.toastui-editor-contents {
  color: var(--ink);
}

.markdown-preview a,
.toastui-editor-contents a {
  color: var(--focus);
}

.markdown-preview blockquote,
.toastui-editor-contents blockquote {
  border-left-color: var(--accent);
  color: var(--muted);
}

.toastui-editor-defaultUI,
.toastui-editor-defaultUI-toolbar,
.toastui-editor-main,
.toastui-editor-md-container,
.toastui-editor-md-preview,
.toastui-editor-ww-container {
  border-color: var(--line) !important;
  background: var(--panel-soft) !important;
  color: var(--ink) !important;
}

.toastui-editor-defaultUI-toolbar button,
.toastui-editor-toolbar-icons {
  border-color: transparent !important;
  background-color: transparent !important;
  filter: invert(1) opacity(0.74);
}

.toastui-editor-md-splitter,
.toastui-editor-mode-switch {
  border-color: var(--line) !important;
  background: #0c1016 !important;
}

.toastui-editor-md-tab-container,
.toastui-editor-tabs {
  background: var(--panel-soft) !important;
  border-color: var(--line) !important;
}

.toastui-editor-md-tab-container .tab-item,
.toastui-editor-tabs .tab-item {
  color: var(--muted) !important;
}

.toastui-editor-md-tab-container .tab-item.active,
.toastui-editor-tabs .tab-item.active {
  color: var(--ink) !important;
  border-color: var(--accent) !important;
}

.toastui-editor-md-container .toastui-editor,
.toastui-editor-md-container .ProseMirror,
.toastui-editor-ww-container .ProseMirror {
  background: #0c1016 !important;
  color: var(--ink) !important;
}

.toastui-editor-popup,
.toastui-editor-popup-body {
  border-color: var(--line) !important;
  background: var(--panel-raised) !important;
  color: var(--ink) !important;
}

.compact-md {
  max-height: 92px;
  overflow: hidden;
}

.md-source {
  display: none;
}

.md-editor {
  min-height: 420px;
}

.flash {
  display: flex;
  gap: 8px;
  max-width: 1480px;
  margin: 12px auto 0;
  padding: 0 24px;
}

.flash span {
  border: 1px solid rgba(46, 199, 211, 0.38);
  border-radius: 6px;
  background: rgba(46, 199, 211, 0.12);
  color: #b8f4f8;
  padding: 8px 10px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
}

.auth-panel {
  display: grid;
  gap: 14px;
  margin: 0;
}

.auth-panel button {
  width: 100%;
}

.inline-error {
  border: 1px solid rgba(255, 91, 110, 0.42);
  border-radius: 6px;
  background: rgba(255, 91, 110, 0.12);
  color: #ffd5dc;
  padding: 8px 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: absolute;
  top: 76px;
  left: 24px;
  width: min(620px, calc(100vw - 48px));
  max-height: calc(100vh - 104px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52);
}

.modal-panel.wide-modal {
  width: min(860px, calc(100vw - 48px));
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  padding: 0;
  font-size: 20px;
}

@media (max-width: 980px) {
  .detail-shell {
    grid-template-columns: 1fr;
  }

  .detail-facts {
    grid-template-columns: 1fr;
  }

  .project-board {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 12px;
    gap: 10px;
  }

  .workspace-switcher {
    width: min(320px, calc(100vw - 170px));
  }

  main {
    padding: 16px;
  }
}

@media (max-width: 620px) {
  .topbar {
    height: auto;
    min-height: 58px;
    grid-template-columns: auto auto;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .topbar-center {
    grid-column: 1 / -1;
    grid-row: 2;
    order: 3;
  }

  nav {
    justify-content: flex-start;
  }

  .topbar-workspace {
    width: 100%;
    justify-content: center;
  }

  .workspace-switcher {
    width: min(300px, calc(100vw - 88px));
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-switcher button {
    min-height: 36px;
  }

  .form-grid,
  .schedule-form,
  .time-block {
    grid-template-columns: 1fr;
  }

  .time-block p {
    grid-column: auto;
  }

  .project-grid,
  .task-grid {
    grid-template-columns: 1fr;
  }

  .project-home-title,
  .activity-head {
    align-items: stretch;
    flex-direction: column;
  }

  .activity-strip {
    top: 118px;
  }

  .heatmap {
    grid-template-columns: repeat(10, minmax(30px, 1fr));
    gap: 5px;
  }

  .heat-cell {
    min-height: 48px;
    padding: 6px;
  }

  .heat-cell strong {
    font-size: 16px;
  }
}
