:root {
  --ios-blue: #007AFF;
  --ios-red: #FF3B30;
  --ios-green: #34C759;
  --ios-orange: #FF9500;
  --ios-purple: #AF52DE;
  --ios-gray: #8E8E93;
  --ios-gray2: #AEAEB2;
  --ios-gray3: #C7C7CC;
  --ios-gray4: #D1D1D6;
  --ios-gray5: #E5E5EA;
  --ios-gray6: #F2F2F7;
  --ios-bg: #F2F2F7;
  --ios-card-bg: #FFFFFF;
  --ios-text: #000000;
  --ios-text-secondary: #3C3C43;
  --ios-text-tertiary: #8E8E93;
  --ios-separator: #C6C6C8;
  --ios-nav-height: 56px;
  --ios-bottom-height: 120px;
  --ios-safe-bottom: 20px;
  --ios-corner-radius: 13px;
  --ios-corner-radius-lg: 16px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif;
  background: var(--ios-bg);
  color: var(--ios-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ios-bg);
  z-index: 1;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}

.view.active {
  display: flex;
  z-index: 2;
}

.view.slide-left {
  transform: translateX(-100%);
}

.view.slide-right {
  transform: translateX(100%);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--ios-nav-height);
  padding: 0 16px;
  background: rgba(242, 242, 247, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--ios-separator);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.nav-title {
  font-size: 17px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  flex: 1;
  margin-left: 8px;
}

.nav-app-icon {
  width: 20px;
  height: 20px;
  margin-right: 4px;
  vertical-align: middle;
  border-radius: 4px;
}

.nav-btn {
  background: none;
  border: none;
  font-size: 22px;
  padding: 8px;
  cursor: pointer;
  color: var(--ios-blue);
  z-index: 1;
  line-height: 1;
}

.nav-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.hamburger-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  position: relative;
  z-index: 101;
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ios-blue);
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s;
  transform-origin: center;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: -4px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.06);
  min-width: 200px;
  overflow: hidden;
  z-index: 100;
  transform-origin: top right;
  animation: dropdownIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -5px;
  right: 13px;
  width: 10px;
  height: 10px;
  background: rgba(255,255,255,0.97);
  transform: rotate(45deg);
  border-radius: 2px;
  box-shadow: -2px -2px 8px rgba(0,0,0,0.06);
}

@keyframes dropdownIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 18px;
  border: none;
  background: none;
  font-size: 16px;
  color: var(--ios-text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}

.dropdown-item:active {
  background: var(--ios-gray5);
}

.dropdown-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.dropdown-divider {
  height: 0.5px;
  background: var(--ios-separator);
  margin: 0 18px;
}

.nav-spacer {
  min-width: 40px;
}

.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
}


.content-form {
  padding-bottom: 32px;
}

.bottom-bar {
  flex-shrink: 0;
  background: rgba(242, 242, 247, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--ios-separator);
  padding: 8px 16px calc(var(--ios-safe-bottom) + 8px);
  z-index: 10;
}

.totals {
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  margin-bottom: 8px;
}

.total-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.total-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ios-text);
}

