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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --primary: #6c63ff;
  --primary-light: #8b83ff;
  --text: #e8e8e8;
  --text-dim: #8a8a9a;
  --idea: #6c63ff;
  --issue: #ff6b6b;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.screen { min-height: 100dvh; }
.hidden { display: none !important; }

/* Login */
.login-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100dvh; gap: 16px; padding: 24px;
}
.login-container h1 { font-size: 2.5rem; color: var(--primary); }
.subtitle { color: var(--text-dim); font-size: 1.1rem; margin-bottom: 32px; }
.btn-google {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; border-radius: var(--radius);
  border: none; background: #fff; color: #333;
  font-size: 1rem; font-weight: 500; cursor: pointer;
  transition: transform 0.1s;
}
.btn-google:active { transform: scale(0.97); }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; background: var(--surface);
}
header h1 { font-size: 1.3rem; color: var(--primary); }
.btn-icon {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 4px;
}

/* Type Selector (save target) */
.type-selector {
  display: flex; gap: 6px; padding: 12px 20px 0;
  align-items: center; flex-wrap: wrap;
}
.type-btn {
  padding: 6px 14px; border-radius: 20px;
  border: 1.5px solid #2a2a4a; background: transparent;
  color: var(--text-dim); font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.type-btn.active {
  border-color: var(--cat-color, var(--primary));
  color: var(--cat-color, var(--primary));
  background: rgba(108, 99, 255, 0.1);
}

/* Voice */
.voice-section {
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 20px 16px; gap: 12px;
}
.btn-voice {
  width: 80px; height: 80px; border-radius: 50%;
  border: none; background: var(--primary);
  color: #fff; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.btn-voice:active { transform: scale(0.95); }
.btn-voice.recording {
  background: var(--issue);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5); }
  50% { box-shadow: 0 0 0 16px rgba(255, 107, 107, 0); }
}
.voice-status { color: var(--text-dim); font-size: 0.85rem; }

