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

:root {
  --bg: #1a2a3a;
  --column-bg: #1e3a52;
  --column-header-bg: #2a4a62;
  --card-bg: #ffffff;
  --card-border: #d0d8e0;
  --text-primary: #1a2a3a;
  --text-secondary: #4a6a8a;
  --text-muted: #8aaccc;
  --accent: #e07a3a;
  --accent-hover: #c86428;
  --danger: #c0392b;
  --danger-hover: #a93226;
  --radius: 8px;
  --column-width: 320px;
}

body {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

/* ===== AUTH ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  background: #1e3a52;
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: #e0ecf8;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.auth-title span { color: var(--accent); }

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid #2a4a62;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-field { margin-bottom: 14px; }

.auth-field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  background: #122030;
  border: 1px solid #2a4a62;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 16px;
  color: #e0ecf8;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.auth-field input:focus { border-color: var(--accent); }

.auth-submit {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}

.auth-submit:hover { background: var(--accent-hover); }

.auth-error {
  font-size: 13px;
  color: #e07070;
  margin-top: 12px;
  text-align: center;
  min-height: 20px;
}

/* ===== APP ===== */
.app-wrap { display: none; }

header {
  background: #122030;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2a4a62;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #e0ecf8;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
}

header h1 span { color: var(--accent); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
}

.breadcrumb-sep { color: #2a4a62; }

.breadcrumb-current {
  color: #e0ecf8;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.back-btn {
  background: transparent;
  border: 1px solid #2a4a62;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.back-btn:hover { border-color: var(--accent); color: var(--accent); }

.username-label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.logout-btn {
  background: transparent;
  border: 1px solid #2a4a62;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}

.logout-btn:hover { border-color: var(--danger); color: var(--danger); }

.header-action-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}

.header-action-btn:hover { background: var(--accent-hover); }

@media (max-width: 600px) {
  header { padding: 10px 12px; gap: 6px; }
  header h1 { font-size: 16px; }
  .username-label { display: none; }
  .back-btn { padding: 6px 8px; font-size: 12px; }
  .logout-btn { padding: 6px 8px; font-size: 12px; }
  .header-action-btn { padding: 6px 10px; font-size: 12px; }
  .breadcrumb-current { max-width: 80px; }
}

/* ===== TOP ===== */
.top-view { padding: 32px 24px 40px; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--column-bg);
  border-radius: 12px;
  padding: 24px 20px 20px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}

.category-card:hover { border-color: var(--accent); background: #243e56; }

.category-card-name {
  font-size: 16px;
  font-weight: 600;
  color: #e0ecf8;
  flex: 1;
}

.category-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.category-card-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.category-card-meta-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.category-card-meta-count {
  white-space: nowrap;
  color: var(--accent);
  font-weight: 500;
}

.category-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

.category-edit-btn, .category-delete-btn {
  background: transparent;
  border: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.category-edit-btn { color: var(--text-muted); }
.category-edit-btn:hover { background: rgba(255,255,255,0.1); color: #e0ecf8; }
.category-delete-btn { color: var(--text-muted); }
.category-delete-btn:hover { background: rgba(192,57,43,0.2); color: var(--danger); }

.add-category-card {
  background: transparent;
  border: 2px dashed rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 24px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255,255,255,0.3);
  font-size: 14px;
  min-height: 120px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.add-category-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(224,122,58,0.06);
}

/* ===== BOARD ===== */
.board-view { display: none; }

.board {
  display: flex;
  gap: 16px;
  padding: 20px 24px 40px;
  overflow-x: auto;
  min-height: calc(100vh - 57px);
  align-items: flex-start;
}

.column {
  max-width: var(--column-width);
  background: var(--column-bg);
  border-radius: 12px;
  width: var(--column-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.column-header {
  background: var(--column-header-bg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: #e0ecf8;
  background: transparent;
  border: none;
  outline: none;
  cursor: text;
  min-width: 0;
}

.column-name:focus {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 2px 6px;
}

.delete-column-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.delete-column-btn:hover { color: var(--danger); background: rgba(192,57,43,0.15); }

.cards-container {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.card-body { padding: 10px 12px 6px; }

.card-text {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 40px;
  outline: none;
  cursor: text;
}

.card-text:empty::before { content: 'メモを入力...'; color: #aaa; pointer-events: none; }

.card-footer {
  padding: 4px 8px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-date { font-size: 11px; color: var(--text-muted); }

.delete-card-btn {
  background: transparent;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.delete-card-btn:hover { color: var(--danger); background: rgba(192,57,43,0.1); }

.add-card-area { padding: 0 10px 12px; }

.add-card-btn {
  width: 100%;
  background: transparent;
  border: 1.5px dashed rgba(255,255,255,0.15);
  border-radius: var(--radius);
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.add-card-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(224,122,58,0.08); }
.add-card-btn .plus-icon { font-size: 18px; font-weight: 300; line-height: 1; }

.empty-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: rgba(255,255,255,0.3);
  gap: 12px;
  padding: 60px 0;
  text-align: center;
}

.empty-board .icon { font-size: 48px; opacity: 0.4; }
.empty-board p { font-size: 14px; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.modal h2 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 16px; }

.modal input[type="text"] {
  width: 100%;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.modal input[type="text"]:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.btn-cancel {
  background: #f0f0f0;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  color: #555;
  transition: background 0.15s;
}

.btn-cancel:hover { background: #e0e0e0; }

.btn-confirm {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-confirm:hover { background: var(--accent-hover); }

.confirm-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.confirm-modal.active { display: flex; }
.confirm-modal .modal p { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; }

.btn-danger {
  background: var(--danger);
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover { background: var(--danger-hover); }

/* ===== DRAG AND DROP ===== */
.card-drag-handle {
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px 8px 0;
  cursor: grab;
  user-select: none;
  line-height: 1;
}

.card-drag-handle:active { cursor: grabbing; }

.column-drag-handle {
  color: rgba(255,255,255,0.3);
  font-size: 16px;
  cursor: grab;
  user-select: none;
  padding: 0 4px;
  flex-shrink: 0;
}

.column-drag-handle:active { cursor: grabbing; }

.drop-indicator {
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  margin: 4px 0;
  opacity: 0.8;
}

.drop-indicator-column {
  width: 4px;
  min-height: 200px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
  opacity: 0.8;
}

.card.dragging { opacity: 0.3; }
