:root {
  color-scheme: light;
  --ink: #1e2630;
  --muted: #647080;
  --line: #d9dee6;
  --paper: #fafafa;
  --panel: #ffffff;
  --rose: #d94f70;
  --teal: #247b7b;
  --sun: #e6a23c;
  --shadow: 0 18px 60px rgba(34, 42, 53, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(217, 79, 112, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(36, 123, 123, 0.16), transparent 38%),
    #f4f7f8;
  overflow-x: hidden;
}

button,
input,
textarea,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.album-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  padding: 18px;
}

.admin-shell {
  width: min(1040px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.login-shell {
  width: min(460px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-panel {
  width: 100%;
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 14px;
}

.login-tab {
  min-height: 40px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  line-height: 1.25;
}

.login-tab.active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.login-form {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.login-message {
  min-height: 24px;
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.admin-header {
  min-height: 112px;
  margin-bottom: 18px;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-grid .panel-block:first-child,
.admin-grid .panel-block:nth-child(2) {
  grid-column: 1 / -1;
}

.admin-link {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--rose);
  text-decoration: none;
  white-space: nowrap;
}

.stage,
.side-panel {
  min-width: 0;
}

.stage {
  display: grid;
  grid-template-rows: minmax(420px, 1fr) 118px;
  gap: 14px;
}

.topbar,
.panel-block {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 96px;
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 56px);
  line-height: 1;
}

h2 {
  font-size: 19px;
}

.upload-button,
.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  touch-action: manipulation;
}

.upload-button {
  padding: 0 16px;
  color: #fff;
  background: var(--rose);
  box-shadow: 0 10px 24px rgba(217, 79, 112, 0.24);
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.admin-upload {
  width: 100%;
}

.upload-progress {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(36, 123, 123, 0.08);
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.upload-progress progress {
  width: 100%;
  height: 12px;
  accent-color: var(--teal);
}

.checkin-limit {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(230, 162, 60, 0.14);
  line-height: 1.6;
}

.storage-status {
  padding: 12px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(36, 123, 123, 0.08);
  line-height: 1.6;
}

.checkin-entry {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}

.checkin-entry {
  min-height: 86px;
}

.checkin-entry:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 123, 123, 0.12);
}

.viewer {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border-radius: 8px;
  background: #111820;
  box-shadow: var(--shadow);
}

.media-frame,
.media-frame img,
.media-frame video {
  width: 100%;
  height: 100%;
}

.media-frame {
  position: absolute;
  inset: 0;
}

.media-frame img,
.media-frame video {
  display: block;
  object-fit: contain;
  background: #111820;
}

.media-frame.entering {
  animation: driftIn 680ms ease both;
}

@keyframes driftIn {
  from {
    opacity: 0;
    transform: translateX(28px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 28px;
  color: #eef4f6;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  font-size: 28px;
}

.empty-state span {
  color: rgba(238, 244, 246, 0.72);
}

.nav-button {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 44px;
  height: 54px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: rgba(20, 27, 34, 0.56);
  transform: translateY(-50%);
  font-size: 34px;
}

.nav-button:hover {
  background: rgba(20, 27, 34, 0.78);
}

.prev {
  left: 16px;
}

.next {
  right: 16px;
}

.filmstrip {
  min-height: 118px;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 12px;
}

.media-count {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 auto;
  min-width: 58px;
  width: 58px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 8px 0 14px rgba(244, 247, 248, 0.84);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.45;
  text-align: center;
}

.media-count.editing {
  color: var(--rose);
  border-color: rgba(217, 79, 112, 0.28);
  background: rgba(217, 79, 112, 0.08);
}

.thumb {
  flex: 0 0 132px;
  height: 92px;
  position: relative;
  overflow: hidden;
  border: 3px solid transparent;
  border-radius: 8px;
  background: #1c2630;
  padding: 0;
  touch-action: manipulation;
}

.thumb.active {
  border-color: var(--rose);
}

.thumb.editable {
  cursor: grab;
  touch-action: none;
}

.thumb.dragging {
  opacity: 0.58;
  transform: scale(0.96);
}

.thumb.drop-target {
  border-color: var(--teal);
}

.thumb-delete {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 2;
  min-width: 44px;
  min-height: 28px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: rgba(217, 79, 112, 0.92);
  font-size: 12px;
  font-weight: 800;
  pointer-events: auto;
}

.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-thumb {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background:
    linear-gradient(135deg, rgba(217, 79, 112, 0.42), rgba(36, 123, 123, 0.48)),
    #1c2630;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
}

.panel-block {
  border-radius: 8px;
  padding: 18px;
}

.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.ghost-button {
  padding: 0 12px;
  color: var(--teal);
  background: rgba(36, 123, 123, 0.08);
  border-color: rgba(36, 123, 123, 0.18);
}

.profile-form,
.reminder-form,
.checkin-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 123, 123, 0.12);
}

.love-text {
  min-height: 150px;
  padding: 22px 18px;
  border-radius: 8px;
  display: grid;
  place-content: center;
  gap: 12px;
  background:
    linear-gradient(135deg, rgba(217, 79, 112, 0.12), rgba(230, 162, 60, 0.1)),
    #fff;
  border: 1px solid rgba(217, 79, 112, 0.14);
  overflow-wrap: anywhere;
}

.love-name {
  color: var(--rose);
  font-size: 30px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.love-sentence {
  color: var(--ink);
  line-height: 1.8;
  text-align: center;
  font-size: 18px;
}

.love-sentence b {
  color: var(--rose);
  font-size: 38px;
  line-height: 1;
}

.love-milestones {
  display: grid;
  gap: 10px;
}

.love-milestone {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.love-milestone.highlight {
  background: rgba(217, 79, 112, 0.08);
}

.love-label,
.love-milestone span {
  color: var(--muted);
  font-size: 13px;
}

.love-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

.love-row > :last-child {
  text-align: left;
}

.love-milestone strong {
  font-size: 15px;
}

.love-milestone b {
  color: var(--rose);
  font-size: 26px;
  line-height: 1;
}

.datetime-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button {
  width: 100%;
  color: #fff;
  background: var(--teal);
}

.todo-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.todo-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.todo-tab.active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

.todo-list,
.checkin-list,
.media-manage-list {
  display: grid;
  gap: 10px;
  max-height: min(45vh, 420px);
  overflow: auto;
  padding-right: 4px;
  margin-top: 14px;
}

.todo-item,
.checkin-item,
.media-manage-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.todo-item.done {
  opacity: 0.58;
}

.todo-title,
.checkin-title {
  margin: 0 0 4px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.todo-time,
.checkin-state,
.checkin-date {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.checkin-summary {
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(230, 162, 60, 0.14);
  line-height: 1.6;
}

.checkin-group {
  display: grid;
  gap: 8px;
}

.checkin-group + .checkin-group {
  padding-top: 4px;
}

.checkin-group-title {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.checkin-more-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.checkin-toggle {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(36, 123, 123, 0.18);
  border-radius: 8px;
  color: var(--teal);
  background: rgba(36, 123, 123, 0.08);
}

.checkin-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.media-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.media-order-button {
  min-width: 52px;
  height: 36px;
  border: 1px solid rgba(36, 123, 123, 0.22);
  border-radius: 8px;
  color: var(--teal);
  background: rgba(36, 123, 123, 0.08);
}

.media-order-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.check-button {
  min-width: 58px;
  height: 36px;
  border: 1px solid rgba(36, 123, 123, 0.22);
  border-radius: 8px;
  color: var(--teal);
  background: rgba(36, 123, 123, 0.08);
}

.checkin-item.checked {
  border-color: rgba(36, 123, 123, 0.38);
  background: rgba(36, 123, 123, 0.08);
}

.delete-button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(217, 79, 112, 0.18);
  border-radius: 8px;
  color: var(--rose);
  background: rgba(217, 79, 112, 0.08);
}

.empty-todos {
  color: var(--muted);
  text-align: center;
  padding: 24px 8px;
}

.empty-todos.compact {
  padding: 12px 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .album-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }
}

@media (max-width: 700px) {
  .album-shell {
    width: 100%;
    min-height: 100dvh;
    gap: 12px;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .admin-shell {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .admin-header {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .admin-link {
    width: 100%;
  }

  .admin-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stage {
    grid-template-rows: minmax(360px, 62dvh) auto;
    gap: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 14px;
    gap: 12px;
  }

  .eyebrow {
    font-size: 12px;
    margin-bottom: 4px;
  }

  h1 {
    font-size: 32px;
    line-height: 1.08;
  }

  h2 {
    font-size: 18px;
  }

  .upload-button {
    width: 100%;
  }

  .viewer {
    min-height: 0;
    height: 100%;
    border-radius: 8px;
  }

  .empty-state {
    padding: 22px;
  }

  .empty-state strong {
    font-size: 23px;
    line-height: 1.2;
  }

  .empty-state span {
    font-size: 14px;
    line-height: 1.6;
  }

  .nav-button {
    width: 42px;
    height: 52px;
    font-size: 30px;
  }

  .prev {
    left: 10px;
  }

  .next {
    right: 10px;
  }

  .filmstrip {
    min-height: 88px;
    gap: 8px;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }

  .thumb {
    flex-basis: 96px;
    height: 72px;
    border-width: 2px;
    scroll-snap-align: start;
  }

  .side-panel {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .panel-block {
    padding: 14px;
  }

  .block-header {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .ghost-button {
    min-width: 76px;
    padding: 0 10px;
  }

  input {
    height: 46px;
    font-size: 16px;
  }

  .love-text {
    padding: 14px;
    min-height: 132px;
  }

  .love-name {
    font-size: 26px;
  }

  .love-sentence {
    font-size: 16px;
  }

  .love-sentence b {
    font-size: 32px;
  }

  .love-milestone {
    gap: 8px;
  }

  .love-row {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }

  .datetime-row {
    grid-template-columns: 1fr;
  }

  .todo-list,
  .checkin-list,
  .media-manage-list {
    max-height: none;
    padding-right: 0;
  }

  .todo-item,
  .checkin-item,
  .media-manage-item {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }

  .checkin-item {
    grid-template-columns: 1fr;
  }

  .checkin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-actions {
    display: grid;
    grid-template-columns: 1fr 40px;
  }

  .check-button,
  .media-order-button {
    width: 100%;
    height: 40px;
  }
}

@media (max-width: 380px) {
  .album-shell {
    padding-left: 8px;
    padding-right: 8px;
  }

  h1 {
    font-size: 28px;
  }

  .stage {
    grid-template-rows: minmax(320px, 58dvh) auto;
  }

  .block-header {
    flex-direction: column;
    align-items: stretch;
  }

  .ghost-button {
    width: 100%;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .album-shell {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 34vw);
    gap: 10px;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .stage {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) 76px;
    gap: 8px;
  }

  .viewer {
    min-height: 0;
    height: 100%;
  }

  .filmstrip {
    min-height: 76px;
    gap: 8px;
    padding-bottom: 4px;
  }

  .media-count {
    min-width: 52px;
    width: 52px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .thumb {
    flex-basis: 86px;
    height: 62px;
    border-width: 2px;
  }

  .side-panel {
    min-height: 0;
    max-height: calc(100dvh - 16px);
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 8px;
    overflow-y: auto;
    padding-right: 2px;
  }

  .panel-block {
    padding: 10px;
  }

  .block-header {
    margin-bottom: 8px;
  }

  h2 {
    font-size: 15px;
  }

  .love-text {
    min-height: 84px;
    padding: 10px;
    gap: 6px;
  }

  .love-name {
    font-size: 20px;
  }

  .love-sentence {
    font-size: 14px;
    line-height: 1.4;
  }

  .love-sentence b {
    font-size: 24px;
  }

  .todo-list,
  .checkin-list {
    max-height: none;
    margin-top: 8px;
  }

  .todo-item,
  .checkin-item {
    padding: 9px;
  }

  .checkin-summary {
    margin-top: 8px;
    padding: 9px;
  }
}
