*, *::before, *::after { box-sizing: border-box; }
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --c-primary: #e72737;
  --c-blue: #1565c0;
  --c-border: #e2e5e9;
  --c-bg: #f4f5f7;
  --c-card: #fff;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--c-bg); color: #1a1a1a; line-height: 1.55; -webkit-text-size-adjust: 100%; }

.wrap { max-width: 640px; margin: 0 auto; padding: 1rem 1rem calc(1rem + var(--safe-b)); }

header { display: flex; align-items: center; gap: .5rem; margin-bottom: 1.25rem; }
header h1 { font-size: 1.1rem; margin: 0; font-weight: 700; }

.form-section {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: .75rem;
}
.section-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #777; margin-bottom: .6rem;
}
.field label { display: block; font-size: .78rem; font-weight: 600; color: #444; margin-bottom: .2rem; }
.field + .field { margin-top: .6rem; }
.field select, .field input[type="search"] {
  width: 100%; padding: .65rem .7rem; border: 1px solid var(--c-border); border-radius: 8px;
  font-size: 1rem; background: #fff; color: #1a1a1a;
}
.field select:focus, .field input:focus { outline: none; border-color: var(--c-blue); box-shadow: 0 0 0 3px rgba(21,101,192,.12); }
.field select:disabled { opacity: .45; background: #fafafa; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  width: 100%; padding: .8rem 1rem; margin-top: .25rem; font-size: .95rem; font-weight: 700;
  color: #fff; background: var(--c-primary); border: none; border-radius: 10px; cursor: pointer;
  transition: opacity .15s; -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-secondary {
  background: var(--c-card); color: var(--c-blue); border: 1px solid var(--c-border);
  font-weight: 600; font-size: .85rem; padding: .55rem .9rem; width: auto; margin-top: 0;
}
.btn-secondary:hover { background: #eef3fb; border-color: var(--c-blue); }

.err { color: #b00020; font-size: .85rem; margin-top: .5rem; text-align: center; }
.spinner-wrap { display: none; align-items: center; justify-content: center; padding: 1.5rem; }
.spinner-wrap.active { display: flex; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--c-border); border-top-color: var(--c-primary);
  border-radius: 50%; animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#result { display: none; }
#result.visible { display: block; animation: fadeUp .25s ease; }
@keyframes fadeUp { from { opacity: 0; transform: none; } to { opacity: 1; transform: none; } }


.meta { font-size: .78rem; color: #666; margin-bottom: .5rem; }

.school-list {
  list-style: none; margin: 0; padding: 0;
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius);
  max-height: 42vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.school-item {
  padding: .65rem .85rem; border-bottom: 1px solid #f0f0f0; cursor: pointer;
  transition: background .12s;
}
.school-item:last-child { border-bottom: none; }
.school-item:active { background: #f5f5f5; }
.school-item .title { font-weight: 600; font-size: .88rem; color: #1a1a1a; }
.school-item .sub { font-size: .72rem; color: #888; margin-top: .15rem; }

.school-item.selected {
  background: #e8f0ff;
  border-left: 3px solid var(--c-primary);
  padding-left: calc(.85rem - 3px);
}

/* Selected school actions (2 external links) */
.actions-panel {
  margin-top: .75rem;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.actions-panel .action-link {
  flex: 1 1 240px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .75rem .9rem;
  text-decoration: none;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 800;
  transition: transform .08s ease, background .15s, border-color .15s;
}
.actions-panel .action-link:active { transform: scale(.99); }
.actions-panel .action-link:hover { background: #eef3fb; border-color: var(--c-blue); }

@media (max-width: 520px) {
  .actions-panel { flex-direction: column; }
  .actions-panel .action-link { flex: 1 1 auto; width: 100%; }
}

.preview-panel {
  margin-top: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.preview-toolbar {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; justify-content: space-between;
  padding: .55rem .65rem;
  background: #fafafa;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  font-size: .75rem;
  margin-bottom: .75rem;
}
.preview-toolbar a { color: var(--c-blue); font-weight: 600; text-decoration: none; }
.preview-toolbar a:hover { text-decoration: underline; }
.preview-frame-wrap {
  height: 62vh; min-height: 280px; max-height: 640px; background: #fff;
}
.preview-frame-wrap iframe {
  width: 100%; height: 100%; border: 0; display: block;
}

/* App layout */
.app-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 0;
}

.main-list {
  padding-right: .15rem;
}

/* Split preview: site + map (stacked, eşit yükseklik) */
.preview-split {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: 0;
  height: 58vh;
  min-height: 520px;
}

.frame-box {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
  flex: 1;
}

.box-title {
  padding: .45rem .6rem;
  background: #fafafa;
  border-bottom: 1px solid var(--c-border);
  font-size: .78rem;
  font-weight: 700;
  color: #666;
}

.frame-box iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  min-height: 0;
  flex: 1;
}

.source {
  margin-top: 1rem; font-size: .68rem; color: #aaa; text-align: center; line-height: 1.4;
}

@media (min-width: 520px) {
  .wrap { padding: 1.25rem; }
  .app-layout { grid-template-columns: 340px 1fr; gap: 1.1rem; }
  .preview-split { height: 62vh; }
}

@media (max-width: 519px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .preview-split {
    height: 52vh;
    min-height: 420px;
  }
}

/* Radar projesiyle aynı footer kalıbı */
.site-footer {
  margin-top: 1.5rem;
  padding: 1rem 1rem calc(1rem + var(--safe-b));
  text-align: center;
  border-top: 1px solid var(--c-border);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  font-size: .75rem;
  color: #aaa;
}
.footer-link {
  color: #888;
  text-decoration: none;
  font-weight: 600;
  transition: color .15s;
}
.footer-link:hover { color: var(--c-primary); }
