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

:root {
  --bg: #0E1824;
  --panel: #1A2632;
  --panel-2: #233140;
  --border: #2A3849;
  --text: #FFFFFF;
  --text-muted: #8A95A3;
  --accent: #F25C2A;
  --accent-hover: #FF6B35;
  --danger: #E74C3C;
  --radius: 14px;
  --radius-sm: 10px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100%;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: 64px;
  gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.logo {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.05s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
[hidden] { display: none !important; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: var(--panel); color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-record { background: var(--accent); color: white; }
.btn-record:hover { background: var(--accent-hover); }
.btn .btn-icon { width: 18px; height: 18px; flex-shrink: 0; display: block; }
.btn .btn-icon-sm { width: 14px; height: 14px; flex-shrink: 0; display: inline-block; vertical-align: -2px; margin-right: 4px; }
.btn-record .btn-icon {
  width: 26px;
  height: 26px;
  padding: 4px;
  background: #fff;
  color: var(--accent);
  border-radius: 50%;
  box-sizing: border-box;
}

.btn-user {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 10px 18px;
  letter-spacing: 0.2px;
}
.btn-user:hover { background: var(--accent-hover); }

.btn-icon {
  background: var(--panel);
  color: var(--text);
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 18px;
  justify-content: center;
}
.btn-icon:hover { background: var(--panel-2); color: var(--accent); }

.settings-title { font-size: 20px; margin-bottom: 8px; }
.settings-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.settings-textarea {
  width: 100%;
  min-height: 280px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}
.settings-textarea:focus { border-color: var(--accent); }
.settings-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}
.settings-counter { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.column-switcher { display: none; }
.mobile-dock { display: none; }

.board {
  display: flex;
  gap: 16px;
  padding: 24px;
  overflow-x: auto;
  height: calc(100vh - 64px);
  align-items: flex-start;
  scroll-snap-type: x mandatory;
}

.column {
  background: var(--panel);
  border-radius: var(--radius);
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  scroll-snap-align: start;
}

.column-header {
  padding: 16px 16px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.column-title-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.column-title { font-weight: 700; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.column-edit-btn, .col-pill-edit {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.column-edit-btn svg, .col-pill-edit svg { width: 13px; height: 13px; fill: currentColor; }
.column-edit-btn { opacity: 0; }
.column-header:hover .column-edit-btn { opacity: 0.7; }
.column-edit-btn:hover, .col-pill-edit:hover { opacity: 1; background: rgba(255,255,255,0.08); }

.column-rename-input {
  font-weight: 700;
  font-size: 15px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: inherit;
  outline: none;
  min-width: 0;
  flex: 1;
}
.column-count {
  background: var(--panel-2);
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}

.task-list {
  padding: 8px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
}

.task {
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: grab;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.task:hover { border-color: var(--accent); }
.task:active { cursor: grabbing; }
.task.sortable-ghost { opacity: 0.4; background: var(--accent); }

.task--transcribing {
  position: relative;
  border-color: var(--accent);
  overflow: hidden;
}
.task--transcribing .task-title {
  color: var(--text-muted);
  font-style: italic;
}
.task-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: progress-slide 1.4s linear infinite;
}
@keyframes progress-slide {
  0% { background-position: -50% 0; }
  100% { background-position: 150% 0; }
}
.task-loading {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-weight: 600;
}
.dot-pulse {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: rec-pulse 1s infinite;
}
.task--failed { border-color: rgba(231, 76, 60, 0.4); }
.task-failed-tag {
  color: var(--danger);
  font-style: italic;
}
.task-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  word-break: break-word;
}
.task-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}
.task-comments {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.add-task {
  margin: 4px 12px 12px;
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.add-task:hover { border-color: var(--accent); color: var(--accent); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-small { max-width: 400px; }

.modal-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

#taskModal.create-mode .comments,
#taskModal.create-mode #taskDelete,
#taskModal.create-mode #modalMeta { display: none; }
#taskModal:not(.create-mode) #modalTitle { display: none; }
#taskModal.create-mode .attachments-section { display: none; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.task-title-input,
#commentText,
#loginPass,
.login-select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
}
.task-title-input:focus,
#commentText:focus,
#loginPass:focus,
.login-select:focus { border-color: var(--accent); }

.task-title-input {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Tiptap editor */
.tiptap-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tiptap-toolbar button {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  min-width: 32px;
  transition: background 0.1s, color 0.1s;
}
.tiptap-toolbar button:hover { background: var(--panel); }
.tiptap-toolbar button.is-active { background: var(--accent); color: #fff; }
.tiptap-toolbar .sep { width: 1px; background: var(--border); margin: 0 4px; }

.task-desc-editor {
  margin-bottom: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  min-height: 200px;
}
.task-desc-editor .ProseMirror {
  padding: 14px 16px;
  outline: none;
  min-height: 200px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.task-desc-editor .ProseMirror p { margin: 0 0 8px; }
.task-desc-editor .ProseMirror p:last-child { margin-bottom: 0; }
.task-desc-editor .ProseMirror h1,
.task-desc-editor .ProseMirror h2,
.task-desc-editor .ProseMirror h3 {
  font-weight: 700;
  margin: 14px 0 6px;
  line-height: 1.25;
}
.task-desc-editor .ProseMirror h1 { font-size: 22px; }
.task-desc-editor .ProseMirror h2 { font-size: 18px; }
.task-desc-editor .ProseMirror h3 { font-size: 16px; }
.task-desc-editor .ProseMirror ul,
.task-desc-editor .ProseMirror ol { padding-left: 22px; margin: 0 0 8px; }
.task-desc-editor .ProseMirror li { margin-bottom: 2px; }
.task-desc-editor .ProseMirror blockquote {
  border-left: 3px solid var(--accent);
  margin: 8px 0;
  padding: 2px 12px;
  color: var(--text-muted);
}
.task-desc-editor .ProseMirror code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.task-desc-editor .ProseMirror pre {
  background: #282c34;
  color: #abb2bf;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  overflow-x: auto;
  margin: 8px 0;
}
.task-desc-editor .ProseMirror pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}
.task-desc-editor .ProseMirror a { color: var(--accent); text-decoration: underline; }
.task-desc-editor .ProseMirror img {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 12px auto;
  cursor: grab;
}
.task-desc-editor .ProseMirror img.ProseMirror-selectednode {
  outline: 2px solid var(--accent);
}
.task-desc-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
  height: 0;
  float: left;
}
.ProseMirror-dropcursor {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  height: 3px !important;
  border-radius: 2px;
}

/* markdown rendering for comments */
.markdown-body { line-height: 1.5; word-wrap: break-word; }
.markdown-body p { margin: 0 0 8px; }
.markdown-body p:last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin: 12px 0 6px;
  font-weight: 700;
}
.markdown-body h1 { font-size: 20px; }
.markdown-body h2 { font-size: 17px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body h4 { font-size: 14px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 8px; padding-left: 22px; }
.markdown-body li { margin-bottom: 2px; }
.markdown-body code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.markdown-body pre {
  background: #282c34;
  color: #abb2bf;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0 0 8px;
}
.markdown-body pre code { background: transparent; padding: 0; color: inherit; }
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 8px;
  padding: 2px 12px;
  color: var(--text-muted);
}
.markdown-body a { color: var(--accent); text-decoration: underline; }
.markdown-body a:hover { color: var(--accent-hover); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.markdown-body img { max-width: 100%; border-radius: 6px; }

/* Attachments */
.attachments-section {
  margin-bottom: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.attachments-section h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.attachments-grid:empty { display: none; }

.attachment {
  position: relative;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
}
.attachment img,
.attachment video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}
.attachment a {
  display: block;
  width: 100%;
  height: 100%;
}
.att-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.75);
  color: white;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}
.att-delete:hover { background: var(--danger); }
.att-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  color: white;
  font-size: 11px;
  padding: 12px 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.attachment.att-circle {
  background: transparent;
  overflow: visible;
}
.attachment.att-circle video {
  border-radius: 50%;
  width: 100%;
  height: 100%;
}
.attachment.att-circle .att-name { display: none; }
.attachment.att-circle .att-circle-hint {
  position: absolute;
  inset: auto 0 8% 0;
  text-align: center;
  font-size: 10px;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  pointer-events: none;
}
.attachment.att-circle.att-unmuted .att-circle-hint { display: none; }
.attachment.att-circle .att-delete {
  top: 6%;
  right: 6%;
}

.attachment.att-voice {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
}
.attachment.att-voice .voice-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.attachment.att-voice audio {
  flex: 1;
  height: 36px;
  background: transparent;
  width: 100%;
  display: block;
  object-fit: unset;
}
.attachment.att-voice .att-name { display: none; }
.attachment.att-voice .att-delete { position: static; flex-shrink: 0; }

.upload-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s;
  flex-wrap: wrap;
}
.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(242, 92, 42, 0.08);
}
.upload-hint { font-size: 12px; color: var(--text-muted); flex-shrink: 1; }

/* Recorder modals */
.circle-recorder-backdrop,
.voice-recorder-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.circle-recorder-backdrop.hidden,
.voice-recorder-backdrop.hidden { display: none; }

.circle-recorder,
.voice-recorder {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 340px;
  max-width: 90vw;
}
.circle-recorder-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.circle-recorder-header .modal-close { position: static; font-size: 24px; }

.circle-preview-wrap {
  width: 280px;
  height: 280px;
  border-radius: 50%;
  overflow: hidden;
  background: #000;
  position: relative;
  border: 3px solid var(--border);
  transition: border-color 0.15s;
}
.circle-preview-wrap.recording { border-color: var(--accent); }
.circle-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.circle-preview-wrap.playback .circle-preview { transform: none; }
.circle-preview.is-rear { transform: none; }

.circle-flip-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s;
}
.circle-flip-btn:hover { background: rgba(0, 0, 0, 0.85); }
.circle-flip-btn:active { transform: scale(0.92); }
.circle-preview-wrap.recording .circle-flip-btn,
.circle-preview-wrap.playback .circle-flip-btn { display: none; }

.circle-rec-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: var(--danger);
  border-radius: 50%;
  display: none;
  animation: rec-pulse 1s infinite;
}
.circle-preview-wrap.recording .circle-rec-dot { display: block; }
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.voice-visual {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.15s;
}
.voice-visual.recording { border-color: var(--accent); }
.voice-mic {
  font-size: 64px;
  transition: transform 0.05s ease-out;
}
.voice-visual.recording .voice-mic { animation: mic-pulse 1.5s ease-in-out infinite; }
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.voice-playback { width: 280px; max-width: 100%; }

.circle-timer {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.circle-controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.modal-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.comments h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.comment-list {
  margin-bottom: 12px;
  max-height: 250px;
  overflow-y: auto;
}
.comment {
  background: var(--panel-2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.comment-author {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.comment-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.15s;
}
.comment-delete:hover { color: var(--danger); }
.comment-text { font-size: 13px; word-break: break-word; }
.comment-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.comment-empty { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

.comment-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.comment-form textarea { min-height: 60px; }
.comment-form button { align-self: flex-end; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

#loginModal .modal-small {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 24px;
}
#loginModal h2 { font-size: 22px; margin: 0; }
.login-logo {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: -1px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 4px;
}
.login-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 4px;
}
.login-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
  cursor: pointer;
}
.login-error {
  background: rgba(231, 76, 60, 0.12);
  border: 1px solid rgba(231, 76, 60, 0.45);
  color: #ff8474;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
}
#loginBtn { width: 100%; padding: 12px; font-size: 15px; }

.perm-help {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.perm-help.visible {
  opacity: 1;
  pointer-events: auto;
}
.perm-help-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.perm-help-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.perm-help-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 20px;
}
.perm-help-close {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.mit-toast {
  position: fixed;
  bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 30, 45, 0.96);
  color: #fff;
  padding: 12px 18px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  max-width: 90vw;
  text-align: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.mit-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ---------------- Mobile ---------------- */
@media (max-width: 768px) {
  body { display: flex; flex-direction: column; }
  .topbar {
    padding: 10px 12px;
    height: 56px;
    gap: 6px;
    flex: 0 0 56px;
  }
  .logo { font-size: 22px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn {
    padding: 8px 10px;
    font-size: 13px;
  }
  .top-record-btn .btn-label { display: none; }
  .top-record-btn { padding: 8px 10px; }
  .top-record-btn .btn-icon { width: 22px; height: 22px; }

  .btn-user {
    padding: 8px 12px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .column-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .column-switcher button {
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--panel);
    color: var(--text-muted);
    border: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .column-switcher button .col-pill-count {
    background: var(--panel-2);
    color: var(--text-muted);
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
  }
  .column-switcher button.active {
    background: var(--accent);
    color: #fff;
  }
  .column-switcher button.active .col-pill-count {
    background: rgba(255,255,255,0.22);
    color: #fff;
  }

  .board {
    padding: 12px;
    gap: 12px;
    height: auto;
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    padding-bottom: 88px;
  }

  /* Mobile dock — TG-style input bar */
  .topbar .top-record-btn { display: none; }
  .mobile-dock {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--border);
    z-index: 50;
  }
  .mobile-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    background: var(--panel);
    border-radius: 22px;
    padding: 4px;
    min-height: 48px;
  }
  .dock-icon-btn {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s, transform 0.05s;
    -webkit-tap-highlight-color: transparent;
  }
  .dock-icon-btn:active { transform: scale(0.92); }
  .dock-icon-btn svg { width: 22px; height: 22px; fill: currentColor; pointer-events: none; }
  .dock-attach-btn { color: var(--text-muted); }
  .dock-attach-btn:hover, .dock-attach-btn:active { color: var(--text); background: var(--panel-2); }
  .dock-record-btn {
    background: var(--accent);
    color: #fff;
    touch-action: none; /* hold-to-record не должен скроллить страницу */
    user-select: none;
    -webkit-user-select: none;
    position: relative;
  }
  .dock-record-btn:hover { background: var(--accent-hover); }
  .dock-record-btn:disabled { opacity: 0.5; }
  .dock-record-btn .rec-icon-mic,
  .dock-record-btn .rec-icon-circle { width: 22px; height: 22px; }
  /* По умолчанию показываем mic, скрываем circle */
  .dock-record-btn .rec-icon-circle { display: none; }
  .dock-record-btn[data-mode="circle"] .rec-icon-mic { display: none; }
  .dock-record-btn[data-mode="circle"] .rec-icon-circle { display: block; }
  /* Анимация переключения режима */
  .dock-record-btn.is-mode-switching {
    animation: rec-mode-flip 0.3s ease;
  }
  @keyframes rec-mode-flip {
    0% { transform: scale(1) rotate(0); }
    50% { transform: scale(0.7) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
  }
  /* Визуальный feedback во время удержания */
  .dock-record-btn.is-holding {
    transform: scale(1.25);
    box-shadow: 0 0 0 8px rgba(242, 92, 42, 0.25);
  }
  .dock-record-btn.is-holding.is-locked {
    background: #1f9b4a; /* зелёный — режим блокировки, отпусти и продолжай */
    transform: scale(1.15);
  }
  .dock-record-btn.is-holding.is-cancelled {
    background: var(--danger);
    transform: scale(1);
    opacity: 0.7;
  }
  .dock-send-btn {
    background: var(--accent);
    color: #fff;
  }
  .dock-send-btn:hover { background: var(--accent-hover); }
  .dock-send-btn svg { width: 20px; height: 20px; transform: translateX(1px); }
  .dock-input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 10px 6px;
    font-size: 16px; /* >=16px чтобы iOS не зумил при фокусе */
    font-family: inherit;
    outline: none;
    resize: none;
    min-height: 40px;
    max-height: 140px;
    line-height: 1.3;
    overflow-y: auto;
  }
  .dock-input::placeholder { color: var(--text-muted); opacity: 0.8; }

  /* ===== TG-style голосовое: bar поверх input bar ===== */
  .voice-rec-bar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    height: 56px;
    background: var(--panel);
    border-radius: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 6px;
    z-index: 100;
    animation: rec-slide-up 0.18s ease-out;
  }
  @keyframes rec-slide-up {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  .voice-rec-cancel, .voice-rec-send {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s, transform 0.05s;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
  }
  .voice-rec-cancel svg, .voice-rec-send svg {
    width: 22px; height: 22px; pointer-events: none;
  }
  .voice-rec-cancel:hover { background: rgba(231,76,60,0.12); color: var(--danger); }
  .voice-rec-send {
    background: var(--accent);
    color: #fff;
  }
  .voice-rec-send:hover { background: var(--accent-hover); }
  .voice-rec-info {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
  }
  .voice-rec-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--danger);
    animation: rec-pulse 1s infinite;
    flex-shrink: 0;
  }
  @keyframes rec-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.15); }
  }
  .voice-rec-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
    font-size: 15px;
    flex-shrink: 0;
  }
  .voice-rec-hint {
    color: var(--text-muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s;
  }
  .voice-rec-bar.is-cancel-armed { background: rgba(231,76,60,0.15); }
  .voice-rec-bar.is-cancel-armed .voice-rec-hint { color: var(--danger); }
  .voice-rec-bar.is-lock-armed .voice-rec-hint { color: #1f9b4a; }

  /* ===== TG-style кружок: fullscreen ===== */
  .circle-rec-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.94);
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
    animation: rec-fade-in 0.15s ease-out;
  }
  @keyframes rec-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  .circle-rec-stage {
    position: relative;
    width: 80vw;
    max-width: 320px;
    aspect-ratio: 1;
    margin-bottom: 28px;
  }
  .circle-rec-frame {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 60px rgba(242, 92, 42, 0.3);
    transition: box-shadow 0.2s;
  }
  .circle-rec-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* зеркалим как в TG для фронталки */
  }
  .circle-rec-video.is-rear { transform: none; }
  .circle-rec-flip {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    color: #0E1824;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  .circle-rec-flip svg { width: 22px; height: 22px; pointer-events: none; }

  /* Таймер + Отмена (как в TG) */
  .circle-rec-meta {
    color: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
  }
  .circle-rec-meta .circle-rec-dot {
    display: inline-block;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--danger);
    animation: rec-pulse 1s infinite;
  }
  .circle-rec-timer {
    font-size: 19px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #fff;
  }
  .circle-rec-cancel-text {
    background: none;
    border: none;
    color: #4aa8ff;
    font-size: 17px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    padding: 8px 12px;
    -webkit-tap-highlight-color: transparent;
    margin-left: 8px;
  }
  .circle-rec-cancel-text:active { opacity: 0.7; }

  /* Большая кнопка отправки снизу справа (как в TG) */
  .circle-rec-send-fab {
    position: absolute;
    right: 24px;
    bottom: calc(28px + env(safe-area-inset-bottom));
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #2196F3;
    border: none;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(33, 150, 243, 0.5);
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, box-shadow 0.15s;
  }
  .circle-rec-send-fab:active { transform: scale(0.94); }
  .circle-rec-send-fab svg { width: 28px; height: 28px; pointer-events: none; }

  .circle-rec-hint { display: none; }

  /* Hint цвет при свайп-армировании (визуальная подсказка) */
  .circle-rec-overlay.is-cancel-armed .circle-rec-frame { box-shadow: 0 0 60px rgba(231,76,60,0.6); }
  .circle-rec-overlay.is-lock-armed .circle-rec-frame { box-shadow: 0 0 60px rgba(74,222,128,0.6); }

  /* Прячем mobile-dock когда идёт запись кружка — чтобы не перекрывало */
  body.is-recording-circle .mobile-dock { display: none; }
  .column {
    width: 100%;
    max-width: 100%;
    display: none;
  }
  .column.is-active { display: flex; }
  .column .column-header { display: none; }
  .column .add-task { display: none; }

  .column-switcher .col-pill-edit { display: none; }
  .column-switcher button.active .col-pill-edit { display: inline-flex; }

  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal {
    border-radius: 0;
    padding: 18px;
    max-width: 100%;
    max-height: 100vh;
    height: 100%;
  }
  .modal-small { border-radius: var(--radius); height: auto; }
  #loginModal { padding: 16px; align-items: center; }

  .task-title-input { font-size: 17px; padding: 10px; }

  .tiptap-toolbar { overflow-x: auto; flex-wrap: nowrap; }
  .tiptap-toolbar button { font-size: 12px; padding: 6px 8px; }

  .upload-area { padding: 10px; gap: 6px; }
  .upload-hint { font-size: 11px; flex-basis: 100%; }

  .attachments-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 6px;
  }

  .circle-recorder, .voice-recorder {
    padding: 16px;
    min-width: 0;
    width: 100%;
    max-width: 360px;
  }
  .circle-preview-wrap { width: 220px; height: 220px; }
  .voice-visual { width: 160px; height: 160px; }
  .voice-mic { font-size: 52px; }
  .circle-timer { font-size: 16px; }
  .circle-controls .btn { padding: 10px 14px; font-size: 13px; }

  .modal-actions { flex-wrap: wrap; }

  .comment-list { max-height: 180px; }
}

@media (max-width: 380px) {
  .upload-area .btn { padding: 8px 10px; font-size: 12px; }
  .circle-preview-wrap { width: 180px; height: 180px; }
}