.total-label {
  font-size: 11px;
  color: var(--ios-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.action-buttons {
  display: flex;
  gap: 12px;
}

.btn-action {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--ios-corner-radius);
  font-size: 16px;
  font-weight: 600;
  background: var(--ios-card-bg);
  color: var(--ios-text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-action:active {
  transform: scale(0.97);
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

.btn-action-primary {
  background: var(--ios-blue);
  color: white;
}

.btn-action-icon {
  font-size: 20px;
}

.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--ios-corner-radius);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s, opacity 0.15s;
  margin-top: 12px;
}

.btn:active {
  transform: scale(0.98);
  opacity: 0.85;
}

.btn-primary {
  background: var(--ios-blue);
  color: white;
}

.btn-secondary {
  background: var(--ios-card-bg);
  color: var(--ios-blue);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-row .btn {
  margin-top: 0;
}

.btn-mic {
  width: 52px;
  flex-shrink: 0;
  font-size: 22px;
  background: var(--ios-card-bg);
  border: 0.5px solid var(--ios-separator);
  padding: 14px 0;
  border-radius: var(--ios-corner-radius);
}

.meal-info {
  flex: 1;
  min-width: 0;
  padding-left: 16px;
}

.meal-description {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.meal-time {
  font-size: 13px;
  color: var(--ios-text-tertiary);
}

.meal-nutrition {
  text-align: right;
  flex-shrink: 0;
  padding-right: 16px;
}

.meal-calories {
  font-size: 18px;
  font-weight: 700;
  color: var(--ios-orange);
}

.meal-bju {
  font-size: 12px;
  color: var(--ios-text-tertiary);
  margin-top: 2px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

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

.empty-state p {
  font-size: 17px;
  color: var(--ios-text-secondary);
  margin-bottom: 4px;
}

.empty-hint {
  font-size: 14px;
  color: var(--ios-text-tertiary);
}

.form-section {
  background: var(--ios-card-bg);
  border-radius: var(--ios-corner-radius-lg);
  overflow: hidden;
  margin-top: 8px;
}

.form-group {
  padding: 10px 16px 14px;
  border-bottom: 0.5px solid var(--ios-separator);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-group:last-child {
  border-bottom: none;
}

.form-label {
  font-size: 16px;
  color: var(--ios-text);
  font-weight: 400;
  margin: 0;
  flex-shrink: 0;
}

.form-input {
  width: auto;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--ios-text);
  background: transparent;
  padding: 0;
  font-family: inherit;
  text-align: right;
}

.form-input::placeholder {
  color: var(--ios-gray3);
  text-align: right;
}

.stepper-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--ios-gray4);
  border-radius: 8px;
  overflow: hidden;
}

.stepper-input {
  text-align: center;
  flex: 1;
  width: 60px;
  padding: 6px 0;
  font-size: 17px;
  font-weight: 600;
}

.stepper-btn {
  width: 44px;
  height: 40px;
  border: none;
  background: var(--ios-gray6);
  font-size: 24px;
  font-weight: 600;
  color: var(--ios-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s;
}

.stepper-btn:active {
  background: var(--ios-gray4);
}

.stepper-btn:first-child {
  border-right: 1px solid var(--ios-gray4);
}

.stepper-btn:last-child {
  border-left: 1px solid var(--ios-gray4);
}

.form-select {
  max-width: 60%;
  appearance: none;
  -webkit-appearance: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238E8E93' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 4px center;
  padding-right: 24px;
  cursor: pointer;
}

.form-textarea {
  width: 100%;
  border: none;
  outline: none;
  font-size: 17px;
  color: var(--ios-text);
  background: var(--ios-card-bg);
  border-radius: var(--ios-corner-radius-lg);
  padding: 16px;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  margin-top: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.form-textarea::placeholder {
  color: var(--ios-gray3);
}

.norm-result {
  background: var(--ios-card-bg);
  border-radius: var(--ios-corner-radius-lg);
  padding: 16px;
  margin-top: 12px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.norm-result .norm-calories {
  font-size: 36px;
  font-weight: 800;
  color: var(--ios-blue);
  display: block;
}

.norm-result .norm-label {
  font-size: 14px;
  color: var(--ios-text-tertiary);
  margin-top: 4px;
  display: block;
}

.norm-result .norm-explanation {
  font-size: 13px;
  color: var(--ios-text-tertiary);
  margin-top: 8px;
  line-height: 1.4;
}

.norm-details {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.norm-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  line-height: 1.5;
}

.norm-detail-label {
  color: var(--ios-text-tertiary);
  text-align: left;
}

.norm-detail-value {
  color: var(--ios-text-secondary);
  font-weight: 500;
  text-align: right;
  max-width: 60%;
}

.camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
}

.camera-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.camera-placeholder {
  text-align: center;
  color: rgba(255,255,255,0.6);
}

.camera-placeholder-icon {
  font-size: 72px;
  margin-bottom: 12px;
}

.camera-placeholder-text {
  font-size: 15px;
  line-height: 1.4;
}

.camera-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.camera-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 30px calc(var(--ios-safe-bottom) + 20px);
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
}

.camera-btn-back {
  color: white !important;
  font-size: 28px !important;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1;
}

.camera-spacer {
  width: 40px;
}

.camera-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  color: white;
  gap: 16px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.analysis-card {
  background: var(--ios-card-bg);
  border-radius: var(--ios-corner-radius-lg);
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  margin-top: 20px;
}

.analysis-food-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.analysis-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

.nutrition-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.nutrition-item {
  padding: 12px;
  background: var(--ios-gray6);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.nutrition-highlight {
  background: linear-gradient(135deg, #FFF5E6, #FFF0CC);
}

.nutrition-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--ios-text);
}

.nutrition-highlight .nutrition-value {
  color: var(--ios-orange);
  font-size: 28px;
}

.nutrition-unit {
  font-size: 12px;
  color: var(--ios-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.analysis-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.not-food {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  margin-top: 40px;
}

.hidden {
  display: none !important;
}

.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.loading-spinner .spinner {
  border-color: rgba(0,0,0,0.1);
  border-top-color: var(--ios-blue);
}

.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 8px;
}

.progress-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--ios-gray5);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--ios-green);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-bar-label {
  font-size: 12px;
  color: var(--ios-text-tertiary);
  white-space: nowrap;
  min-width: 85px;
  text-align: right;
}

.meal-card-wrap {
  position: relative;
}

#meal-list {
  padding: 0;
}

.meal-card {
  background: var(--ios-card-bg);
  padding: 14px 0;
  display: flex;
  align-items: flex-start;
  gap: 0;
  position: relative;
  background-color: var(--ios-card-bg);
  border-bottom: 1px solid var(--ios-separator);
  transition: opacity 0.1s;
}

.meal-card:active {
  opacity: 0.7;
}

#server-offline .offline-box {
  background: var(--ios-card-bg);
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 280px;
}

#server-offline .offline-box p {
  font-size: 17px;
  font-weight: 600;
  color: var(--ios-text);
}

