/* ═══════════════════════════════════════════════════════════
   HAPPY COUPLE DESIGN SYSTEM
   Light, Clean, Modern UI matching screenshots
   ═══════════════════════════════════════════════════════════ */

/* CSS VARIABLES FOR THEMING */
:root {
  --bg-primary: #E8EDF2;
  --bg-secondary: #FFFFFF;
  --text-primary: #2C3E50;
  --text-secondary: #6C757D;
  --text-muted: #9E9E9E;
  --border-color: #DEE2E6;
  --accent-color: #5B8DC5;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

body.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-muted: #707070;
  --border-color: #404040;
  --accent-color: #7BA8D9;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* RESET & GLOBAL STYLES */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Miui', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  padding-bottom: 80px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  transition: background 0.3s ease, color 0.3s ease;
  /* Xiaomi UI compatibility */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  max-width: 700px;
  margin: 0 auto;
  padding: 24px 20px;
  /* Safe area support for Xiaomi and other Android devices - EXTRA padding right for settings button */
  padding-left: max(20px, env(safe-area-inset-left, 20px));
  padding-right: max(40px, env(safe-area-inset-right, 40px)) !important;
  /* Don't hide overflow - let button be visible */
  box-sizing: border-box;
  width: 100%;
  position: relative;
}

/* TYPOGRAPHY */
h1 {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
}

h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

p {
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 12px;
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-color);
  opacity: 0.8;
}

/* BUTTONS */
button, .btn, input[type="submit"] {
  padding: 14px 24px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--accent-color);
  color: white;
  font-family: inherit;
}

button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(91, 141, 197, 0.3);
}

button:active, .btn:active {
  transform: translateY(0);
}

/* INPUTS */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s;
  margin-bottom: 12px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(91, 141, 197, 0.1);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* CARDS */
.card, [class*="card"] {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
}

/* LISTS */
ul, ol {
  list-style-position: inside;
  margin-bottom: 16px;
}

li {
  margin-bottom: 8px;
}

/* TABLES */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  padding: 14px;
  text-align: left;
  border-bottom: 1px solid #DEE2E6;
}

th {
  background: #F8F9FA;
  font-weight: 600;
  color: #2C3E50;
}

tr:last-child td {
  border-bottom: none;
}

/* FORMS */
form {
  margin-bottom: 24px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #2C3E50;
  margin-bottom: 8px;
}

/* BOTTOM NAVIGATION */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #DEE2E6;
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  padding-left: max(20px, env(safe-area-inset-left, 20px));
  padding-right: max(20px, env(safe-area-inset-right, 20px));
  display: flex;
  justify-content: space-around;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 1000;
}

.bottom-nav a,
.bottom-nav-item,
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #ADB5BD;
  text-decoration: none;
  font-size: 28px;
  padding: 10px;
  border-radius: 8px;
  transition: all 0.2s;
  position: relative;
}

.bottom-nav a:hover,
.bottom-nav-item:hover,
.nav-item:hover {
  background: #F8F9FA;
}

.bottom-nav a.active,
.bottom-nav-item.active,
.nav-item.active {
  color: #5B8DC5;
  background: #E7F3FF;
}

/* HEADER */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  /* Ensure button doesn't get cut off on small screens */
  padding-right: 0;
  margin-right: -8px; /* Negative margin to allow button to extend slightly */
  min-width: 0; /* Allow flex items to shrink */
  gap: 12px; /* Space between title and button */
  width: 100%;
  box-sizing: border-box;
  position: relative;
}

.profile-btn {
  width: 48px;
  height: 48px;
  min-width: 48px; /* Prevent shrinking */
  background: #4A6278;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0 !important; /* Prevent button from shrinking - force with !important */
  /* Safe area support - ensure button stays visible */
  margin-right: 0;
  position: relative;
  z-index: 10;
  /* Ensure button is fully visible even on edge of screen */
  right: 0;
}

/* FILTERS / PILLS */
.filters, .filter-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn, .filter-pill {
  padding: 8px 16px;
  border: none;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: #2C3E50;
  transition: all 0.2s;
}

.filter-btn.active, .filter-pill.active {
  background: #5B8DC5;
  color: white;
}

