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

:root {
  --black: #000000;
  --white: #ffffff;
  --gray-file: #a7a7a7;
  --gray-line: #e0e0e0;
  --gray-soft: #f5f5f5;
  --text-size: 32px;
}

body {
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 400;
  background: var(--white);
  color: var(--black);
}

/* Make the `hidden` attribute win over flex/block display rules */
[hidden] {
  display: none !important;
}

/* ---- Page layout ---- */
.page {
  position: relative;
  max-width: 1024px;
  margin: 0 auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 37px;
}

/* ---- Top bar / editor icon button ---- */
.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -16px; /* tighten gap to header */
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gray-line);
  border-radius: 50%;
  background: var(--white);
  color: var(--black);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--gray-soft);
}

/* Signed-in state: filled black */
.icon-btn.signed-in {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  position: relative;
  background: var(--white);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 26px;
  line-height: 1;
  background: transparent;
  border: none;
  color: #777;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--black);
}

.modal input[type="password"] {
  width: 100%;
}

.error {
  font-size: 14px;
  color: #c0392b;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.header-title {
  font-size: var(--text-size);
  text-align: center;
  word-break: break-word;
}

/* ---- Add card ---- */
.add-card {
  border: 1px solid var(--gray-line);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--gray-soft);
}

.add-card-title {
  font-size: 24px;
  font-weight: 500;
}

.entry-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hint {
  font-size: 14px;
  color: #555;
  line-height: 1.4;
}

.auth-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

input[type="password"] {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  background: var(--white);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 16px;
  font-weight: 500;
}

input[type="text"],
textarea {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  background: var(--white);
  resize: vertical;
}

input[type="file"] {
  font-family: inherit;
  font-size: 14px;
}

/* ---- Rich text editor ---- */
.rte {
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
}

.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-line);
  background: var(--gray-soft);
}

.rte-btn {
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--black);
  cursor: pointer;
}

.rte-btn:hover {
  background: var(--white);
  border-color: var(--gray-line);
}

.rte-btn.active {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.rte-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px 4px;
  background: var(--gray-line);
}

.rte-editor {
  min-height: 96px;
  max-height: 320px;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
  outline: none;
}

.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: #9a9a9a;
  pointer-events: none;
}

.rte-editor:focus-within,
.rte:focus-within {
  border-color: #999;
}

.rte-editor h1,
.rte-editor h2,
.rte-editor h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 6px 0;
}

.rte-editor ul,
.rte-editor ol {
  padding-left: 1.4em;
  margin: 4px 0;
}

.rte-editor a {
  color: #0a58ca;
}

.btn-primary {
  align-self: flex-start;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--white);
  background: var(--black);
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  cursor: pointer;
}

.btn-primary:hover {
  opacity: 0.85;
}

/* ---- Entries ---- */
.entries {
  display: flex;
  flex-direction: column;
  gap: 37px;
}

.entry {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.entry-week {
  font-size: var(--text-size);
  word-break: break-word;
}

.entry-description {
  font-size: 16px;
  line-height: 1.5;
  word-break: break-word;
}

/* Rich text content inside a published entry */
.entry-description h1,
.entry-description h2,
.entry-description h3 {
  font-size: 1.25em;
  font-weight: 600;
  margin: 0.3em 0;
}

.entry-description ul,
.entry-description ol {
  padding-left: 1.2em;
  margin: 0.3em 0;
}

.entry-description li {
  margin: 0.15em 0;
}

.entry-description a {
  color: #0a58ca;
  word-break: break-all;
}

.entry-description p {
  margin: 0 0 0.5em;
}

.entry-description p:last-child {
  margin-bottom: 0;
}

/* Files area — the gray block from the mockup */
.entry-files {
  background: var(--gray-file);
  border-radius: 8px;
  min-height: 220px;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.entry-files.empty {
  align-items: center;
  justify-content: center;
}

.entry-files.empty::after {
  content: "No files";
  font-size: 18px;
  color: var(--white);
}

.file-item {
  background: var(--white);
  border-radius: 8px;
  overflow: hidden;
  width: 200px;
  display: flex;
  flex-direction: column;
}

.file-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.file-pdf {
  height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--gray-soft);
  color: var(--black);
  text-decoration: none;
}

.file-pdf .pdf-icon {
  font-size: 40px;
}

.file-name {
  font-size: 13px;
  padding: 8px 10px;
  word-break: break-word;
  border-top: 1px solid var(--gray-line);
}

.file-name a {
  color: var(--black);
}

/* Delete entry button */
.entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.btn-delete {
  font-family: inherit;
  font-size: 14px;
  color: var(--black);
  background: transparent;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
}

.btn-delete:hover {
  background: var(--gray-soft);
}

/* Edit/Delete button group in an entry header */
.entry-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Add/edit form footer */
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Current-files list shown while editing an entry */
.existing-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.existing-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  font-size: 14px;
}

.existing-file.removing {
  opacity: 0.5;
}

.existing-file-name {
  flex: 1;
  word-break: break-word;
}

.existing-file.removing .existing-file-name {
  text-decoration: line-through;
}

.existing-file-toggle {
  font-family: inherit;
  font-size: 13px;
  color: var(--black);
  background: transparent;
  border: 1px solid var(--gray-line);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.existing-file-toggle:hover {
  background: var(--gray-soft);
}

/* Image thumbnails open the lightbox */
.file-item .file-thumb {
  display: block;
  border: none;
  padding: 0;
  margin: 0;
  background: none;
  cursor: zoom-in;
  width: 100%;
}

/* ---- Lightbox ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.9);
}

.lb-figure {
  margin: 0;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lb-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: #111;
}

.lb-caption {
  color: var(--white);
  font-size: 15px;
  text-align: center;
  max-width: 90vw;
  word-break: break-word;
}

.lb-counter {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.lb-close,
.lb-nav {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  border: none;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
}

.lb-close:hover,
.lb-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lb-close {
  top: 14px;
  right: 16px;
  width: 44px;
  height: 44px;
  font-size: 30px;
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  font-size: 34px;
}

.lb-prev {
  left: 18px;
}

.lb-next {
  right: 18px;
}

/* Hide the nav arrows when there's only a single photo */
.lightbox.single .lb-nav {
  display: none;
}

/* Responsive */
@media (max-width: 600px) {
  :root {
    --text-size: 24px;
  }
  .page {
    padding: 20px;
  }
  .file-item {
    width: 100%;
  }
  .lb-nav {
    width: 42px;
    height: 42px;
    font-size: 28px;
  }
  .lb-prev {
    left: 8px;
  }
  .lb-next {
    right: 8px;
  }
}
