:root {
  color-scheme: light;
  --bg: #f3f7f5;
  --ink: #25211c;
  --muted: #5f6b66;
  --line: #d7e2dc;
  --panel: #fafdff;
  --panel-strong: #ffffff;
  --accent: #1f7a6d;
  --accent-dark: #145a51;
  --rose: #c85757;
  --shadow: 0 18px 44px rgba(52, 45, 35, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(31, 122, 109, 0.08), transparent 36%),
    linear-gradient(315deg, rgba(200, 87, 87, 0.08), transparent 40%),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(280px, 1.3fr);
  gap: 24px;
  align-items: end;
  padding: 8px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.submit-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(250, 253, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  border-radius: 8px;
}

.submit-form input,
.search-box input {
  width: 100%;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.submit-form input {
  min-height: 48px;
  padding: 0 14px;
}

.submit-form input:focus,
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.14);
}

.submit-form button,
.segmented-button,
.like-button {
  border: 0;
  border-radius: 6px;
}

.submit-form button {
  min-width: 82px;
  min-height: 48px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.submit-form button:hover {
  background: var(--accent-dark);
}

.submit-form button:disabled {
  cursor: progress;
  opacity: 0.68;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 18px;
}

.search-box {
  flex: 1 1 280px;
}

.search-box input {
  min-height: 42px;
  padding: 0 12px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(250, 253, 255, 0.76);
}

.segmented-button {
  min-height: 34px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.segmented-button.is-active {
  background: var(--ink);
  color: #fff;
}

.status {
  min-height: 22px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.gallery {
  column-count: 3;
  column-gap: 18px;
}

.card {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid rgba(215, 226, 220, 0.95);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 10px 28px rgba(52, 45, 35, 0.1);
  break-inside: avoid;
  isolation: isolate;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.card::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0 rgba(31, 122, 109, 0);
  content: "";
  transition: box-shadow 160ms ease;
}

.card:hover {
  border-color: rgba(31, 122, 109, 0.42);
  box-shadow: 0 12px 30px rgba(52, 45, 35, 0.13);
}

.card:hover::after {
  box-shadow: inset 0 0 0 2px rgba(31, 122, 109, 0.16);
}

.card-link {
  position: relative;
  z-index: 1;
  display: block;
  color: inherit;
  text-decoration: none;
}

.preview {
  display: grid;
  min-height: 172px;
  aspect-ratio: 1.55;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(31, 122, 109, 0.2), rgba(200, 87, 87, 0.16)),
    #e6eeea;
  color: var(--accent-dark);
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
  word-break: break-word;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  padding: 14px 14px 54px;
}

.domain-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 20px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

.favicon[src=""] {
  display: none;
}

.domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.28;
  letter-spacing: 0;
}

.card-description {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-description:empty {
  display: none;
}

.like-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 58px;
  min-height: 34px;
  padding: 0 10px;
  background: #eef4f1;
  color: var(--ink);
  font-weight: 700;
}

.like-button:hover,
.like-button.is-liked {
  background: #f8dddd;
  color: var(--rose);
}

.heart {
  font-size: 1rem;
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(250, 253, 255, 0.68);
  color: var(--muted);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .gallery {
    column-count: 2;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 20px;
  }

  .submit-form,
  .controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
  }

  .gallery {
    column-count: 1;
  }
}
