:root {
  --bg: #fbfbfa;
  --bg-elevated: #f2f7f5;
  --card: #ffffff;
  --border: #e4e7e5;
  --text: #191c1a;
  --muted: #565c59;
  --faint: #8b918d;
  --accent: #2f9a7c;
  --accent-strong: #237e65;
  --accent-soft: #eafbf5;
  --danger: #a33a3a;
  --danger-soft: #fff0f0;
  --radius: 12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }

.wrap {
  width: min(100% - 48px, 960px);
  margin: 0 auto;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: rgba(251, 251, 250, 0.9);
  backdrop-filter: blur(8px);
}

.nav .wrap {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
}

.brand img { width: 26px; height: 26px; }

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

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 10px;
  cursor: pointer;
}

.nav-toggle span {
  width: 20px;
  height: 2px;
  display: block;
  margin: 4px auto;
  border-radius: 2px;
  background: var(--text);
}

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

.cb-auth-email {
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font: 600 14px/1 var(--font);
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.btn.danger {
  color: var(--danger);
  border-color: #efc4c4;
}
.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

main { flex: 1; padding: 40px 0 56px; }

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
}

.meta {
  color: var(--faint);
  font-size: 13px;
}

.ad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 26px;
}

.ad-card-link { display: block; height: 100%; color: inherit; }
.ad-card-link:hover { color: inherit; }

.ad-shadow {
  height: 100%;
  filter:
    drop-shadow(0 4px 4px rgba(25, 28, 26, 0.24))
    drop-shadow(0 16px 20px rgba(25, 28, 26, 0.2));
  transition: filter 0.15s ease;
}

/* Kıvrım, kağıdın köşesini gerçekten kesip yerine katlanmış üçgeni koyar.
   Gölge dış sarmalda tutulur; böylece clip-path gölgeyi kırpmaz ve gölge,
   kesilmiş siluetin dış hattını izler. */
.ad-shell {
  --fold: 30px;
  position: relative;
  height: 100%;
  min-height: 260px;
  border: 0;
  background: var(--note-bg, #fff1a8);
  padding: 36px 28px 30px;
  clip-path: polygon(
    0 0,
    100% 0,
    100% calc(100% - var(--fold)),
    calc(100% - var(--fold)) 100%,
    0 100%
  );
  transition: transform 0.15s ease;
}

.ad-shell::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: var(--fold);
  height: var(--fold);
  background:
    linear-gradient(
      225deg,
      rgba(25, 28, 26, 0.16),
      rgba(25, 28, 26, 0) 70%
    ),
    var(--note-fold, #e9d77e);
  clip-path: polygon(0 0, 100% 0, 0 100%);
  content: "";
}

.ad-card-link:hover .ad-shell {
  transform: translateY(-4px);
}

.ad-card-link:hover .ad-shadow {
  filter:
    drop-shadow(0 6px 6px rgba(25, 28, 26, 0.26))
    drop-shadow(0 21px 24px rgba(25, 28, 26, 0.22));
}

.postit-yellow { --note-bg: #fff1a8; --note-fold: #e8d474; }
.postit-mint { --note-bg: #cfeee3; --note-fold: #a8d7c7; }
.postit-pink { --note-bg: #ffd8df; --note-fold: #e9b7c1; }
.postit-blue { --note-bg: #d7eaff; --note-fold: #b2d0ef; }
.postit-lilac { --note-bg: #e8dcff; --note-fold: #c9b8e9; }

.ad-title {
  margin: 0 0 14px;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.ad-body {
  margin: 0 0 18px;
  color: #454844;
  white-space: pre-wrap;
}

.ad-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.ad-link-chip {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  color: #244d42;
  font-weight: 600;
  font-size: 14px;
}

#ad-view .ad-shell {
  --fold: 40px;
  max-width: 640px;
  min-height: 420px;
  margin: 0 auto;
  padding: 56px 48px;
}

.edit-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}

.preview-column {
  display: grid;
  gap: 24px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  padding: 22px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

label {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
}

input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: 15px var(--font);
  background: #fff;
  color: var(--text);
}

textarea { min-height: 120px; resize: vertical; }

.color-fieldset {
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.color-fieldset legend {
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 600;
}

.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-option {
  position: relative;
  margin: 0;
  cursor: pointer;
}

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

.color-option span {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 2px solid transparent;
  border-radius: 6px 6px 12px 6px;
  box-shadow: 0 2px 5px rgba(25, 28, 26, 0.12);
  color: #353834;
  font-size: 11px;
  font-weight: 700;
}

.color-option input:checked + span {
  border-color: var(--text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.color-yellow span { background: #fff1a8; }
.color-mint span { background: #cfeee3; }
.color-pink span { background: #ffd8df; }
.color-blue span { background: #d7eaff; }
.color-lilac span { background: #e8dcff; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 14px;
}

.link-row {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.qr-panel {
  text-align: center;
}

#qr-image {
  width: 120px;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.qr-public-url {
  display: block;
  max-width: 100%;
  margin-top: 10px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mine-item {
  position: relative;
  min-width: 0;
}

.mine-item.is-draft .ad-card-link {
  opacity: 0.42;
  filter: grayscale(0.25);
}

.empty { color: var(--muted); }
.empty.error, .message-error {
  color: var(--danger);
}

.message {
  min-height: 20px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

.message-success {
  color: var(--accent-strong);
}

footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
}

footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 820px) {
  .edit-layout { grid-template-columns: 1fr; }
  .link-row { grid-template-columns: 1fr; }
  .wrap { width: min(100% - 32px, 960px); }
  #ad-view .ad-shell { min-height: 340px; padding: 42px 28px; }

  .nav-toggle {
    display: block;
  }

  .nav-cta {
    position: absolute;
    top: calc(100% + 8px);
    right: 16px;
    width: min(280px, calc(100vw - 32px));
    display: none;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    padding: 12px;
    box-shadow: 0 16px 32px rgba(25, 28, 26, 0.16);
  }

  .nav.nav-menu-open .nav-cta {
    display: grid;
  }

  .nav-cta .btn,
  .nav-cta .cb-auth-controls,
  .nav-cta .cb-auth-controls > * {
    width: 100%;
  }

  .nav-cta .cb-auth-controls {
    display: grid;
  }

  .cb-auth-email {
    max-width: none;
    padding: 8px 4px;
    text-align: center;
  }
}
