* {
  box-sizing: border-box;
}

:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f6f8;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f4f6f8;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 330px 1fr;
}

.sidebar {
  padding: 22px;
  background: #ffffff;
  border-right: 1px solid #e4e8ee;
  overflow-y: auto;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: #2563eb;
  font-size: 22px;
  font-weight: 700;
}

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

.brand p {
  margin: 3px 0 0;
  color: #7a8494;
  font-size: 12px;
}

.panel {
  padding: 16px;
  border: 1px solid #e5e9ef;
  border-radius: 14px;
  background: #f9fafb;
}

.panel-actions {
  display: flex;
  margin-bottom: 14px;
}

.panel label {
  display: block;
  margin-bottom: 7px;
  color: #4b5563;
  font-size: 13px;
  font-weight: 650;
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 11px 12px;
  border: 1px solid #d9dee7;
  border-radius: 10px;
  outline: none;
  background: white;
  color: #172033;
}

textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}

.button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 650;
  transition: .15s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.button.primary {
  width: 100%;
  margin-top: 10px;
  background: #2563eb;
  color: white;
}

.button.secondary {
  background: #eef1f5;
  color: #253047;
}

.button.save {
  min-width: 120px;
  background: #172033;
  color: white;
}

.drop-zone {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed #b8c1cf;
  border-radius: 10px;
  color: #7a8494;
  text-align: center;
  font-size: 12px;
}

.drop-zone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

.stats,
.saved-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stats {
  padding: 18px 2px 10px;
  color: #7a8494;
  font-size: 12px;
}

.saved-header {
  margin-top: 5px;
}

.saved-header h2 {
  margin: 0;
  font-size: 14px;
}

.icon-button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #7a8494;
  font-size: 20px;
}

.icon-button:hover {
  background: #eef1f5;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 9px;
}

.saved-empty {
  padding: 12px;
  border-radius: 9px;
  background: #f7f8fa;
  color: #929aaa;
  font-size: 12px;
}

.saved-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px;
  padding: 9px;
  border: 1px solid #e8ebef;
  border-radius: 9px;
  background: white;
}

.saved-open {
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: #354054;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-remove {
  border: 0;
  background: transparent;
  color: #a0a8b5;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: white;
  border-bottom: 1px solid #e4e8ee;
}

.counter {
  color: #687386;
  font-size: 12px;
  font-weight: 700;
}

.current-url {
  max-width: min(70vw, 900px);
  margin-top: 4px;
  color: #253047;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview {
  position: relative;
  min-height: 0;
  margin: 18px;
  overflow: hidden;
  border: 1px solid #dfe4eb;
  border-radius: 14px;
  background: white;
  box-shadow: 0 4px 18px rgba(23, 32, 51, .05);
}

.preview iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 0;
  background: white;
}

.empty-state,
.fallback-card,
.loading-state {
  min-height: 520px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 35px;
  text-align: center;
}

.empty-icon {
  font-size: 42px;
}

.empty-state h2,
.fallback-card h2 {
  margin: 0;
  font-size: 20px;
}

.empty-state p,
.fallback-card p {
  max-width: 560px;
  margin: 0;
  color: #6b7484;
  line-height: 1.5;
}

.muted {
  color: #929aaa !important;
  font-size: 13px;
}

.fallback-card {
  min-height: 520px;
}

.fallback-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #fff4e5;
  font-size: 27px;
}

.fallback-url {
  max-width: 720px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #f4f6f8;
  color: #5f697a;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.fallback-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.loading-state {
  position: absolute;
  inset: 0;
  min-height: 0;
  background: white;
  z-index: 2;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e7ee;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toolbar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 18px 18px;
}

@media (max-width: 850px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #e4e8ee;
  }

  .main {
    min-height: 75vh;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .current-url {
    max-width: 90vw;
  }

  .preview iframe {
    min-height: 460px;
  }
}