#server-offline .offline-hint {
  font-size: 14px;
  font-weight: 400;
  color: var(--ios-text-tertiary);
}

.totals-date-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--ios-card-bg);
  border-bottom: 1px solid var(--ios-separator);
}

.totals-date-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--ios-text);
}

.totals-date-nutrition {
  text-align: right;
}

.td-cal {
  font-size: 16px;
  font-weight: 700;
  color: var(--ios-orange);
  display: block;
}

.td-bju {
  font-size: 12px;
  color: var(--ios-text-tertiary);
  margin-top: 2px;
  display: block;
}

.td-norm {
  font-size: 12px;
  color: var(--ios-text-tertiary);
  display: block;
  margin-top: 1px;
}

.content-chart {
  padding-bottom: 40px;
}

.chart-section {
  background: var(--ios-card-bg);
  border-radius: var(--ios-corner-radius-lg);
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ios-text-secondary);
  margin-bottom: 12px;
}

.chart-section canvas {
  width: 100%;
  height: 280px;
  display: block;
}

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--ios-separator);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: 14px;
  color: var(--ios-text-secondary);
}

.stat-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--ios-text-primary);
}

.stat-value.positive {
  color: #FF9500;
}

.stat-value.negative {
  color: #34C759;
}

.stat-value.neutral {
  color: var(--ios-text-primary);
}

.about-section {
  background: var(--ios-card-bg);
  border-radius: var(--ios-corner-radius-lg);
  padding: 32px 24px;
  margin-top: 20px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.about-icon {
  font-size: 56px;
  margin-bottom: 12px;
}

.about-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.about-desc {
  font-size: 15px;
  line-height: 1.5;
  color: var(--ios-text-secondary);
  margin-bottom: 8px;
}

.about-version {
  font-size: 13px;
  color: var(--ios-text-tertiary);
  margin-bottom: 16px;
}

.about-subtitle {
  font-size: 16px;
  font-weight: 600;
  color: var(--ios-text);
  margin-bottom: 16px;
  text-align: left;
}

.about-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  margin-bottom: 14px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ios-text-secondary);
}

.about-step:last-child {
  margin-bottom: 0;
}

.about-step-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}

.about-privacy {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ios-text-tertiary);
}

.about-footer {
  font-size: 13px;
  color: var(--ios-gray2);
}

.about-divider {
  height: 0.5px;
  background: var(--ios-separator);
  margin: 20px 0;
}
