/* ===== Themes ===== */
:root {
  --bg: #1e1f21;
  --surface: #252628;
  --card: #2e2f31;
  --card-hover: #353638;
  --border: #3a3b3d;
  --text: #f1f0ee;
  --text-dim: #9ca0a4;
  --accent: #4573d2;
  --danger: #d64f4f;
  --drop-indicator: #4573d2;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

body.light {
  --bg: #f4f3f1;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f7f7f6;
  --border: #dedcd8;
  --text: #1f1e1c;
  --text-dim: #6f6d68;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

/* Elements with the hidden attribute must never be shown,
   regardless of any display rules on their classes */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Top bar ===== */
.topbar { padding: 12px 20px 0; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar-row { display: flex; align-items: center; gap: 10px; }

.project-badge {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #e05c78, #c94f6d);
  color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}

.project-name { font-size: 18px; font-weight: 600; margin: 0; flex: 1; }

.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; width: 32px; height: 32px; font-size: 16px; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }

.tabs { display: flex; gap: 4px; margin-top: 10px; }
.tab {
  background: none; border: none; color: var(--text-dim); font-size: 14px;
  padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

/* ===== Main view container ===== */
#view { flex: 1; overflow: auto; }
.board-loading { color: var(--text-dim); padding: 20px; }

/* ===== Board view ===== */
#view.view-board {
  display: flex; gap: 14px; padding: 18px 20px;
  overflow-x: auto; align-items: flex-start;
}

.column {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  width: 290px; min-width: 290px; max-height: 100%;
  display: flex; flex-direction: column;
}

.column-header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }

.column-name {
  font-size: 15px; font-weight: 600; border: 1px solid transparent; border-radius: 5px;
  padding: 2px 6px; margin-left: -6px; background: none; color: var(--text);
  width: 100%; min-width: 0;
}
.column-name:hover { border-color: var(--border); }
.column-name:focus { outline: none; border-color: var(--accent); background: var(--card); }

.column-count { color: var(--text-dim); font-size: 13px; flex-shrink: 0; }

.column-delete {
  background: none; border: none; color: var(--text-dim); font-size: 15px;
  cursor: pointer; border-radius: 5px; padding: 2px 6px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
}
.column:hover .column-delete { opacity: 1; }
.column-delete:hover { color: var(--danger); background: var(--card); }

.tasks { padding: 4px 10px; overflow-y: auto; flex: 1; min-height: 30px; }

.task {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; margin-bottom: 8px; cursor: pointer;
  box-shadow: var(--shadow); position: relative;
}
.task:hover { background: var(--card-hover); }
.task.dragging { opacity: 0.4; }

.task-title { font-size: 14px; line-height: 1.4; word-break: break-word; padding-right: 20px; }

.task-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

.chip {
  display: inline-block; font-size: 11px; font-weight: 600; color: #fff;
  border-radius: 10px; padding: 2px 8px; line-height: 1.5; white-space: nowrap;
}

.task-meta {
  margin-top: 8px; font-size: 12px; color: var(--text-dim);
  display: flex; gap: 10px; align-items: center;
}
.task-meta .overdue { color: var(--danger); font-weight: 600; }

.task-delete {
  position: absolute; top: 8px; right: 8px; background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 14px; border-radius: 4px;
  padding: 1px 5px; opacity: 0; transition: opacity 0.15s;
}
.task:hover .task-delete { opacity: 1; }
.task-delete:hover { color: var(--danger); }

.drop-indicator { height: 3px; background: var(--drop-indicator); border-radius: 2px; margin: 2px 0 8px; }

.add-task-btn, .add-column-btn {
  background: none; border: none; color: var(--text-dim); font-size: 14px;
  text-align: left; padding: 10px 14px; cursor: pointer; border-radius: 0 0 10px 10px;
}
.add-task-btn:hover, .add-column-btn:hover { color: var(--text); background: var(--card); }

.add-column-btn {
  border: 1px dashed var(--border); border-radius: 10px;
  width: 290px; min-width: 290px; padding: 14px; flex-shrink: 0;
}

.add-task-form { padding: 0 10px 10px; }
.add-task-input {
  width: 100%; font-size: 14px; font-family: inherit;
  background: var(--card); color: var(--text);
  border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; resize: none;
}
.add-task-input:focus { outline: none; }

/* ===== List view ===== */
#view.view-list { padding: 18px 20px; }

.list-section { margin-bottom: 22px; }
.list-section-header {
  font-size: 15px; font-weight: 600; margin-bottom: 6px;
  display: flex; gap: 8px; align-items: baseline;
}
.list-section-header .column-count { font-weight: 400; }

.list-row, .list-head {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 110px 110px 110px 80px;
  gap: 10px; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.list-head { font-size: 12px; color: var(--text-dim); border-bottom-width: 2px; }
.list-row { cursor: pointer; font-size: 14px; }
.list-row:hover { background: var(--card); }
.list-cell-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-cell-dim { font-size: 13px; color: var(--text-dim); }
.list-cell-dim.overdue { color: var(--danger); font-weight: 600; }

/* ===== Calendar view ===== */
#view.view-calendar { padding: 18px 20px; display: flex; flex-direction: column; }

.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-title { font-size: 17px; font-weight: 600; min-width: 170px; }
.cal-nav {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 4px 12px; font-size: 14px; cursor: pointer;
}
.cal-nav:hover { background: var(--card-hover); }
.cal-hint { font-size: 12px; color: var(--text-dim); margin-left: auto; }

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex: 1;
  grid-auto-rows: auto;
}
.cal-dow {
  background: var(--surface); font-size: 12px; color: var(--text-dim);
  padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left;
}
.cal-day {
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 6px; min-height: 96px; font-size: 12px;
}
.cal-day.other-month { opacity: 0.4; }
.cal-day-num { color: var(--text-dim); margin-bottom: 4px; }
.cal-day.today .cal-day-num {
  background: var(--accent); color: #fff; border-radius: 10px;
  display: inline-block; padding: 0 7px;
}
.cal-task {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 5px; color: var(--text); font-size: 12px;
  padding: 3px 6px; margin-bottom: 3px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-task:hover { background: var(--card-hover); }

/* ===== Timeline view ===== */
#view.view-timeline { padding: 18px 20px; }

.tl-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.tl-inner { position: relative; min-width: max-content; }

.tl-header { display: flex; border-bottom: 1px solid var(--border); background: var(--surface); }
.tl-label-col { width: 220px; min-width: 220px; padding: 6px 10px; font-size: 12px; color: var(--text-dim); border-right: 1px solid var(--border); position: sticky; left: 0; background: var(--surface); z-index: 2; }
.tl-day { width: 34px; min-width: 34px; font-size: 10px; color: var(--text-dim); text-align: center; padding: 6px 0; border-right: 1px solid var(--border); }
.tl-day.weekend { background: var(--card); }
.tl-day.today { color: var(--accent); font-weight: 700; }

.tl-row { display: flex; align-items: center; border-bottom: 1px solid var(--border); height: 38px; }
.tl-row:hover { background: var(--card); }
.tl-row .tl-label-col {
  font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: pointer; height: 100%; display: flex; align-items: center;
}
.tl-track { position: relative; height: 100%; flex: 1; }
.tl-bar {
  position: absolute; top: 8px; height: 20px; border-radius: 10px;
  background: var(--accent); opacity: 0.9; cursor: pointer; min-width: 12px;
}
.tl-bar:hover { opacity: 1; }
.tl-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: 0.5; z-index: 1; }

.tl-empty { padding: 24px; color: var(--text-dim); font-size: 14px; }

/* ===== Overview view ===== */
#view.view-overview { padding: 18px 20px; }

.ov-cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.ov-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 18px; min-width: 150px;
}
.ov-card-num { font-size: 26px; font-weight: 700; }
.ov-card-num.danger { color: var(--danger); }
.ov-card-label { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.ov-section { margin-bottom: 22px; max-width: 560px; }
.ov-section h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }

.ov-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 13px; }
.ov-bar-label { width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-bar-track { flex: 1; background: var(--card); border-radius: 5px; height: 10px; overflow: hidden; }
.ov-bar-fill { height: 100%; background: var(--accent); border-radius: 5px; }
.ov-bar-count { width: 30px; text-align: right; color: var(--text-dim); }

.ov-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

/* ===== Task modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40;
}

.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 680px; max-width: calc(100vw - 24px); max-height: calc(100vh - 40px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  z-index: 50; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
  from { transform: translate(-50%, -48%); opacity: 0; }
  to { transform: translate(-50%, -50%); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .modal { animation: none; }
}

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

.status-select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; font-family: inherit; cursor: pointer;
}
.status-select:focus { outline: none; border-color: var(--accent); }

.modal-actions { display: flex; gap: 6px; }

.icon-btn {
  background: none; border: 1px solid transparent; color: var(--text-dim);
  font-size: 15px; cursor: pointer; border-radius: 6px; padding: 4px 8px;
}
.icon-btn:hover { color: var(--text); background: var(--card); }
.icon-btn.danger:hover { color: var(--danger); }

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

.modal-title {
  width: 100%; font-size: 21px; font-weight: 600; font-family: inherit;
  background: none; color: var(--text); border: 1px solid transparent; border-radius: 6px;
  padding: 6px 8px; margin: 0 0 10px -8px; resize: none; line-height: 1.35;
}
.modal-title:hover { border-color: var(--border); }
.modal-title:focus { outline: none; border-color: var(--accent); background: var(--card); }

.field-grid {
  display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px;
  align-items: center; margin-bottom: 16px;
}
.field-label { font-size: 13px; color: var(--text-dim); }
.field-control { display: flex; align-items: center; gap: 6px; }

.field-select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; font-family: inherit;
  cursor: pointer; min-width: 140px;
}
.field-select:focus { outline: none; border-color: var(--accent); }

.field-value-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

.gear-btn {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; border-radius: 5px; padding: 3px 6px;
}
.gear-btn:hover { color: var(--text); background: var(--card); }

.date-input {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; font-size: 13px; font-family: inherit;
  color-scheme: dark;
}
body.light .date-input { color-scheme: light; }
.date-input:focus { outline: none; border-color: var(--accent); }

.field-static { font-size: 13px; color: var(--text-dim); }

.modal-section-label {
  font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 18px 0 8px;
}

.modal-desc {
  width: 100%; min-height: 80px; font-size: 14px; font-family: inherit; line-height: 1.5;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; resize: vertical;
}
.modal-desc:focus { outline: none; border-color: var(--accent); }

/* Attachments */
.attachment-list { display: flex; flex-direction: column; gap: 8px; }
.attachment {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.attachment-thumb {
  width: 44px; height: 44px; object-fit: cover; border-radius: 6px;
  background: var(--bg); flex-shrink: 0; cursor: zoom-in;
}
.attachment-fileicon {
  width: 44px; height: 44px; border-radius: 6px; background: var(--bg);
  display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
.attachment-info { flex: 1; min-width: 0; }
.attachment-name {
  font-size: 13px; color: var(--text); text-decoration: none; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attachment-name:hover { text-decoration: underline; }
.attachment-size { font-size: 12px; color: var(--text-dim); }

.upload-btn {
  background: none; border: 1px dashed var(--border); color: var(--text-dim);
  font-size: 13px; border-radius: 8px; padding: 10px; cursor: pointer; width: 100%; margin-top: 8px;
}
.upload-btn:hover { color: var(--text); border-color: var(--text-dim); }
.upload-btn:disabled { opacity: 0.5; cursor: wait; }

/* Comments */
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.comment-author { font-size: 13px; font-weight: 600; }
.comment-date { font-size: 12px; color: var(--text-dim); flex: 1; }
.comment-delete { background: none; border: none; color: var(--text-dim); font-size: 12px; cursor: pointer; opacity: 0; }
.comment:hover .comment-delete { opacity: 1; }
.comment-delete:hover { color: var(--danger); }
.comment-body { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

.comment-form { border-top: 1px solid var(--border); padding: 12px 20px; flex-shrink: 0; }
.comment-name-input {
  width: 100%; font-size: 13px; font-family: inherit; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin-bottom: 8px;
}
.comment-name-input:focus { outline: none; border-color: var(--accent); }
.comment-input {
  width: 100%; font-size: 14px; font-family: inherit; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; resize: none; min-height: 56px;
}
.comment-input:focus { outline: none; border-color: var(--accent); }
.comment-submit {
  margin-top: 8px; background: var(--accent); border: none; color: #fff;
  font-size: 14px; font-weight: 600; border-radius: 8px; padding: 8px 16px; cursor: pointer;
}
.comment-submit:hover { filter: brightness(1.1); }
.comment-submit:disabled { opacity: 0.5; cursor: wait; }

.empty-hint { font-size: 13px; color: var(--text-dim); }

/* ===== Options editor (on top of the modal) ===== */
.editor-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 70; }
.editor {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 420px; max-width: calc(100vw - 24px); max-height: 80vh;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  z-index: 71; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.editor-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px;
}
.editor-body { padding: 12px 16px; overflow-y: auto; }
.editor-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.editor-color {
  width: 34px; height: 30px; padding: 2px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--card); cursor: pointer;
}
.editor-label {
  flex: 1; font-size: 14px; font-family: inherit; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
}
.editor-label:focus { outline: none; border-color: var(--accent); }
.editor-add {
  background: none; border: 1px dashed var(--border); color: var(--text-dim);
  font-size: 13px; border-radius: 8px; padding: 8px; cursor: pointer; width: 100%; margin-top: 4px;
}
.editor-add:hover { color: var(--text); border-color: var(--text-dim); }

/* Image lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.85); z-index: 80;
  display: grid; place-items: center; cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--danger); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); z-index: 100;
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar { height: 10px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 720px) {
  .list-row, .list-head { grid-template-columns: 1fr 90px 90px; }
  .list-cell-scope, .list-cell-created { display: none; }
}

/* ===== v4: fix for empty modal stripe ===== */
.modal[hidden] { display: none; }

/* ===== v4: brand + project topbar ===== */
.brand {
  background: none; border: none; color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 16px; font-weight: 800; letter-spacing: 3px;
  padding: 4px 2px;
}
.brand:hover { color: var(--accent); }

.topbar-spacer { flex: 1; }

.project-name-input {
  font-size: 17px; font-weight: 600; font-family: inherit;
  background: none; color: var(--text);
  border: 1px solid transparent; border-radius: 6px;
  padding: 4px 8px; min-width: 0; flex: 1; max-width: 420px;
}
.project-name-input:hover { border-color: var(--border); }
.project-name-input:focus { outline: none; border-color: var(--accent); background: var(--card); }

/* ===== v4: home page ===== */
#view.view-home {
  display: flex; flex-direction: column; align-items: center;
  padding: 56px 20px;
}

.home-title {
  font-size: 58px; font-weight: 800; letter-spacing: 14px;
  margin: 0 0 4px; padding-left: 14px; /* optical centering of letter-spacing */
}
.home-sub { color: var(--text-dim); margin: 0 0 34px; font-size: 15px; }

.project-cards {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 820px;
}

.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; width: 250px; cursor: pointer; text-align: left;
  color: var(--text); font-family: inherit; font-size: 14px;
}
.project-card:hover { background: var(--card); border-color: var(--text-dim); }

.project-card-name {
  font-size: 17px; font-weight: 700;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.project-card-lock { font-size: 13px; }
.project-card-desc { font-size: 13px; color: var(--text-dim); margin-top: 8px; min-height: 36px; line-height: 1.45; }

.new-project-btn {
  background: none; border: 1px dashed var(--border); border-radius: 12px;
  color: var(--text-dim); font-family: inherit; font-size: 14px;
  padding: 18px 20px; width: 250px; cursor: pointer;
}
.new-project-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* ===== v4: project login ===== */
.login-box {
  max-width: 340px; margin: 70px auto 0; text-align: center;
  display: flex; flex-direction: column; gap: 12px; padding: 0 16px;
}
.login-title { font-size: 22px; font-weight: 700; margin: 0; }
.login-sub { color: var(--text-dim); font-size: 14px; margin: 0; }
.login-input {
  font-size: 15px; font-family: inherit; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; text-align: center;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn {
  background: var(--accent); border: none; color: #fff; font-size: 15px; font-weight: 600;
  border-radius: 8px; padding: 10px; cursor: pointer;
}
.login-btn:hover { filter: brightness(1.1); }
.login-btn:disabled { opacity: 0.5; cursor: wait; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 0; }
.login-back {
  background: none; border: none; color: var(--text-dim); font-size: 13px;
  cursor: pointer; font-family: inherit;
}
.login-back:hover { color: var(--text); }

/* ===== v4: settings modal bits ===== */
.settings-section { margin-bottom: 16px; }
.settings-section h3 { font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 0 0 8px; }
.settings-input {
  width: 100%; font-size: 14px; font-family: inherit; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px;
}
.settings-input:focus { outline: none; border-color: var(--accent); }
.settings-btn {
  background: var(--accent); border: none; color: #fff; font-size: 14px; font-weight: 600;
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
.settings-btn:hover { filter: brightness(1.1); }
.settings-btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.settings-hint { font-size: 12px; color: var(--text-dim); margin: 4px 0 0; }
.settings-msg { font-size: 13px; min-height: 18px; margin: 6px 0 0; }
.settings-msg.ok { color: #4caf50; }
.settings-msg.err { color: var(--danger); }

/* ===== v4: project description on Overview ===== */
.ov-desc { max-width: 560px; margin-bottom: 22px; }

/* ===== v6: quick wins ===== */
.modal-title { min-height: 42px; }

.task.overdue { border-left: 3px solid var(--danger); }

.task-top { display: flex; gap: 8px; align-items: flex-start; }
.task-check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--text-dim); background: none; color: transparent;
  font-size: 11px; line-height: 1; cursor: pointer; flex-shrink: 0;
  display: grid; place-items: center; padding: 0; margin-top: 1px;
}
.task-check:hover { border-color: #4caf50; color: #4caf50; }
.task-check.checked { background: #4caf50; border-color: #4caf50; color: #fff; }

.task .task-title { padding-right: 40px; }

.task-copy {
  position: absolute; top: 8px; right: 30px; background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 13px; border-radius: 4px;
  padding: 1px 5px; opacity: 0; transition: opacity 0.15s;
}
.task:hover .task-copy { opacity: 1; }
.task-copy:hover { color: var(--text); background: var(--card-hover); }

.task-due {
  background: none; border: none; color: var(--text-dim); font-size: 12px;
  cursor: pointer; padding: 0; font-family: inherit;
}
.task-due:hover { color: var(--text); text-decoration: underline; }
.task-due.overdue { color: var(--danger); font-weight: 600; }
.task-due.ghost { opacity: 0; transition: opacity 0.15s; }
.task:hover .task-due.ghost, .list-row:hover .task-due.ghost { opacity: 1; }
.task-due.list-due { text-align: left; font-size: 13px; }

.date-inline { font-size: 12px; padding: 2px 6px; max-width: 150px; }

/* ===== Kuna V1: branding + subtasks ===== */
.home-tagline {
  color: var(--text-dim); font-size: 13px; letter-spacing: 4px;
  text-transform: uppercase; margin: 0 0 40px; padding-left: 4px;
}

.module-title {
  font-size: 28px; font-weight: 700; letter-spacing: 8px;
  margin: 0 0 2px; padding-left: 8px;
}
.module-tagline {
  color: var(--text-dim); font-size: 12px; letter-spacing: 3px;
  text-transform: uppercase; margin: 0 0 20px; padding-left: 3px;
}

.subtask-list { display: flex; flex-direction: column; }
.subtask {
  display: flex; align-items: center; gap: 8px; padding: 3px 0;
}
.subtask-check { width: 15px; height: 15px; accent-color: #4caf50; cursor: pointer; flex-shrink: 0; }
.subtask-title {
  flex: 1; font-size: 14px; font-family: inherit; background: none; color: var(--text);
  border: 1px solid transparent; border-radius: 5px; padding: 3px 6px; min-width: 0;
}
.subtask-title:hover { border-color: var(--border); }
.subtask-title:focus { outline: none; border-color: var(--accent); background: var(--card); }
.subtask.done .subtask-title { text-decoration: line-through; color: var(--text-dim); }
.subtask-del { opacity: 0; font-size: 12px; }
.subtask:hover .subtask-del { opacity: 1; }

.subtask-add {
  width: 100%; font-size: 13px; font-family: inherit; background: none; color: var(--text);
  border: 1px dashed var(--border); border-radius: 8px; padding: 7px 10px; margin-top: 6px;
}
.subtask-add:focus { outline: none; border-color: var(--accent); }
.subtask-add::placeholder { color: var(--text-dim); }

.task-meta .subs-done { color: #4caf50; }

/* ===== Kuna V2: admin ===== */
.project-card-wrap { position: relative; }
.project-del {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--text-dim);
  font-size: 13px; cursor: pointer; border-radius: 4px; padding: 2px 6px;
  opacity: 0; transition: opacity 0.15s;
}
.project-card-wrap:hover .project-del { opacity: 1; }
.project-del:hover { color: var(--danger); background: var(--card); }

.admin-link {
  background: none; border: none; color: var(--text-dim); font-family: inherit;
  font-size: 12px; cursor: pointer; margin-top: 36px; letter-spacing: 1px;
}
.admin-link:hover { color: var(--text); }

/* ===== Kuna V2: landing modules ===== */
.modules { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 26px; }

.module-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 26px 30px; width: 280px; cursor: pointer; text-align: center;
  color: var(--text); font-family: inherit;
  transition: transform 0.12s, border-color 0.12s;
}
.module-card:hover:not(.disabled) { border-color: var(--accent); transform: translateY(-2px); }

.module-card-title { font-size: 24px; font-weight: 800; letter-spacing: 5px; }
.module-card-tagline {
  font-size: 11px; color: var(--text-dim); letter-spacing: 2px;
  text-transform: uppercase; margin-top: 4px;
}
.module-card-desc { font-size: 13px; color: var(--text-dim); margin-top: 14px; line-height: 1.5; }

.module-card.disabled { opacity: 0.55; cursor: default; }

/* ===== Kuna V3: subtasks as full tasks ===== */
.modal-tabs {
  display: flex; gap: 2px; padding: 0 16px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-tab {
  background: none; border: none; color: var(--text-dim); font-family: inherit;
  font-size: 13px; padding: 9px 12px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.modal-tab:hover { color: var(--text); }
.modal-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.parent-crumb {
  background: none; border: none; color: var(--text-dim); font-family: inherit;
  font-size: 12px; cursor: pointer; border-radius: 5px; padding: 4px 8px;
  max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 0;
}
.parent-crumb:hover { color: var(--accent); background: var(--card); }

.child-task {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; cursor: pointer; background: var(--card);
}
.child-task:hover { background: var(--card-hover); }
.child-title {
  flex: 1; font-size: 14px; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.child-task.done .child-title { text-decoration: line-through; color: var(--text-dim); }
.child-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; font-size: 12px; }
.child-due { color: var(--text-dim); }
.child-due.overdue { color: var(--danger); font-weight: 600; }
.child-dim { color: var(--text-dim); }

/* ===== Kuna V4: custom fields ===== */
.add-field-btn {
  background: none; border: 1px dashed var(--border); color: var(--text-dim);
  font-family: inherit; font-size: 12px; border-radius: 8px; padding: 5px 10px; cursor: pointer;
}
.add-field-btn:hover { color: var(--text); border-color: var(--text-dim); }
.editor-sep { border-bottom: 1px solid var(--border); margin: 10px 0; }

/* ===== Kuna V5: two-pane task window ===== */
.modal { width: 1000px; height: min(88vh, 780px); }

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

.modal-main { flex: 1; min-width: 0; overflow-y: auto; padding: 16px 20px; }
.modal-main::-webkit-scrollbar { width: 8px; }

.fieldbox-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  margin-bottom: 16px;
}
.fieldbox-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.fieldbox .field-select { width: 100%; min-width: 0; }
.fieldbox .field-control { width: 100%; }
.fieldbox .date-input { width: 100%; }

.add-checklist-btn {
  background: none; border: 1px dashed var(--border); color: var(--text-dim);
  font-family: inherit; font-size: 13px; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; margin-top: 10px; display: block;
}
.add-checklist-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* Comments panel */
.cpanel {
  width: 320px; min-width: 320px; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; background: var(--bg);
  border-radius: 0 14px 14px 0;
}
.cpanel.collapsed { width: 42px; min-width: 42px; }

.cpanel-strip {
  flex: 1; background: none; border: none; color: var(--text-dim);
  font-family: inherit; font-size: 13px; cursor: pointer;
  writing-mode: vertical-rl; text-orientation: mixed; letter-spacing: 2px;
  padding: 14px 0;
}
.cpanel-strip:hover { color: var(--text); background: var(--card); border-radius: 0 14px 14px 0; }

.cpanel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}

.cpanel-body { flex: 1; overflow-y: auto; padding: 10px 14px; min-height: 0; }
.cpanel .comment-form { padding: 10px 14px; }
.cpanel .comment-input { min-height: 48px; }

.activity-entry {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  padding: 6px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.activity-dot { color: var(--accent); }
.activity-date { margin-left: auto; }

@media (max-width: 900px) {
  .modal { width: calc(100vw - 16px); height: calc(100vh - 24px); }
  .modal-columns { flex-direction: column; overflow-y: auto; }
  .modal-main { overflow-y: visible; flex: none; }
  .cpanel, .cpanel.collapsed { width: 100%; min-width: 0; border-left: none; border-top: 1px solid var(--border); border-radius: 0 0 14px 14px; }
  .cpanel-strip { writing-mode: horizontal-tb; padding: 10px; }
}

/* ===== Kuna V5.1: dates section separated ===== */
.field-divider { border-bottom: 1px solid var(--border); margin: 6px 0 14px; }

/* ===== Kuna V6: dialogs, add-task menu, templates ===== */
.ui-dialog { width: 440px; }
.dialog-label { font-size: 13px; color: var(--text-dim); margin: 10px 0 6px; }
.dialog-label:first-child { margin-top: 0; }
.dialog-message { font-size: 14px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.settings-btn.danger-btn { background: var(--danger); }
.ui-dialog .field-select, .ui-dialog .modal-desc { width: 100%; }

.add-task-top {
  background: var(--accent); border: none; color: #fff;
  font-family: inherit; font-size: 13px; font-weight: 600;
  border-radius: 8px; padding: 7px 14px; cursor: pointer;
}
.add-task-top:hover { filter: brightness(1.1); }

.add-menu {
  position: fixed; z-index: 60; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); padding: 6px;
}
.add-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px; cursor: pointer; font-size: 14px;
}
.add-menu-item:hover { background: var(--card); }
.add-menu-icon { width: 18px; text-align: center; flex-shrink: 0; }
.add-menu-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-menu-sep { border-bottom: 1px solid var(--border); margin: 6px 4px; }
.tpl-action { opacity: 0; padding: 2px 5px; font-size: 12px; }
.add-menu-item:hover .tpl-action { opacity: 1; }

/* ===== Kuna V6.1: field management in project settings ===== */
.fields-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.fields-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card);
}
.fields-dots { display: flex; gap: 3px; flex-shrink: 0; min-width: 20px; }
.fields-dot { width: 9px; height: 9px; border-radius: 50%; }
.fields-name { flex: 1; font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fields-count { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.fields-btn { padding: 4px 10px; font-size: 12px; }
.fields-list .add-field-btn { align-self: flex-start; margin-top: 4px; }

/* ===== Kuna V6.2: task search ===== */
.search-input {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 13px; border-radius: 8px;
  padding: 7px 12px; width: 200px; min-width: 90px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.search-menu {
  position: fixed; z-index: 60; max-width: 420px; max-height: 50vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); padding: 6px;
}
.search-item { padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.search-item:hover, .search-item.active { background: var(--card); }
.search-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-parent { color: var(--text-dim); font-size: 12px; }
.search-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.search-empty { padding: 10px; font-size: 13px; color: var(--text-dim); }

@media (max-width: 700px) { .search-input { width: 120px; } }

/* ===== Kuna V7: task windows ===== */
.task-window {
  transform: none;
  top: auto; left: auto;
  animation: none;
  min-width: 320px;
  resize: none;
}
.tw-drag { cursor: move; }
.tw-drag button, .tw-drag select { cursor: pointer; }

.tw-resize {
  position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px;
  cursor: nwse-resize; border-radius: 0 0 12px 0;
  background:
    linear-gradient(135deg, transparent 0 50%, var(--border) 50% 60%, transparent 60% 70%, var(--border) 70% 80%, transparent 80%);
}

.taskbar {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 65; max-width: calc(100vw - 20px);
  overflow-x: auto; padding: 4px;
}
.taskbar-tab {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 8px 7px 14px; cursor: pointer; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); white-space: nowrap;
}
.taskbar-tab:hover { background: var(--card); }
.taskbar-title { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.taskbar-x { padding: 2px 6px; font-size: 12px; }

@media (max-width: 900px) {
  .task-window {
    left: 8px !important; top: 8px !important;
    width: calc(100vw - 16px) !important; height: calc(100vh - 16px) !important;
  }
  .tw-resize { display: none; }
  .tw-drag { cursor: default; }
}

/* ===== Kuna V7/F1: user accounts ===== */
.user-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 13px; border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis;
}
.user-btn:hover { border-color: var(--text-dim); }

.user-menu-who { padding: 8px 10px 4px; font-size: 14px; font-weight: 600; }
.user-menu-email { font-size: 12px; color: var(--text-dim); font-weight: 400; margin-top: 2px; }

.comment-as { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }

/* ===== Kuna V8/F2: members & assignee ===== */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  user-select: none;
}
.avatar.small { width: 20px; height: 20px; font-size: 9px; }
.assignee-control { display: flex; align-items: center; gap: 8px; }
.assignee-control .field-select { flex: 1; }

/* ===== Kuna V9/F3: user settings, roles, access mode ===== */
.toggle-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; padding: 6px 0; cursor: pointer;
}
.toggle-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.role-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 5px;
  padding: 2px 6px; flex-shrink: 0;
}

/* ===== Kuna V9.1: activity entries ===== */
.activity-body { flex: 1; min-width: 0; }

/* ===== Kuna V10: complete button in window header ===== */
.tw-complete { flex-shrink: 0; margin-right: 2px; }

/* ===== Kuna V10.1: header polish ===== */
.tw-complete {
  width: auto; border-radius: 14px; padding: 3px 12px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  display: inline-flex; align-items: center; white-space: nowrap;
}
.tw-complete:hover { color: #4caf50; }
.tw-complete.checked { color: #fff; }

.modal-actions .icon-btn { font-size: 16px; padding: 6px 10px; }
.icon-btn.tw-trash { color: var(--danger); font-size: 17px; }
.icon-btn.tw-trash:hover { background: rgba(214, 79, 79, 0.15); }

/* ===== Kuna V10.1: filter bar ===== */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 20px 0;
}
.fb-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  font-family: inherit; font-size: 12px; border-radius: 8px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.fb-btn:hover { color: var(--text); border-color: var(--text-dim); }
.fb-btn.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.fb-clear { color: var(--danger); }
.fb-clear:hover { color: var(--danger); border-color: var(--danger); }
.fb-select {
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  font-family: inherit; font-size: 12px; border-radius: 8px;
  padding: 6px 8px; cursor: pointer; max-width: 200px;
}
.fb-select.active { color: var(--text); border-color: var(--accent); }
