:root {
  --bg: #f5f5f7;
  --text: #111;
  --card: #ffffff;
  --primary: #007aff;
}

body.dark {
  --bg: #1c1c1e;
  --text: #fff;
  --card: #2c2c2e;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* topbar */
.topbar {
  padding: 16px;
}

.menu-btn {
  font-size: 22px;
  background: none;
  border: none;
  cursor: pointer;
}

/* container */
.container {
  max-width: 500px;
  margin: auto;
  padding: 16px;
  text-align: center;
}

/* card */
.card {
  perspective: 1000px;
}

.card-inner {
  height: 240px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(.4,.2,.2,1);
}

.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--card);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  backface-visibility: hidden;
  box-sizing: border-box;
  padding: 22px;
  overflow: hidden;
}

.card-back {
  transform: rotateY(180deg);
  font-size: 34px;
  flex-direction: column;
  overflow-y: auto;
}

/* buttons */
.buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

button {
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

button:active {
  transform: scale(0.96);
}

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

.secondary-btn {
  background: #E5E5EA;
}

body.dark .secondary-btn {
  background: var(--card);
  color: white;
}

.favorite-btn {
  min-width: 48px;
  font-size: 20px;
  line-height: 1;
}

.favorite-btn.active {
  background: #ffcc00;
  color: #111;
}

.progress-track {
  width: 100%;
  max-width: 360px;
  height: 8px;
  margin: 12px auto 0;
  border-radius: 999px;
  background: rgba(128,128,128,.18);
  overflow: hidden;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}

.progress-details {
  margin: 8px 0 16px;
  font-size: 14px;
  opacity: 0.7;
}

/* sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  box-sizing: border-box;
  background: var(--card);
  padding: 20px;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 1001;
}

.sidebar.open {
  transform: translateX(0);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 1000;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* file upload */
.file-upload input {
  display: none;
}

.hidden-menu-item {
  display: none !important;
}

.file-btn {
  background: var(--card);
  padding: 10px;
  border-radius: 10px;
  margin-top: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

#fileName {
  font-size: 13px;
  margin-top: 6px;
  opacity: 0.7;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  z-index: 1002;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--card);
  padding: 20px;
  border-radius: 16px;
  max-width: 320px;
  width: calc(100% - 40px);
  animation: pop 0.25s ease;
}

/* theme btn */
.theme-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111;
  color: white;
  padding: 12px;
  border-radius: 50%;
  font-size: 18px;
  z-index: 1003;
}

@keyframes pop {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== iOS MENU STYLE ===== */

.menu-section {
  margin-bottom: 18px;
}

.menu-section label {
  font-size: 13px;
  opacity: 0.6;
  display: block;
  margin-bottom: 6px;
}

.menu-section select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: var(--bg);
  font-size: 15px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.08);
}

body.dark .menu-section select {
  background: #1c1c1e;
  color: white;
}

.translation-main {
  font-size: 34px;
  font-weight: 600;
  text-align: center;
  overflow-wrap: anywhere;
}

.grammar-block {
  margin-top: 14px;
  font-size: 15px;
  line-height: 1.45;
  opacity: 0.72;
  text-align: center;
  overflow-wrap: anywhere;
}

.example-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(128,128,128,.25);
  max-width: 100%;
  text-align: center;
  overflow-wrap: anywhere;
}

.example-de {
  margin-top: 10px;
  font-size: 18px;
  line-height: 1.4;
  font-weight: 600;
}

.example-ru {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.4;
  opacity: .75;
}

.front-word {
  font-size: 34px;
  font-weight: 600;
  text-align: center;
}

.front-hint {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 500;
  opacity: 0.62;
  text-align: center;
}

@media (max-width: 520px) {
  .card-inner {
    height: 240px;
  }

  .card-front,
  .card-back {
    padding: 18px;
  }

  .translation-main {
    font-size: 30px;
  }

  .example-block {
    margin-top: 16px;
    padding-top: 12px;
  }

  .example-de {
    font-size: 16px;
  }

  .example-ru {
    font-size: 14px;
  }

  .front-word {
    font-size: 30px;
  }

  .front-hint {
    font-size: 16px;
  }

  .buttons {
    gap: 8px;
  }

  button {
    padding: 11px 13px;
  }

  .progress-track {
    max-width: 300px;
  }

  .progress-details {
    font-size: 13px;
  }
}
