:root {
  color-scheme: dark;
  --bg: #0f0f1a;
  --panel: #1a1a2e;
  --accent: #7c5cff;
  --accent-hover: #6a4af0;
  --text: #f0f0f5;
  --muted: #9a9ab0;
  --danger: #ff6b6b;
  --ok: #4ade80;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(160deg, #0f0f1a 0%, #1a1030 100%);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

header h1 {
  margin: 0;
  font-size: 1.75rem;
}

.tagline {
  color: var(--muted);
  margin: 0.25rem 0 1.5rem;
}

.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

.hidden { display: none !important; }

input, textarea, button {
  font: inherit;
}

input, textarea {
  width: 100%;
  border: 1px solid #333355;
  background: #12121f;
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

textarea {
  resize: vertical;
  min-height: 6rem;
  line-height: 1.45;
}

button, .file-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 600;
}

button:hover:not(:disabled), .file-btn:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

button.secondary, .file-btn.secondary, .briefing-actions button {
  background: #2a2a44;
}

button.secondary:hover:not(:disabled),
.file-btn.secondary:hover,
.briefing-actions button:hover {
  background: #353555;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  font-size: 1.05rem;
  padding: 0.9rem 1rem;
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 1.02rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}

.btn-google:hover:not(:disabled) {
  background: #f2f2f2;
}

.btn-google-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #ea4335 50%, #fbbc05 85%, #34a853);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
}

.login-sub {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.85rem;
  line-height: 1.4;
}

.login-password-fallback {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-password-fallback summary {
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.login-password-fallback input,
.login-password-fallback button {
  margin-top: 0.35rem;
}

.btn-send {
  margin-top: 0.5rem;
}

.file-btn {
  display: inline-block;
  font-size: 0.9rem;
  flex: 1;
  text-align: center;
}

.hint-keys {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.4rem 0 0;
}

.attach-hint {
  color: var(--ok);
  font-size: 0.85rem;
  margin: -0.35rem 0 0.6rem;
}

.capture-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.assistant-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.5rem 0 1rem;
}

.assistant-card {
  display: block;
  width: 100%;
  text-align: left;
  background: #2a2a44;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-weight: 500;
}

.assistant-card strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.assistant-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.4;
}

.assistant-card:hover:not(:disabled) {
  background: #353555;
}

.btn-calendar {
  width: 100%;
  background: #2a2a44;
  margin-bottom: 0.75rem;
}

.btn-calendar:hover:not(:disabled) {
  background: #353555;
}

.btn-calendar.open {
  background: var(--accent);
}

.calendar-panel {
  margin-top: 0.25rem;
}

.calendar-view-toggle {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.view-toggle {
  flex: 1;
  background: #2a2a44;
  font-size: 0.85rem;
  padding: 0.5rem;
}

.view-toggle.active {
  background: var(--accent);
}

.week-grid .month-day {
  min-height: 3.2rem;
}

.week-grid .month-day .day-weekday {
  display: block;
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  line-height: 1;
}

.edit-card {
  max-height: 90vh;
  overflow-y: auto;
}

.edit-heading {
  margin: 0 0 0.75rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.35rem 0 0.25rem;
}

.edit-card input,
.edit-card textarea {
  margin-bottom: 0.35rem;
}

.edit-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.35rem 0 0.5rem;
}

.edit-check input {
  width: auto;
  margin: 0;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.month-label {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  text-transform: capitalize;
  flex: 1;
  text-align: center;
}

.month-nav-btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  background: #2a2a44;
  font-size: 1.35rem;
  line-height: 1;
  flex-shrink: 0;
}

.month-nav-btn:hover:not(:disabled) {
  background: #353555;
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
  margin-bottom: 0.35rem;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

.month-day {
  aspect-ratio: 1;
  min-height: 2.5rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #12121f;
  color: var(--text);
  padding: 0.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  position: relative;
  cursor: pointer;
}

.month-day.empty {
  background: transparent;
  border: none;
  cursor: default;
}

.month-day.today .day-num {
  color: #c4b5fd;
  font-weight: 700;
}

.month-day.selected {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.18);
}

.month-day.has-events .day-dot {
  display: inline-flex;
}

.month-day.has-open .day-dot {
  background: var(--accent);
}

.day-num {
  font-size: 0.85rem;
  line-height: 1;
}

.day-dot {
  display: none;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: #3b3b5c;
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.undated-toggle {
  width: 100%;
  background: #2a2a44;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
}

.undated-toggle.active {
  background: var(--accent);
}

.day-detail-title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}

#items-list li.calendar-day {
  display: none;
}

#items-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#items-list li {
  background: #12121f;
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.item-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

#items-list button.btn-item {
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

#items-list button.btn-item.done {
  background: var(--ok);
  color: #06210f;
}

#items-list button.btn-item.edit {
  background: #3b3b5c;
}

#items-list li.done {
  opacity: 0.55;
}

#items-list li.done .item-title {
  text-decoration: line-through;
}

.item-meta {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

#items-list li.conflict {
  border: 1px solid #f59e0b;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.25);
}

