/* ===== Base / Reset ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #0F172A;
  background: #F8FAFC;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ===== Layout (mobile-first) ===== */
.app {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 16px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.header {
  padding: 4px 2px 0;
}

.title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #0F172A;
}

.subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: #64748B;
}

/* ===== Submit card ===== */
.submit-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.submit-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.submit-textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  background: #F8FAFC;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.submit-textarea::placeholder {
  color: #94A3B8;
}

.submit-textarea:focus {
  border-color: #6366F1;
  background: #FFFFFF;
}

.submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.submit-hint {
  font-size: 12px;
  color: #94A3B8;
  flex: 1;
  min-width: 0;
}

.submit-btn {
  flex-shrink: 0;
  padding: 10px 18px;
  border-radius: 8px;
  background: #6366F1;
  color: #FFFFFF;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  min-width: 96px;
}

.submit-btn:hover {
  background: #4F46E5;
}

.submit-btn:active {
  transform: translateY(1px);
}

.submit-btn:disabled {
  background: #A5B4FC;
  cursor: not-allowed;
  opacity: 0.85;
}

.submit-btn .spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Filter tabs ===== */
.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 6px;
  margin: 0 -14px;
  padding-left: 14px;
  padding-right: 14px;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tab:hover {
  border-color: #CBD5E1;
}

.tab.is-active {
  background: #6366F1;
  border-color: #6366F1;
  color: #FFFFFF;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #E2E8F0;
  color: #475569;
  line-height: 1;
}

.tab.is-active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

.tab-badge--pending { background: #DBEAFE; color: #1D4ED8; }
.tab-badge--in_progress { background: #FEF3C7; color: #B45309; }
.tab-badge--completed { background: #D1FAE5; color: #047857; }
.tab-badge--failed { background: #FEE2E2; color: #B91C1C; }

/* ===== List ===== */
.list-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-error {
  padding: 16px;
  border-radius: 8px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  font-size: 13px;
  text-align: center;
}

/* ===== Todo card ===== */
.todo-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.todo-card:hover {
  border-color: #CBD5E1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.todo-card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
}

.todo-title {
  font-size: 15px;
  font-weight: 600;
  color: #0F172A;
  word-break: break-word;
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}

.todo-id {
  font-size: 12px;
  color: #94A3B8;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  margin-top: 2px;
}

.todo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: #64748B;
}

.todo-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.todo-error {
  margin-top: 2px;
  padding: 8px 10px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 6px;
  color: #B91C1C;
  font-size: 12px;
  word-break: break-word;
  line-height: 1.4;
}

/* ===== Status badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

.badge--pending {
  background: #DBEAFE;
  color: #1D4ED8;
}

.badge--in_progress {
  background: #FEF3C7;
  color: #B45309;
}

.badge--completed {
  background: #D1FAE5;
  color: #047857;
}

.badge--failed {
  background: #FEE2E2;
  color: #B91C1C;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: #94A3B8;
}

.empty-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.92);
  color: #FFFFFF;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.18);
  z-index: 1000;
  animation: toast-in 0.18s ease-out;
}

.toast--success { background: rgba(16, 185, 129, 0.95); }
.toast--error { background: rgba(239, 68, 68, 0.95); }
.toast--info { background: rgba(15, 23, 42, 0.92); }

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

/* ===== Loading skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, #F1F5F9 0%, #E2E8F0 50%, #F1F5F9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 4px;
  height: 12px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== PC layout (>= 768px) ===== */
@media (min-width: 768px) {
  body {
    background: #F1F5F9;
  }

  .app {
    max-width: 800px;
    padding: 28px 24px 48px;
    gap: 18px;
  }

  .title {
    font-size: 26px;
  }

  .subtitle {
    font-size: 14px;
  }

  .submit-card {
    padding: 18px;
  }

  .submit-textarea {
    min-height: 100px;
    font-size: 14px;
  }

  .filter-tabs {
    margin: 0;
    padding-left: 0;
    padding-right: 0;
    overflow-x: visible;
    flex-wrap: wrap;
  }

  .tab {
    padding: 8px 14px;
    font-size: 13px;
  }

  .todo-card {
    padding: 14px 18px;
  }

  .todo-title {
    font-size: 16px;
  }
}