/* Input */
.input-section { padding: 0 20px 16px; display: flex; flex-direction: column; gap: 12px; }
#text-input {
  width: 100%; padding: 14px; border-radius: var(--radius);
  border: 1px solid #2a2a4a; background: var(--surface);
  color: var(--text); font-size: 1rem; resize: none;
  font-family: inherit;
}
#text-input:focus { outline: none; border-color: var(--primary); }
.btn-row { display: flex; gap: 10px; }
.btn-save {
  flex: 1; padding: 14px; border-radius: var(--radius);
  border: none; background: var(--primary);
  color: #fff; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.btn-save:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-save:not(:disabled):active { transform: scale(0.98); }
.btn-ai-chat {
  padding: 14px 20px; border-radius: var(--radius);
  border: none; background: #4ecdc4;
  color: #fff; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.btn-ai-chat:active { transform: scale(0.98); }

/* Tabs */
.tabs {
  display: flex; gap: 0; padding: 16px 20px 0;
  border-bottom: 1px solid #2a2a4a;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 10px 14px; border: none; background: none;
  color: var(--text-dim); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s; white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Entries */
.entries-list { padding: 12px 20px; }
.empty-msg { text-align: center; color: var(--text-dim); padding: 32px 0; }
.entry-card {
  padding: 14px; margin-bottom: 10px;
  background: var(--surface); border-radius: var(--radius);
  border-left: 3px solid #6c63ff;
}
.entry-type {
  font-size: 0.75rem; font-weight: 600;
  margin-bottom: 6px;
}
.pri-badge {
  font-size: 0.65rem; padding: 1px 6px; border-radius: 8px;
  font-weight: 700; text-transform: uppercase; vertical-align: middle;
  margin-left: 4px;
}
.pri-high { background: #ff6b6b; color: #fff; }
.pri-medium { background: #f0a500; color: #1a1a2e; }
.pri-low { background: #444; color: var(--text-dim); }
.entry-content { font-size: 0.95rem; line-height: 1.5; margin-bottom: 8px; }
.entry-footer {
  display: flex; justify-content: space-between; align-items: center;
}
.entry-date { font-size: 0.75rem; color: var(--text-dim); }
.entry-actions { display: flex; gap: 8px; }
.btn-sm {
  padding: 4px 10px; border-radius: 6px; border: none;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
  transition: opacity 0.2s;
}
.btn-sm:active { opacity: 0.7; }
.btn-organize { background: #4ecdc4; color: #fff; }
.btn-delete { background: #444; color: var(--text-dim); }
.btn-edit { background: #2a2a4a; color: var(--text); }

/* Edit Dialog */
#edit-dialog { align-items: center; }
#edit-dialog .dialog { border-radius: 16px; max-height: 90vh; overflow-y: auto; }
.edit-body { padding: 16px 20px; }
.edit-body textarea {
  width: 100%; padding: 12px; border-radius: var(--radius);
  border: 1px solid #2a2a4a; background: var(--bg);
  color: var(--text); font-size: 0.95rem; resize: vertical;
  font-family: inherit; min-height: 100px;
}
.edit-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 12px;
}
.edit-fields label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.75rem; color: var(--text-dim);
}
.edit-fields select, .edit-fields input {
  padding: 8px; border-radius: 8px;
  border: 1px solid #2a2a4a; background: var(--bg);
  color: var(--text); font-size: 0.85rem;
  font-family: inherit;
}

.edit-danger-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid #2a2a4a;
}

/* Dialog */
.dialog-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 20px;
}
.dialog {
  background: var(--surface); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 500px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.dialog-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; font-weight: 600; font-size: 1.1rem;
  border-bottom: 1px solid #2a2a4a;
}
.dialog-header .btn-icon { font-size: 1.5rem; line-height: 1; }
.dialog-body {
  padding: 16px 20px; overflow-y: auto; flex: 1;
  font-size: 0.95rem; line-height: 1.6; white-space: pre-wrap;
}
.dialog-body .loading { color: var(--text-dim); text-align: center; padding: 20px; }
.dialog-input { padding: 0 20px 16px; }
.dialog-input textarea {
  width: 100%; padding: 12px; border-radius: var(--radius);
  border: 1px solid #2a2a4a; background: var(--bg);
  color: var(--text); font-size: 0.95rem; resize: none;
  font-family: inherit; margin-bottom: 8px;
}
.dialog-result { padding: 0 20px 16px; }
.dialog-label { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 8px; }
#dialog-organized {
  background: var(--bg); padding: 12px; border-radius: var(--radius);
  font-size: 0.9rem; line-height: 1.6; margin-bottom: 12px;
  max-height: 200px; overflow-y: auto; white-space: pre-wrap;
}
.dialog-actions { display: flex; gap: 8px; }
.dialog-actions .btn-save { flex: 1; }
.btn-cancel {
  flex: 1; padding: 14px; border-radius: var(--radius);
  border: 1px solid #2a2a4a; background: none;
  color: var(--text-dim); font-size: 1rem; cursor: pointer;
}

/* AI Chat */
.chat-dialog { max-height: 85vh; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 200px;
}
.chat-msg {
  max-width: 85%; padding: 10px 14px; border-radius: 12px;
  font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap;
}
.chat-msg.user {
  align-self: flex-end; background: var(--primary); color: #fff;
}
.chat-msg.ai {
  align-self: flex-start; background: #2a2a4a; color: var(--text);
}
.chat-msg.ai.thinking {
  color: var(--text-dim); font-style: italic;
}
.chat-action-bar {
  display: flex; gap: 8px; padding: 8px 20px;
  border-top: 1px solid #2a2a4a;
}
.chat-action-bar .btn-save,
.chat-action-bar .btn-cancel { flex: 1; padding: 12px; font-size: 0.9rem; }
.chat-input-area {
  display: flex; gap: 8px; padding: 12px 20px;
  border-top: 1px solid #2a2a4a;
}
.chat-input-area textarea {
  flex: 1; padding: 10px; border-radius: var(--radius);
  border: 1px solid #2a2a4a; background: var(--bg);
  color: var(--text); font-size: 0.9rem; resize: none;
  font-family: inherit;
}
.btn-chat-voice {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: var(--primary); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.btn-chat-voice.recording {
  background: var(--issue);
  animation: pulse 1.5s infinite;
}
.btn-chat-send {
  padding: 10px 16px; border-radius: var(--radius);
  border: none; background: #4ecdc4; color: #fff;
  font-weight: 600; cursor: pointer; white-space: nowrap;
}

/* View Switcher */
.view-switcher {
  display: flex; padding: 8px 20px 0; gap: 0;
  border-bottom: 2px solid #2a2a4a;
}
.view-btn {
  flex: 1; padding: 10px; border: none; background: none;
  color: var(--text-dim); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all 0.2s;
}
.view-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Task Sections (Vertical) */
.task-sections {
  padding: 10px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.task-section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 700;
  border-left: 4px solid;
}
.task-section-header.urgent {
  background: rgba(255, 107, 107, 0.1); border-color: #ff6b6b; color: #ff6b6b;
}
.task-section-header.in-progress {
  background: rgba(108, 99, 255, 0.1); border-color: var(--primary); color: var(--primary);
}
.task-section-header.todo {
  background: rgba(138, 138, 154, 0.1); border-color: var(--text-dim); color: var(--text-dim);
}
.task-section-header.done {
  background: rgba(0, 184, 148, 0.08); border-color: #00b894; color: #00b894;
}
.task-section-count {
  font-size: 0.7rem; background: #2a2a4a; color: var(--text-dim);
  padding: 1px 8px; border-radius: 10px;
}
.task-section-cards {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
  min-height: 20px; padding: 6px 0;
  border-radius: 8px; border: 2px dashed transparent;
  transition: border-color 0.2s, background 0.2s;
}
.task-section-cards .empty-msg { grid-column: 1 / -1; }
.task-section-cards.drag-over {
  border-color: var(--primary);
  background: rgba(108, 99, 255, 0.05);
  padding: 12px 4px; min-height: 50px;
}
.task-card {
  padding: 12px; background: var(--surface); border-radius: var(--radius);
  border-left: 3px solid #00b894;
  cursor: grab; touch-action: none;
  transition: opacity 0.2s, transform 0.2s;
}
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: 0.4; transform: scale(0.97); }
.task-card.urgent { border-left-color: #ff6b6b; }
.task-card.in_progress { border-left-color: var(--primary); }
.task-card.done { opacity: 0.5; }
.task-card.done .task-content { text-decoration: line-through; }
.task-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.task-id { font-size: 0.75rem; font-weight: 600; color: #00b894; }
.task-content { font-size: 0.9rem; line-height: 1.5; margin-bottom: 6px; }
.task-meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 6px;
}
.task-due {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 8px;
  background: #2a2a4a; color: var(--text-dim);
}
.task-due.overdue { background: rgba(255, 107, 107, 0.2); color: #ff6b6b; }
.task-due.soon { background: rgba(240, 165, 0, 0.2); color: #f0a500; }
.task-status-badge {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 8px;
  font-weight: 600;
}
.status-todo { background: #2a2a4a; color: var(--text-dim); }
.status-in_progress { background: rgba(108, 99, 255, 0.2); color: var(--primary); }
.status-done { background: rgba(0, 184, 148, 0.2); color: #00b894; }
.task-footer {
  display: flex; justify-content: space-between; align-items: center;
}
.task-actions { display: flex; gap: 6px; }
.btn-task-status {
  padding: 4px 10px; border-radius: 6px; border: none;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff;
}
.btn-task-status:active { opacity: 0.7; }
.btn-cal-sync {
  padding: 4px 10px; border-radius: 6px; border: none;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
  background: #4285F4; color: #fff;
}
.btn-cal-sync:active { opacity: 0.7; }
.btn-cal-sync.synced { background: #00b894; }

/* Highlighted entries (AI suggested for action) */
.entry-card.highlighted {
  background: rgba(255, 107, 107, 0.15);
  border-color: #ff6b6b;
  animation: highlight-pulse 1.5s ease-in-out infinite;
}
@keyframes highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.3); }
  50% { box-shadow: 0 0 0 4px rgba(255, 107, 107, 0); }
}