#items-list button.btn-item.move {
  background: #4a3b2a;
  color: #fde68a;
}

.btn-add-item {
  width: 100%;
  background: var(--accent);
  margin-bottom: 0.65rem;
}

.fab {
  position: fixed;
  right: 1rem;
  bottom: 1.25rem;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0;
  z-index: 30;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.fab.open {
  transform: rotate(45deg);
}

.fab-menu {
  position: fixed;
  right: 1rem;
  bottom: 4.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 30;
}

.fab-menu button {
  font-size: 0.85rem;
  text-align: left;
  white-space: nowrap;
}

.copilot-panel {
  margin: 0.5rem 0 1rem;
}

.btn-chat {
  width: 100%;
}

.chat-box {
  margin-top: 0.5rem;
  background: #12121f;
  border-radius: 12px;
  padding: 0.65rem;
}

.chat-box.open {
  min-height: 140px;
  border: 1px solid rgba(124, 92, 255, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.chat-messages {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.chat-msg {
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.chat-msg.user {
  background: #2a2a44;
  margin-left: 1.5rem;
}

.chat-msg.assistant {
  background: rgba(124, 92, 255, 0.2);
  margin-right: 1.5rem;
}

.chat-input-row {
  display: flex;
  gap: 0.35rem;
}

.chat-input-row input {
  margin: 0;
  flex: 1;
}

.chat-input-row button {
  flex-shrink: 0;
}

.insights-panel {
  background: #12121f;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.75rem;
}

.insights-text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.insights-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.insight-chip {
  background: rgba(124, 92, 255, 0.18);
  border: 1px solid rgba(124, 92, 255, 0.35);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  color: #ddd;
}

.routines-panel {
  background: #12121f;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.75rem;
}

.routines-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.routines-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.routines-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}

.routines-list li:last-child {
  border-bottom: none;
}

.small-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}

.series-scope-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.btn-danger {
  background: #8b2e2e;
  color: #fff;
  border: none;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
}

.item-series-badge {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.72rem;
  opacity: 0.75;
}

.hidden-field {
  display: none !important;
}

.integrations-panel {
  background: #12121f;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.75rem;
}

.integrations-header {
  margin-bottom: 0.65rem;
}

.integration-block {
  padding: 0.55rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.integration-block:first-of-type {
  border-top: none;
}

.integration-title {
  margin: 0 0 0.25rem;
  font-size: 0.92rem;
}

.integration-meta {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.integration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.integration-block input {
  margin-bottom: 0.35rem;
}

.accent-card {
  background: rgba(124, 92, 255, 0.15) !important;
  border: 1px solid rgba(124, 92, 255, 0.35);
}

.confirm-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

.confirm-list li {
  background: #12121f;
  border-radius: 10px;
  padding: 0.65rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
}

.confirm-list li span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.confirm-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.edit-card select {
  width: 100%;
  border: 1px solid #333355;
  background: #12121f;
  color: var(--text);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.35rem;
}

.empty-items {
  color: var(--muted);
  text-align: center;
  padding: 1rem 0.5rem;
  font-size: 0.95rem;
}

.error { color: var(--danger); }
.status {
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 1.25rem;
  margin: 0.5rem 0;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.status.busy { color: #c4b5fd; }

.briefing {
  background: #12121f;
  border-radius: 12px;
  padding: 1rem;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.5;
}

.push-panel {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(255, 193, 7, 0.08);
  border: 1px solid rgba(255, 193, 7, 0.35);
}

.push-panel.push-pulse {
  animation: pushPulse 1.4s ease-in-out 3;
}

@keyframes pushPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 4px rgba(255, 193, 7, 0.25); }
}

.btn-push {
  width: 100%;
  background: #f0b429;
  color: #1a1a2e;
  border: none;
  font-weight: 700;
}

.btn-push:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-push.active {
  background: var(--ok);
  color: #06210f;
}

.push-hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.45rem 0 0;
  line-height: 1.4;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.75rem;
}

.sheet-card {
  width: min(480px, 100%);
  background: var(--panel);
  border-radius: 20px 20px 16px 16px;
  padding: 0.85rem;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.45);
}

#camera-preview,
.camera-snapshot {
  width: 100%;
  max-height: 55vh;
  object-fit: cover;
  border-radius: 14px;
  background: #000;
  display: block;
}

.sheet-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
}

.sheet-actions button {
  flex: 1;
  min-width: 5.5rem;
}

.btn-shutter {
  background: #ef4444;
  flex: 1.4 !important;
}

.btn-shutter:hover:not(:disabled) {
  background: #dc2626;
}

.audio-card {
  text-align: center;
  padding: 1.25rem 1rem 1rem;
}

.audio-title {
  margin: 0;
  font-weight: 700;
}

.audio-timer {
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  margin: 0.75rem 0 0.35rem;
  color: var(--text);
}

.audio-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.btn-mic {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  font-size: 2rem;
  background: #ef4444;
  margin: 0 auto 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-mic:hover:not(:disabled) {
  background: #dc2626;
}

.btn-mic.recording {
  animation: pulse-mic 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55);
}

@keyframes pulse-mic {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  70% { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