/* TASK CARDS */
.task-card {
  background: white;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.task-header {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.task-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.task-icon.orange { background: #FFB74D; }
.task-icon.green { background: #81C784; }
.task-icon.blue { background: #64B5F6; }

.task-title {
  font-size: 15px;
  font-weight: 600;
  color: #2C3E50;
  margin-bottom: 4px;
}

.task-meta {
  font-size: 12px;
  color: #6C757D;
}

.task-actions {
  display: flex;
  gap: 8px;
}

.task-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-skip {
  background: #FFB74D;
  color: white;
}

.btn-done {
  background: #81C784;
  color: white;
}

.btn-delete {
  background: #E57373;
  color: white;
  flex: 0;
  padding: 10px 16px;
}

.btn-delete-compact {
  background: #E57373;
  color: white;
  flex: 0;
  padding: 8px 12px;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* CALENDAR */
.calendar {
  margin-bottom: 24px;
}

.calendar-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 0;
}

.calendar-scroll::-webkit-scrollbar {
  display: none;
}

.calendar-day {
  flex-shrink: 0;
  width: 72px;
  text-align: center;
  cursor: pointer;
  padding: 12px 8px;
  border-radius: 12px;
  transition: all 0.2s;
  user-select: none;
}

.calendar-day:hover {
  background: rgba(91, 141, 197, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.calendar-day.today {
  background: #5B8DC5;
  color: white;
}

.day-name {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  margin-bottom: 8px;
  opacity: 0.8;
  pointer-events: none;
}

.day-number {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  pointer-events: none;
}

.day-dots {
  display: flex;
  gap: 4px;
  justify-content: center;
  min-height: 12px;
  pointer-events: none;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
}

.dot.green { background: #81C784; }
.dot.orange { background: #FFB74D; }
.dot.red { background: #E57373; }
.dot.blue { background: #3b82f6; }

/* STATS */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 24px;
}

.stat-number {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-number.red { color: #E57373; }
.stat-number.orange { color: #FFB74D; }

.stat-label {
  font-size: 15px;
  color: #6C757D;
  font-weight: 500;
}

/* DAILY BRIEF */
.brief-card {
  background: #C5D9EA;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 16px;
}

.brief-icon {
  width: 56px;
  height: 56px;
  background: #7B9CB8;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.brief-content h3 {
  font-size: 16px;
  font-weight: 700;
  color: #2C3E50;
  margin-bottom: 8px;
}

.brief-content p {
  font-size: 14px;
  color: #2C3E50;
  line-height: 1.5;
  margin-bottom: 8px;
}

.brief-link {
  color: #4A6278;
  font-size: 14px;
  text-decoration: none;
}

/* HISTORY */
.history-item {
  background: white;
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.history-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.history-icon.green { background: #C8E6C9; }
.history-icon.red { background: #FFCDD2; }
.history-icon.blue { background: #BBDEFB; }
.history-icon.orange { background: #FFE0B2; }
.history-icon.completed { background: #C8E6C9; }
.history-icon.pass { background: #FFE0B2; }
.history-icon.deleted { background: #FFCDD2; }
.history-icon.created { background: #BBDEFB; }

.history-title {
  font-size: 17px;
  font-weight: 700;
  color: #2C3E50;
  margin-bottom: 6px;
}

.history-meta {
  font-size: 14px;
  color: #6C757D;
}

/* ACTIVITY */
.activity-section h2 {
  font-size: 22px;
  font-weight: 700;
  color: #2C3E50;
  margin-bottom: 16px;
}

.activity-item {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.activity-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-dot.green { background: #28A745; }
.activity-dot.orange { background: #FD7E14; }

.activity-text {
  flex: 1;
  font-size: 14px;
  color: #2C3E50;
  font-weight: 500;
}

.activity-time {
  font-size: 12px;
  color: #6C757D;
}

/* ASSIGNED PILLS */
.assigned-section {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.assigned-pill {
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 600;
  background: white;
  color: #2C3E50;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.assigned-pill.active {
  background: #5B8DC5;
  color: white;
  border-color: #4A7DB0;
}

/* MESSAGES / CHAT */
.chat-container {
  height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 75%;
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
}

.chat-message-sent {
  align-self: flex-end;
  background: #5B8DC5;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message-received {
  align-self: flex-start;
  background: white;
  color: #2C3E50;
  border-bottom-left-radius: 4px;
}

.chat-input-container {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #DEE2E6;
  display: flex;
  gap: 12px;
}

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

.chat-input-container button {
  flex-shrink: 0;
  padding: 14px 20px;
}

/* UTILITIES */
.greeting {
  font-size: 26px;
  font-weight: 700;
  color: #2C3E50;
}

.completed-badge {
  display: inline-block;
  padding: 6px 12px;
  background: #C8E6C9;
  color: #2E7D32;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.task-title.done {
  text-decoration: line-through;
  color: #9E9E9E;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #6C757D;
  font-size: 16px;
}

/* ADD MODAL */
.add-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.add-modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 20px;
  width: min(380px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.add-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.add-modal-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #2C3E50;
  margin: 0;
}

.add-modal-close {
  background: none;
  border: none;
  font-size: 32px;
  color: #6C757D;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-modal-close:hover {
  color: #2C3E50;
}

.add-modal-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-card {
  background: #FFFFFF;
  border: 2px solid #5B8DC5;
  border-radius: 24px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 60px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  color: #000000 !important;
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.add-card::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(to top, rgba(0,0,0,0.1), transparent);
  pointer-events: none;
}

.add-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0.95;
}

.add-card-agenda {
  background: #FFFFFF !important;
  border: 2px solid #5B8DC5 !important;
  color: #000000 !important;
}

.add-card-agenda * {
  color: #000000 !important;
}

.add-card-task {
  background: #FFFFFF !important;
  border: 2px solid #5B8DC5 !important;
  color: #000000 !important;
}

.add-card-task * {
  color: #000000 !important;
}

.add-card-icon {
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.add-card-agenda .add-card-icon {
  background: #5B8DC5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
}

.add-card-task .add-card-icon {
  background: #10b981;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-card-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.add-card-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #000000 !important;
  line-height: 1.2;
}

.add-card-subtitle {
  font-size: 13px;
  font-weight: 400;
  margin: 0;
  color: #000000 !important;
  opacity: 1;
  line-height: 1.2;
}

.add-form {
  animation: fadeIn 0.3s ease;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #2C3E50;
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #E8EDF2;
  border-radius: 12px;
  font-size: 15px;
  color: #2C3E50;
  background: white;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #5B8DC5;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: #5B8DC5;
  color: white;
}

.btn-primary:hover {
  background: #4A7AB0;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(91, 141, 197, 0.3);
}

.btn-secondary {
  background: #E8EDF2;
  color: #6C757D;
}

.btn-secondary:hover {
  background: #D4DCE6;
  color: #2C3E50;
}

/* SHOPPING LIST */
.shopping-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: white;
  border-radius: 12px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.shopping-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.shopping-item.checked {
  opacity: 0.6;
}

.shopping-item.checked .item-name {
  text-decoration: line-through;
  color: #9E9E9E;
}

.shopping-item input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: #5B8DC5;
  flex-shrink: 0;
}

.shopping-item .item-name {
  flex: 1;
  font-size: 16px;
  font-weight: 500;
  color: #2C3E50;
}

.shopping-item .delete-btn {
  background: #E57373;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.shopping-item .delete-btn:hover {
  background: #D32F2F;
  transform: scale(1.05);
}

.add-form {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.add-form input {
  flex: 1;
  margin-bottom: 0;
}

.add-form .add-btn {
  background: #81C784;
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 20px;
  font-weight: 700;
  transition: all 0.2s;
  flex-shrink: 0;
}

.add-form .add-btn:hover {
  background: #66BB6A;
  transform: scale(1.05);
}

.clear-btn {
  background: #FFB74D;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 20px;
  transition: all 0.2s;
}

.clear-btn:hover {
  background: #FFA726;
  transform: translateY(-1px);
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.empty-text {
  font-size: 16px;
  color: #6C757D;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  h1 { font-size: 28px; }
  h2 { font-size: 20px; }
  
  main {
    padding: 20px 16px;
    padding-left: max(16px, env(safe-area-inset-left, 16px));
    /* EXTRA padding right to prevent settings button from being cut off on Xiaomi */
    padding-right: max(36px, env(safe-area-inset-right, 36px)) !important;
    width: 100%;
    box-sizing: border-box;
    position: relative;
  }
  
  .header {
    margin-right: -12px; /* More negative margin on mobile */
  }
  
  .stats {
    grid-template-columns: 1fr;
  }
  
  .header {
    flex-wrap: nowrap; /* Prevent wrapping on small screens */
    gap: 12px;
    padding-right: 0;
    width: 100%;
    box-sizing: border-box;
  }
  
  .header h1 {
    flex: 1;
    min-width: 0; /* Allow text to truncate if needed */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 0;
  }
  
  .profile-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-size: 22px;
    flex-shrink: 0;
    margin-right: 0;
  }
  
  .add-card {
    min-height: 60px;
    padding: 14px 18px;
  }
}

/* Specific fix ONLY for Xiaomi Redmi 13C (720px width) and similar devices */
@media (max-width: 750px) and (min-width: 700px) {
  main {
    /* Extra padding specifically for Xiaomi Redmi 13C (720px) */
    padding-right: max(52px, env(safe-area-inset-right, 52px)) !important;
  }
  
  .header {
    margin-right: -20px; /* More negative margin for Xiaomi */
  }
  
  .profile-btn {
    flex-shrink: 0 !important;
    z-index: 10;
    position: relative;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  main {
    padding: 16px 12px;
    padding-left: max(12px, env(safe-area-inset-left, 12px));
    /* EXTRA padding right for Xiaomi devices to prevent button cutoff - increased significantly */
    padding-right: max(32px, env(safe-area-inset-right, 32px)) !important;
    width: 100%;
    box-sizing: border-box;
    position: relative;
  }
  
  .header {
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    margin-right: -16px; /* Even more negative margin on extra small screens */
  }
  
  .profile-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-size: 20px;
    flex-shrink: 0 !important;
    margin-right: 0;
    z-index: 10;
  }
  
  .header h1 {
    font-size: 24px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .profile-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 20px;
    flex-shrink: 0;
    margin-right: 0;
  }
}
