:root {
  /* iOS centik/ev cubugu icin guvenli alan kisayollari */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --tap: 44px; /* onerilen minimum dokunma hedefi */

  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #172033;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #f87171;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  /* Mobil tarayicilarda yatay tasma ve otomatik font buyutmesi olmasin. */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.runner-open,
body.dragging-card {
  overflow: hidden;
  user-select: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 4px 0 0;
}

/* ---------------- Topbar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px calc(16px + var(--safe-r)) 10px calc(16px + var(--safe-l));
  padding-top: calc(10px + var(--safe-t));
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 1.1rem;
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 6px;
  flex: 1;
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.who-name {
  font-weight: 600;
  color: var(--accent);
}

/* ---------------- Layout ---------------- */

.app {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 20px calc(16px + var(--safe-r)) calc(48px + var(--safe-b)) calc(16px + var(--safe-l));
}

.gate {
  max-width: 420px;
  margin: 12vh auto 0;
}

.gate-title {
  font-size: 1.6rem;
  margin: 0 0 4px;
  color: var(--accent);
  letter-spacing: 1px;
}

.view-narrow {
  max-width: 760px;
  margin: 0 auto;
}

.view-slogan {
  text-align: center;
  font-size: 1.4rem;
  margin: 4px 0 20px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.section-title {
  margin: 0;
  font-size: 1.25rem;
}

.section-sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.section-hint {
  margin: 0;
  align-self: flex-end;
  color: var(--muted);
  font-size: 0.78rem;
}

.section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 12px;
}

/* ---------------- Butonlar ---------------- */

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  /* Mobilde cift dokunma zoom'u ve gri parlama olmasin. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-yes {
  background: var(--green);
  color: #052e16;
  font-weight: 600;
}

.btn-primary {
  background: var(--green);
  color: #052e16;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.18);
}

.btn-primary:disabled {
  box-shadow: none;
}

.btn-no {
  background: var(--border);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-link {
  background: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 4px 2px;
  font-size: 0.85rem;
}

.btn-person {
  background: var(--accent);
  color: #082f49;
  font-weight: 600;
}

.btn-icon svg {
  pointer-events: none;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
}

.btn-icon.btn-danger:hover {
  color: var(--red);
  border-color: var(--red);
}

.btn-danger-solid {
  background: #7f1d1d;
  color: #fecaca;
}

/* ---------------- Formlar ---------------- */

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  margin: 10px 0 0;
}

.form-card {
  text-align: left;
}

.form-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input[type='text'],
input[type='password'],
input[type='number'],
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  color: var(--text);
  font-family: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.kind-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.kind-option {
  flex: 1;
  min-width: 140px;
}

.kind-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kind-option span {
  display: block;
  text-align: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
}

.kind-option input:checked + span {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  align-items: center;
}

.form-actions .spacer {
  flex: 1;
}

/* ---------------- Takvim ---------------- */

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
}

.btn-nav {
  background: var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.1rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}

.weekday {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  background: var(--bg);
}

.day-cell.empty {
  background: transparent;
}

.day-cell.done {
  background: var(--green);
  color: #052e16;
  font-weight: 700;
}

.day-cell.today {
  outline: 2px solid var(--accent);
}

.stats {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 10px 0 0;
}

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

.calendars-row .calendar-card {
  padding: 14px 10px;
  margin-bottom: 0;
}

.calendar-person-title {
  margin: 0 0 10px;
  font-size: 1rem;
}

.calendars-row .calendar-header {
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.calendars-row .btn-nav {
  width: 24px;
  height: 24px;
  font-size: 0.85rem;
  border-radius: 6px;
}

.calendars-row .calendar-grid {
  gap: 4px;
}

.calendars-row .weekday {
  font-size: 0.65rem;
}

.calendars-row .day-cell {
  font-size: 0.7rem;
  border-radius: 6px;
}

.calendars-row .stats {
  font-size: 0.7rem;
  margin-top: 8px;
}

.goal-block {
  text-align: center;
  margin-top: 20px;
}

.goal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 8px;
}

.goal-line {
  font-size: 1rem;
  margin: 4px 0;
}

/* ---------------- Egzersiz sayfasi ---------------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 18px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Presetler */

.preset-bar {
  margin: 0 0 18px;
}

