* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #000000;
  --fg: #ffffff;
  --border: 3px solid var(--fg);
}

body {
  font-family: 'Courier New', Courier, monospace;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  padding: 20px;
  line-height: 1.4;
}

.container {
  max-width: 600px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  margin-bottom: 32px;
  font-size: 28px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 4px;
  border: var(--border);
  padding: 16px;
  background: var(--bg);
  color: var(--fg);
}

body.light-mode h1 {
  background: #ffffff !important;
  color: #000000 !important;
  border-color: #000000 !important;
}

.input-section {
  margin-bottom: 32px;
}

#urlInput {
  width: 100%;
  padding: 16px;
  font-size: 18px;
  font-family: inherit;
  border: var(--border);
  background: var(--bg);
  color: var(--fg);
  outline: none;
}

#urlInput:focus {
  background: var(--bg);
}

#urlInput::placeholder {
  color: #888;
}

.preview-card {
  margin-top: 16px;
  border: var(--border);
  background: var(--bg);
  cursor: pointer;
}

.preview-card:hover {
  background: var(--fg);
}

.preview-card .preview-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-bottom: var(--border);
  display: block;
  filter: grayscale(100%) contrast(1.2);
}

.preview-card:hover .preview-image {
  filter: none;
}

.preview-card .preview-content {
  padding: 16px;
}

.preview-card .preview-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.preview-card .preview-description {
  font-size: 14px;
  color: #888;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.preview-card .preview-url {
  font-size: 12px;
  color: #888;
  word-break: break-all;
}

.preview-card .save-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 16px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  font-family: inherit;
  font-size: 16px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
}

.preview-card .save-btn:hover {
  background: var(--bg);
  color: var(--fg);
  outline: 2px solid var(--fg);
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.link-card {
  display: flex;
  border: var(--border);
  background: var(--bg);
  text-decoration: none;
  color: inherit;
}

.link-card:hover {
  background: var(--fg);
}

.link-card:hover .link-title,
.link-card:hover .link-meta {
  color: var(--bg);
}

.link-card .link-image {
  width: 140px;
  height: 100px;
  object-fit: cover;
  border-right: var(--border);
  flex-shrink: 0;
  filter: grayscale(100%);
}

.link-card:hover .link-image {
  filter: none;
}

.link-card .link-content {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.link-card .link-title {
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-card .link-meta {
  font-size: 12px;
  color: #888;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.link-card .delete-btn {
  padding: 8px 16px;
  background: transparent;
  color: var(--fg);
  border: 2px solid var(--fg);
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
}

.link-card:hover .delete-btn {
  color: var(--bg);
  border-color: var(--bg);
}

.link-card .delete-btn:hover {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.link-card .link-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fg);
  color: var(--bg);
  font-size: 32px;
  font-weight: bold;
}

.loading {
  padding: 32px;
  text-align: center;
  text-transform: uppercase;
  font-weight: bold;
  border: var(--border);
  animation: blink 0.5s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.error {
  padding: 16px;
  text-align: center;
  background: var(--fg);
  color: var(--bg);
  border: 3px solid var(--fg);
  text-transform: uppercase;
  font-weight: bold;
}

.empty {
  padding: 32px;
  text-align: center;
  border: var(--border);
  text-transform: uppercase;
  color: #888;
}

@media (max-width: 500px) {
  h1 {
    font-size: 20px;
    letter-spacing: 2px;
  }
  
  .link-card {
    flex-direction: column;
  }
  
  .link-card .link-image {
    width: 100%;
    height: 120px;
    border-right: none;
    border-bottom: var(--border);
  }

  body.light-mode .link-card .link-image {
    border-bottom-color: #000000;
  }
}

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 12px 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--fg);
  color: var(--bg);
  border: 3px solid var(--fg);
  z-index: 100;
}

.theme-toggle:hover {
  background: var(--bg);
  color: var(--fg);
}

body.light-mode {
  --bg: #ffffff;
  --fg: #000000;
}

body.light-mode #urlInput {
  border-color: #000000 !important;
}

body.light-mode .preview-card,
body.light-mode .link-card {
  border-color: #000000 !important;
}

body.light-mode .preview-card {
  background: #ffffff !important;
  color: #000000 !important;
}

body.light-mode .preview-card .preview-title,
body.light-mode .preview-card .preview-description,
body.light-mode .preview-card .preview-url {
  color: #000000 !important;
}

body.light-mode .preview-card:hover {
  background: #000000 !important;
}

body.light-mode .preview-card:hover .preview-title,
body.light-mode .preview-card:hover .preview-description,
body.light-mode .preview-card:hover .preview-url {
  color: #ffffff !important;
}

body.light-mode .preview-card .preview-image {
  border-bottom-color: #000000 !important;
}

body.light-mode .link-card .link-image {
  border-right-color: #000000 !important;
}

body.light-mode .empty {
  border-color: #000000 !important;
  color: #000000 !important;
}
