* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Roboto', -apple-system, sans-serif;
  background: #0f0f0f; color: #f1f1f1;
  min-height: 100vh; display: flex; flex-direction: column;
}
header {
  background: #181818; border-bottom: 1px solid #3f3f3f;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
}
header h1 { font-size: 18px; font-weight: 500; flex: 1; }
.back-to-vault {
  color: #aaa;
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.back-to-vault:hover {
  background: #3f3f3f;
  color: #fff;
}

main {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 20px; padding: 24px; flex: 1;
  max-width: 1600px; width: 100%;
  margin: 0 auto; align-items: start;
}

.panel {
  background: #272727; border-radius: 12px;
  padding: 24px; border: 1px solid #3f3f3f;
  display: flex; flex-direction: column;
}
.panel.left { max-height: calc(100vh - 110px); overflow: hidden; }
.panel.left .scroll-area {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; min-height: 0;
}
.panel.left .field.notes-field {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
.panel.left .field.notes-field textarea {
  flex: 1; min-height: 90px;
}

h2 {
  font-size: 16px; font-weight: 500;
  margin-bottom: 16px; color: #aaa;
  text-transform: uppercase; letter-spacing: 1px;
}

.field { margin-bottom: 18px; }
label { display: block; font-size: 13px; color: #aaa; margin-bottom: 6px; }
input[type="text"], select, textarea {
  width: 100%;
  background: #121212; border: 1px solid #3f3f3f;
  color: #f1f1f1; padding: 10px 12px;
  border-radius: 6px; font-size: 14px;
  font-family: inherit; transition: border-color .15s;
}
input[type="text"]:focus, select:focus, textarea:focus {
  outline: none; border-color: #ff0000;
}
textarea { resize: none; min-height: 90px; }

button {
  background: #3f3f3f; color: #f1f1f1; border: none;
  padding: 10px 14px; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-family: inherit;
  transition: background .15s, color .15s;
}
button:hover { background: #555; }
button.primary {
  background: #ff0000; width: 100%; padding: 14px;
  font-weight: 500; margin-top: 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
button.primary:hover { background: #cc0000; }
button.primary:disabled { background: #555; cursor: not-allowed; }

button.subtle {
  background: transparent; color: #888;
  padding: 6px 10px; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
button.subtle:hover { background: #3f3f3f; color: #ff5555; }

.tag-input-wrapper { position: relative; }
.selected-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.selected-tags:not(:empty) { margin-bottom: 8px; }
.chip {
  background: #ff0000; color: #fff;
  padding: 4px 10px; border-radius: 20px; font-size: 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip span.x { cursor: pointer; font-weight: bold; opacity: .8; }
.chip span.x:hover { opacity: 1; }

.tag-suggestions {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #181818; border: 1px solid #3f3f3f;
  border-radius: 6px; margin-top: 4px;
  max-height: 240px; overflow-y: auto;
  z-index: 10; display: none;
}
.tag-suggestions.visible { display: block; }
.tag-suggestion { padding: 8px 12px; cursor: pointer; font-size: 13px; }
.tag-suggestion:hover, .tag-suggestion.create { background: #3f3f3f; }
.tag-suggestion.create { color: #ff5555; }
.tag-suggestion.empty { color: #666; cursor: default; font-style: italic; }
.tag-suggestion.empty:hover { background: transparent; }

.url-row { display: flex; gap: 6px; margin-bottom: 6px; }
.url-row input { flex: 1; }

.media-zone {
  background: #121212; border: 2px dashed #3f3f3f;
  border-radius: 8px; aspect-ratio: 1 / 1;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .15s;
  overflow: hidden; position: relative;
}
.media-zone:hover, .media-zone.drag { border-color: #ff0000; }
.media-zone.has-media { cursor: default; }
.media-zone img, .media-zone video {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain; border-radius: 6px;
}
.media-placeholder { color: #666; text-align: center; padding: 20px; }
.media-placeholder .big { font-size: 48px; margin-bottom: 12px; }

.media-controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; gap: 10px;
}
.media-counter { color: #aaa; font-size: 13px; }
.file-info { color: #888; font-size: 12px; margin-top: 6px; word-break: break-all; }

.date-hint { font-size: 11px; color: #666; margin-top: 4px; }
.error-msg { color: #ff5555; font-size: 12px; margin-top: 4px; }
input.invalid { border-color: #ff5555 !important; }

.status-msg { margin-top: 10px; font-size: 13px; text-align: center; min-height: 18px; }
.status-msg.ok { color: #66ff88; }
.status-msg.err { color: #ff5555; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-wrap {
  margin-top: 10px; height: 6px;
  background: #121212; border-radius: 3px;
  overflow: hidden; display: none;
}
.progress-wrap.visible { display: block; }
.progress-bar {
  height: 100%; background: #ff0000; width: 0%;
  transition: width .15s;
}

/* URL fetch box */
.url-fetch {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #3f3f3f;
}
.url-fetch label {
  font-size: 13px; color: #aaa; margin-bottom: 6px;
}
.url-fetch-row { display: flex; gap: 6px; }
.url-fetch-row input { flex: 1; }
.url-fetch-row button { white-space: nowrap; }
.url-fetch-status {
  margin-top: 8px;
  font-size: 12px;
  min-height: 16px;
}
.url-fetch-status.ok { color: #66ff88; }
.url-fetch-status.err { color: #ff5555; }
.url-fetch-status.pending { color: #aaa; }

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
  header {
    padding: 12px 16px;
  }
  
  header h1 {
    font-size: 16px;
  }
  
  main {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
  
  .panel {
    padding: 16px;
  }
  
  .panel.left {
    max-height: none;
    overflow: visible;
  }
  
  .panel.left .scroll-area {
    overflow-y: visible;
  }
  
  .panel.left .field.notes-field textarea {
    min-height: 120px;
  }
  
  h2 {
    font-size: 14px;
    margin-bottom: 12px;
  }
  
  .field {
    margin-bottom: 14px;
  }
  
  label {
    font-size: 12px;
  }
  
  input[type="text"], select, textarea {
    padding: 12px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  button {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  button.primary {
    padding: 16px;
    font-size: 16px;
  }
  
  .chip {
    padding: 6px 12px;
    font-size: 13px;
  }
  
  .tag-suggestions {
    max-height: 200px;
  }
  
  .tag-suggestion {
    padding: 12px;
    font-size: 14px;
  }
  
  .media-zone {
    aspect-ratio: 4 / 3;
    min-height: 250px;
  }
  
  .media-placeholder {
    padding: 16px;
  }
  
  .media-placeholder .big {
    font-size: 36px;
    margin-bottom: 8px;
  }
  
  .media-placeholder div {
    font-size: 14px !important;
  }
  
  .media-controls {
    margin-top: 10px;
  }
  
  .media-controls button {
    padding: 10px 14px;
    font-size: 13px;
  }
  
  .media-counter {
    font-size: 12px;
  }
  
  .file-info {
    font-size: 11px;
  }
  
  .url-fetch {
    margin-top: 14px;
    padding-top: 12px;
  }
  
  .url-fetch-row {
    flex-direction: column;
    gap: 8px;
  }
  
  .url-fetch-row button {
    width: 100%;
  }
  
  .url-row {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
  }
  
  .url-row button {
    width: 100%;
  }
  
  #addUrlBtn {
    width: 100%;
  }
  
  #clearMediaBtn {
    width: 100%;
  }
}

/* Small phones */
@media (max-width: 480px) {
  header {
    padding: 10px 12px;
  }
  
  header h1 {
    font-size: 15px;
  }
  
  main {
    padding: 12px;
    gap: 12px;
  }
  
  .panel {
    padding: 14px;
    border-radius: 8px;
  }
  
  h2 {
    font-size: 13px;
    margin-bottom: 10px;
  }
  
  .media-zone {
    min-height: 200px;
  }
}
/* Add this to the existing header section */
header {
  /* existing styles */
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-links {
  display: flex;
  gap: 16px;
}

.header-links a {
  color: #aaa;
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.header-links a:hover {
  color: #fff;
}