.preset-bar-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.preset-bar-title {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.preset-chip:hover {
  border-color: var(--accent);
}

.preset-apply {
  display: flex;
  align-items: baseline;
  gap: 7px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 7px 6px 7px 14px;
  cursor: pointer;
}

.preset-name {
  font-weight: 600;
}

.preset-meta {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.preset-remove {
  border: none;
  border-radius: 0;
  width: 26px;
  height: auto;
  color: var(--border);
  padding-right: 4px;
}

.preset-remove:hover {
  color: var(--red);
}

.preset-remove .icon {
  width: 12px;
  height: 12px;
}

.preset-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.preset-empty .btn-link {
  color: var(--accent);
}

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exercise-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 12px 8px;
  text-align: left;
  cursor: grab;
  /* Dokunmatikte satirin uzerinden sayfa kaydirilabilsin; surukleme
     .row-grip tutamacindan baslar (bkz. dragdrop.js touchHandle). */
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.exercise-row:hover {
  border-color: var(--muted);
}

.exercise-main {
  flex: 1;
  min-width: 0;
}

.exercise-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.exercise-name {
  font-weight: 600;
}

.exercise-detail {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.exercise-tools {
  display: flex;
  gap: 6px;
}

.badge {
  font-size: 0.66rem;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
}

.badge-rep {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
}

.badge-time {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: 14px;
}

.empty-emoji {
  font-size: 2rem;
  margin: 0 0 8px;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.empty-hint {
  margin: 0 auto;
  max-width: 340px;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ---------------- Antrenman timer'i ---------------- */

.runner {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) calc(16px + var(--safe-r))
           calc(24px + var(--safe-b)) calc(16px + var(--safe-l));
  /* Alcak ekranlarda (ornegin yatay telefon) icerik kirpilmasin. */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.runner[data-phase='motion'] {
  background: radial-gradient(circle at 50% 30%, #14532d 0%, var(--bg) 65%);
}

.runner[data-phase='prep'] {
  background: radial-gradient(circle at 50% 30%, #78350f 0%, var(--bg) 65%);
}

.runner-inner {
  width: 100%;
  max-width: 420px;
  text-align: center;
  position: relative;
}

.runner-close {
  position: fixed;
  top: calc(14px + var(--safe-t));
  right: calc(16px + var(--safe-r));
  width: var(--tap);
  height: var(--tap);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.12);
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.runner-close:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.22);
}

.runner-person {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 18px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.runner-phase {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}

.runner-exercise {
  margin: 6px 0 2px;
  font-size: 1.6rem;
}

.runner-set {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  min-height: 1.2em;
}

.runner-dial {
  --dial: 100%;
  --dial-color: var(--green);
  width: 240px;
  height: 240px;
  margin: 22px auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--dial-color) var(--dial), rgba(148, 163, 184, 0.16) 0);
  transition: background 0.2s linear;
}

.runner[data-phase='prep'] .runner-dial { --dial-color: #fbbf24; }

.runner-dial-inner {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.runner-value {
  font-size: 3.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.runner-unit {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.1em;
}

.runner-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 10px;
}

.runner-progress-track {
  flex: 1;
  height: 5px;
  background: rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  overflow: hidden;
}

#runner-progress-bar {
  height: 100%;
  width: 0;
  background: var(--green);
  transition: width 0.25s ease;
}

.runner-progress-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.runner-next {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin: 0 0 20px;
}

.runner-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}

.runner-actions .btn {
  min-width: 130px;
  padding: 14px 20px;
  font-size: 1.05rem;
}

/* ---------------- Board ---------------- */

.board {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  overflow-x: auto;
  scrollbar-width: thin;
  /* Kolonlar sayfanin dar kolonuna sikismasin, pencere kenarina kadar kaysin. */
  margin-inline: calc(50% - 50vw);
  padding-block: 4px 18px;
  padding-inline: calc(50vw - 50%) 16px;
}

.board-columns {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.board-column {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 272px;
  min-width: 272px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 6px;
  cursor: grab;
  /* Basligin uzerinden board yatay kaydirilabilsin; surukleme .col-grip'ten. */
  touch-action: manipulation;
}

.column-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.92rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-count {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}

.column-tools {
  display: flex;
  gap: 2px;
  transition: opacity 0.15s ease;
}

/* Uzerine gelinebilen cihazlarda gizle; dokunmatikte hover olmadigi icin
   araclar her zaman gorunur kalir. */
@media (hover: hover) and (pointer: fine) {
  .column-tools {
    opacity: 0;
  }

  .board-column:hover .column-tools,
  .column-head:focus-within .column-tools {
    opacity: 1;
  }
}

.column-tools .btn-icon {
  width: 22px;
  height: 22px;
  border-color: transparent;
  font-size: 0.7rem;
}

.column-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 8px;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.column-cards.drop-target {
  background: rgba(56, 189, 248, 0.08);
  outline: 1px dashed rgba(56, 189, 248, 0.5);
  outline-offset: 3px;
}

.column-empty {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 18px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.board-card {
  position: relative;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 30px 10px 12px;
  border-left: 4px solid var(--border);
  cursor: grab;
  /* Kartin uzerinden sayfa/board kaydirilabilsin; surukleme .card-grip'ten. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.board-card:hover {
  border-color: var(--muted);
}

.board-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-title {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  word-break: break-word;
}

.card-desc {
  margin: 5px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.board-card.label-blue { border-left-color: #3b82f6; }
.board-card.label-green { border-left-color: #22c55e; }
.board-card.label-yellow { border-left-color: #eab308; }
.board-card.label-red { border-left-color: #ef4444; }
.board-card.label-purple { border-left-color: #a855f7; }

/* Hizli kart ekleme */

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-input {
  font-size: 1rem;
  padding: 9px 10px;
  border-radius: 10px;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.85rem;
}

.btn-add-card,
.btn-add-column {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 9px;
  border-radius: 10px;
  width: 100%;
  text-align: center;
}

.btn-add-card:hover,
.btn-add-column:hover {
  color: var(--text);
  border-color: var(--muted);
  background: rgba(148, 163, 184, 0.06);
}

.column-adder {
  width: 200px;
  min-width: 200px;
}

/* ---------------- Surukle-birak ---------------- */

body.dragging-active {
  user-select: none;
  cursor: grabbing;
}

.icon {
  width: 15px;
  height: 15px;
  display: block;
}

/* Surukleme tutamaclari. Dokunmatikte surukleme yalnizca buradan baslar,
   bu yuzden tutamaclar touch-action:none, govde ise kaydirilabilir kalir. */
.row-grip,
.card-grip,
.col-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  opacity: 0.45;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.row-grip {
  padding: 0 2px;
  min-width: 26px;
  align-self: stretch;
}

.row-grip .icon {
  width: 18px;
  height: 18px;
}

.card-grip {
  position: absolute;
  top: 2px;
  right: 0;
  width: 30px;
  height: 32px;
}

.card-grip .icon {
  width: 16px;
  height: 16px;
}

.col-grip {
  width: 20px;
  height: 24px;
  margin-left: -2px;
}

.col-grip .icon {
  width: 16px;
  height: 16px;
}

.exercise-row:hover .row-grip,
.board-card:hover .card-grip,
.column-head:hover .col-grip {
  opacity: 0.9;
}

.drag-hidden {
  display: none !important;
}

.drag-placeholder {
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.07);
  flex-shrink: 0;
}

.drag-ghost {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  margin: 0;
  transform: rotate(1.5deg);
  box-shadow: 0 16px 34px rgba(2, 6, 23, 0.55);
  cursor: grabbing;
}

/* ---------------- Modal ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(2, 6, 23, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-t)) calc(16px + var(--safe-r))
           calc(20px + var(--safe-b)) calc(16px + var(--safe-l));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-box {
  width: 100%;
  max-width: 440px;
  text-align: left;
  margin: auto;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.label-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.label-swatch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.label-swatch span {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--border);
  cursor: pointer;
}

.label-swatch.label-blue span { background: #3b82f6; }
.label-swatch.label-green span { background: #22c55e; }
.label-swatch.label-yellow span { background: #eab308; }
.label-swatch.label-red span { background: #ef4444; }
.label-swatch.label-purple span { background: #a855f7; }

.label-swatch input:checked + span {
  border-color: var(--text);
  transform: scale(1.08);
}

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  bottom: calc(20px + var(--safe-b));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 32px);
  pointer-events: none;
}

.toast {
  background: #7f1d1d;
  color: #fee2e2;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: opacity 0.35s ease;
}

.toast-success {
  background: #14532d;
  color: #dcfce7;
}

.toast-out {
  opacity: 0;
}

/* ---------------- Dokunmatik cihazlar ---------------- */

/* Fare olmayan cihazlarda dokunma hedeflerini buyut ve hover'a bagli
   gorunurlukleri kalici hale getir. */
@media (pointer: coarse) {
  .btn-icon {
    width: 36px;
    height: 36px;
  }

  .btn-link {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 4px;
  }

  .btn-nav,
  .calendars-row .btn-nav {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    border-radius: 8px;
  }

  .column-tools .btn-icon {
    width: 32px;
    height: 32px;
  }

  .preset-apply {
    padding: 11px 8px 11px 16px;
    font-size: 0.9rem;
  }

  .preset-remove {
    width: 34px;
  }

  .row-grip,
  .card-grip,
  .col-grip {
    opacity: 0.8;
  }

  .card-grip {
    width: 34px;
    height: 36px;
  }

  .row-grip {
    min-width: 32px;
  }

  .col-grip {
    width: 24px;
    height: 28px;
  }

  .board-card {
    padding-right: 34px;
  }

  .tab {
    padding: 10px 14px;
  }

  /* Dokunmatikte :hover "yapisip" kaldigi icin renk degisimini iptal et. */
  .btn-icon:hover:not(:disabled),
  .btn-icon.btn-danger:hover {
    color: var(--muted);
    border-color: var(--border);
  }

  .exercise-row:hover,
  .board-card:hover,
  .preset-chip:hover {
    border-color: var(--border);
  }
}

/* ---------------- Mobil ---------------- */

@media (max-width: 640px) {
  .app {
    padding: 16px calc(12px + var(--safe-r)) calc(40px + var(--safe-b))
             calc(12px + var(--safe-l));
  }

  /* Topbar */

  .topbar {
    gap: 8px;
    padding: 8px calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l));
    padding-top: calc(8px + var(--safe-t));
  }

  .brand {
    font-size: 1rem;
  }

  .tabs {
    order: 3;
    width: 100%;
    flex: none;
  }

  .tab {
    flex: 1;
    padding: 9px 8px;
    font-size: 0.82rem;
  }

  .who {
    margin-left: auto;
    gap: 8px;
    font-size: 0.8rem;
    min-width: 0;
  }

  .who-name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Giris / kisi secimi */

  .gate {
    margin: clamp(16px, 8vh, 80px) auto 0;
  }

  .gate-title {
    font-size: 1.4rem;
  }

  #person-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  #person-buttons .btn {
    width: 100%;
    padding: 14px 10px;
  }

  /* Genel */

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

  .section-head {
    gap: 8px;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions .btn {
    flex: 1;
    white-space: nowrap;
    font-size: 0.92rem;
    padding: 12px;
  }

  /* Ipucu gizlenmiyor; tam satira aliniyor ki tutamac mobilde de anlasilsin. */
  .section-hint {
    display: block;
    width: 100%;
    align-self: flex-start;
    margin: 2px 0 0;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions .spacer {
    display: none;
  }

  .form-actions .btn {
    flex: 1 1 auto;
    min-width: 96px;
    padding: 12px 10px;
  }

  /* Silme gibi geri donusu olmayan islem ayri satira alinir. */
  .form-actions .btn-danger-solid {
    order: 3;
    flex-basis: 100%;
    margin-top: 4px;
  }

  .kind-option {
    min-width: 120px;
  }

  /* Takvim */

  .view-slogan {
    font-size: 1.15rem;
    margin-bottom: 16px;
  }

  #question-card .actions .btn,
  #done-card .actions .btn {
    flex: 1;
    min-width: 120px;
    padding: 13px 16px;
  }

  .calendars-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Tek kolona dusunce gun hucrelerine yer aciliyor. */
  .calendars-row .calendar-card {
    padding: 16px 14px;
  }

  .calendars-row .calendar-header {
    font-size: 0.95rem;
    margin-bottom: 10px;
  }

  .calendars-row .btn-nav {
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
    border-radius: 8px;
  }

  .calendars-row .calendar-grid {
    gap: 6px;
  }

  .calendars-row .weekday {
    font-size: 0.75rem;
  }

  .calendars-row .day-cell {
    font-size: 0.88rem;
    border-radius: 8px;
  }

  .calendars-row .stats {
    font-size: 0.8rem;
  }

  .goal-title {
    font-size: 1.25rem;
  }

  .goal-line {
    font-size: 0.95rem;
  }

  /* Egzersiz */

  .stat-tile {
    padding: 9px 11px;
  }

  .stat-value {
    font-size: 1.05rem;
  }

  .stat-label {
    font-size: 0.62rem;
  }

  .exercise-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 10px 10px 4px;
  }

  .exercise-tools {
    gap: 4px;
  }

  .empty-state {
    padding: 28px 14px;
  }

  /* Antrenman timer'i */

  .runner-exercise {
    font-size: 1.4rem;
  }

  .runner-dial {
    width: 200px;
    height: 200px;
  }

  .runner-dial-inner {
    width: 166px;
    height: 166px;
  }

  .runner-value {
    font-size: 3rem;
  }

  .runner-actions {
    width: 100%;
  }

  .runner-actions .btn {
    flex: 1;
    min-width: 0;
    padding: 15px 12px;
  }

  /* Board */

  .board {
    /* Masaustundeki 50vw tam genislik hilesi yerine mobilde app dolgusunu
       tam olarak geri aliyoruz; boylece yatay tasma olusmuyor. */
    margin-inline: calc(-12px - var(--safe-l)) calc(-12px - var(--safe-r));
    padding-inline: calc(12px + var(--safe-l)) calc(12px + var(--safe-r));
  }

  .board-column {
    width: min(84vw, 320px);
    min-width: min(84vw, 320px);
  }

  .column-adder {
    width: 170px;
    min-width: 170px;
  }

  .column-tools {
    opacity: 1;
  }

  /* Kart modali mobilde alt sayfa (bottom sheet) gibi acilir. */
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-box {
    max-width: none;
    /* Masaustundeki "margin: auto" ortalamasi alt sayfayi ortaliyor. */
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
    max-height: 88vh;
    max-height: 88dvh;
    padding: 18px calc(16px + var(--safe-r)) calc(18px + var(--safe-b))
             calc(16px + var(--safe-l));
  }
}

/* Cok dar telefonlar */
@media (max-width: 380px) {
  .brand {
    font-size: 0.95rem;
  }

  .tab {
    font-size: 0.78rem;
    padding: 9px 4px;
  }

  .who {
    font-size: 0.75rem;
    gap: 6px;
  }

  .who-name {
    max-width: 70px;
  }

  /* Dort arac butonu satira sigmadigi icin kendi satirina iner. */
  .exercise-tools {
    width: 100%;
    justify-content: flex-end;
    padding-top: 2px;
  }

  .view-slogan {
    font-size: 1.05rem;
  }

  .empty-hint {
    font-size: 0.8rem;
  }
}

/* Yatay tutulan telefon: dikey sirali dizilim sigmadigi icin kadran sola,
   metin ve butonlar saga alinir. */
@media (orientation: landscape) and (max-height: 560px) {
  .runner {
    padding-block: 12px;
  }

  .runner-inner {
    max-width: 620px;
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    /* Kadranin tum sagi kaplayabilmesi icin satirlar acikca tanimlanir;
       gizli adimlarda artan satirlar 0 yuksekliginde kalir. */
    grid-template-rows: repeat(8, auto);
    column-gap: 24px;
    align-items: center;
    text-align: left;
  }

  .runner-dial {
    grid-column: 1;
    grid-row: 1 / -1;
    width: 150px;
    height: 150px;
    margin: 0;
    align-self: center;
  }

  .runner-dial-inner {
    width: 124px;
    height: 124px;
  }

  .runner-value {
    font-size: 2.2rem;
  }

  .runner-person,
  .runner-phase,
  .runner-exercise,
  .runner-set,
  .runner-progress,
  .runner-next,
  .runner-actions,
  #runner-skip {
    grid-column: 2;
  }

  .runner-person {
    margin-bottom: 4px;
  }

  .runner-exercise {
    font-size: 1.25rem;
    margin: 2px 0;
  }

  .runner-progress {
    margin: 10px 0 6px;
  }

  .runner-next {
    margin-bottom: 12px;
  }

  .runner-actions {
    justify-content: flex-start;
    margin-bottom: 8px;
  }

  .runner-actions .btn {
    padding: 12px 18px;
    font-size: 1rem;
  }

  #runner-skip {
    justify-self: start;
  }

  .gate {
    margin-top: 16px;
  }
}

/* Hareket azaltma tercihi */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
