:root {
  --bg: #18191c;
  --card: #24262b;
  --surface: #2f3239;
  --border: #3c4049;
  --text: #f1f3f4;
  --muted: #9aa0a6;
  --accent: #00e699;
  --gold: #ffd54f;
}

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

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

button,
select,
input,
label {
  touch-action: manipulation;
}

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 28px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  color: var(--accent);
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.search-wrap {
  position: relative;
}

#searchInput {
  width: 240px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.search-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover {
  background: var(--surface);
}

.search-item span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.select-label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

.stats-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.btn-ghost.danger:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.preview-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(100, 181, 246, 0.14);
  border: 1px solid rgba(100, 181, 246, 0.4);
  color: #90caf9;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
}

.btn-small {
  background: #64b5f6;
  color: #111;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
}

.word-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.word-title-wrap {
  min-width: 0;
}

.pos-badge {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--surface);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.word-title {
  margin: 0;
  font-size: 36px;
  color: var(--gold);
  letter-spacing: 0.3px;
  word-break: break-word;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #111;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-blue {
  background: #64b5f6;
}

.btn-green {
  background: #81c784;
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.card-body {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 20px;
  margin: 18px 0;
  align-items: start;
}

.details-panel {
  background: var(--surface);
  border-radius: 10px;
  padding: 18px;
  min-height: 270px;
}

.hidden-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 230px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.hidden-hint:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tr-box {
  background: rgba(0, 230, 153, 0.12);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 14px;
}

.field-group {
  margin-bottom: 12px;
}

.field-group h4 {
  margin: 0 0 3px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.field-group p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.example-text {
  color: #ffe082;
  font-style: italic;
  cursor: pointer;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.image-panel {
  width: 270px;
  height: 270px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-panel img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-placeholder {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
}

.rating-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding-top: 8px;
}

.btn-rate {
  border: none;
  border-radius: 10px;
  padding: 12px 8px;
  min-height: 54px;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.08s ease;
}

.btn-rate:active {
  transform: scale(0.97);
}

.btn-rate small {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.9;
}

.rate-1 { background: #e53935; }
.rate-2 { background: #fb8c00; }
.rate-3 { background: #43a047; }
.rate-4 { background: #1e88e5; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state p {
  color: var(--muted);
  max-width: 520px;
  margin: 10px auto 22px;
  line-height: 1.6;
}

.footer {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}

code,
kbd {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
}

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #111317;
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.hidden {
  display: none !important;
}

@media (max-width: 768px) {
  .app {
    padding: 12px 10px calc(20px + env(safe-area-inset-bottom));
  }

  .brand h1 {
    font-size: 18px;
  }

  .controls {
    width: 100%;
  }

  .search-wrap {
    flex: 1 1 200px;
  }

  #searchInput {
    width: 100%;
    font-size: 16px; /* iOS Safari otomatik zoom engelleme */
  }

  .stats-bar {
    padding: 10px 12px;
    font-size: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 12px;
  }

  .word-header {
    gap: 10px;
    padding-bottom: 12px;
  }

  .word-title {
    font-size: 28px;
  }

  .action-buttons {
    width: 100%;
  }

  .action-buttons .btn {
    flex: 1;
  }

  .toggle-wrap {
    width: 100%;
    font-size: 12px;
  }

  .card-body {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 12px 0;
  }

  .image-panel {
    width: 100%;
    max-width: 220px;
    height: 190px;
    margin: 0 auto;
    order: -1;
  }

  .details-panel {
    min-height: auto;
    padding: 14px;
  }

  .hidden-hint {
    min-height: 76px;
    font-size: 14px;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .rating-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .desktop-hints {
    display: none;
  }
}