:root {
  color-scheme: dark;
  --bg: #05080c;
  --shell: #070c12;
  --surface: #0c1219;
  --surface-2: #101923;
  --surface-3: #172533;
  --ink: #f1f8fb;
  --muted: #9fb3bd;
  --dim: #647984;
  --line: rgba(111, 180, 205, 0.13);
  --line-strong: rgba(119, 211, 196, 0.24);
  --blue: #2f8cff;
  --blue-2: #1668c9;
  --green: #22c786;
  --green-2: #159b6b;
  --teal: #22c7bd;
  --teal-2: #15928b;
  --red: #e35f5f;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.6);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #02050a;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Yu Gothic UI", sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 20% -12%, rgba(47, 140, 255, 0.22), transparent 24rem),
    radial-gradient(circle at 90% 0%, rgba(34, 199, 134, 0.16), transparent 20rem),
    linear-gradient(180deg, #08111c 0%, #03070c 100%);
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
}

h1,
h2,
h3,
p { margin-top: 0; }

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 10px 8px 24px;
}

.app-header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: center;
  max-width: 430px;
  margin: 0 auto;
  padding: 10px 8px 12px;
}

.app-header h1 {
  margin: 0;
  text-align: center;
  font-size: 20px;
  line-height: 1.2;
}

.app-header p {
  margin: 3px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
}

.ghost-icon,
.menu-button,
.icon-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: rgba(47, 140, 255, 0.08);
  border-radius: var(--radius);
}

.ghost-icon {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  font-size: 34px;
}

.menu-button {
  min-height: 52px;
  padding: 5px 8px;
}

.menu-button span {
  font-size: 22px;
  line-height: 1;
}

.menu-button small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.phone-frame {
  width: min(100%, 430px);
  min-height: 820px;
  margin: 0 auto;
  padding: 0 12px calc(18px + var(--safe-bottom));
  background:
    linear-gradient(180deg, rgba(47, 140, 255, 0.07), transparent 12rem),
    var(--shell);
  border: 1px solid rgba(119, 211, 196, 0.18);
  border-radius: 28px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(47, 140, 255, 0.06);
  overflow: hidden;
}

.toolbar,
.backup-panel,
.summary-row article,
.photo-card,
.group-block,
.dialog-card {
  background: rgba(10, 17, 24, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.toolbar {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 12px;
}

.search-box,
.filter-grid label,
.field {
  display: grid;
  gap: 5px;
}

.search-box span,
.filter-grid span,
.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #050a10;
  outline: 0;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(34, 199, 134, 0.78);
  box-shadow: 0 0 0 3px rgba(47, 140, 255, 0.16);
}

.filter-grid,
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: #050a10;
}

.segmented button {
  min-height: 36px;
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 900;
}

.segmented button.is-active {
  color: #f1fffb;
  background: linear-gradient(180deg, var(--blue), var(--green-2));
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.summary-row article {
  padding: 10px;
  background: linear-gradient(180deg, rgba(47,140,255,0.1), rgba(34,199,134,0.035));
}

.summary-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.summary-row strong {
  display: block;
  margin-top: 2px;
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.subtle-button,
.secondary-button {
  min-height: 38px;
  padding: 7px 9px;
  color: #e9efed;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #101923;
  font-size: 12px;
  font-weight: 900;
}

.primary-button {
  color: #fff;
  border-color: rgba(34, 199, 134, 0.78);
  background: linear-gradient(180deg, var(--blue), var(--green-2));
}

.section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 12px 0 8px;
}

.section-heading span {
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.result-list {
  display: grid;
  gap: 10px;
}

.photo-card {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
}

.thumb,
.detail-image {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #d9edf2;
  background:
    linear-gradient(135deg, rgba(47, 140, 255, 0.2), rgba(34, 199, 134, 0.16)),
    #0a1118;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.detail-image {
  width: 100%;
  padding: 0;
  cursor: zoom-in;
}

.detail-image:disabled {
  cursor: default;
}

.thumb {
  aspect-ratio: 4 / 3;
  min-height: 92px;
  white-space: pre-line;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.thumb img,
.detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fullscreen-dialog {
  width: 100dvw;
  height: 100dvh;
  max-width: 100dvw;
  max-height: 100dvh;
  border-radius: 0;
}

.fullscreen-dialog::backdrop {
  background: #000;
}

.fullscreen-viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100dvw;
  height: 100dvh;
  background: #000;
}

.fullscreen-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
  background: rgba(4, 8, 13, 0.92);
  border-bottom: 1px solid rgba(119, 211, 196, 0.14);
}

.fullscreen-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.fullscreen-image {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 8px;
}

.fullscreen-image img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

@media (orientation: landscape) {
  .fullscreen-viewer {
    grid-template-rows: minmax(0, 1fr);
  }

  .fullscreen-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 2;
    background: linear-gradient(180deg, rgba(0,0,0,0.78), rgba(0,0,0,0));
    border-bottom: 0;
  }

  .fullscreen-image {
    padding: 0;
  }

  .fullscreen-image img {
    max-width: 100dvw;
    max-height: 100dvh;
  }
}

.photo-card-content {
  min-width: 0;
}

.photo-card h3 {
  margin: 0 0 3px;
  font-size: 15px;
  line-height: 1.32;
}

.meta-line,
.memo-line {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.memo-line {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  color: #dce8e5;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  background: #22282a;
  font-size: 11px;
  font-weight: 900;
}

.badge.variation {
  color: #b7e0ff;
  background: rgba(47, 140, 255, 0.16);
}

.badge.standard {
  color: #8ff0c9;
  background: rgba(34, 199, 134, 0.14);
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.card-actions button {
  flex: 1;
  min-height: 34px;
  color: #eff7f5;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #101923;
  font-size: 12px;
  font-weight: 900;
}

.card-actions .delete-card-button {
  color: #ff7b7b;
}

.group-block {
  padding: 9px;
}

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

.group-header h3 {
  margin: 0;
  font-size: 15px;
}

.group-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.empty-state {
  padding: 26px 14px;
  color: var(--muted);
  text-align: center;
  background: rgba(255,255,255,0.035);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.backup-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding: 10px;
}

.file-button {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 7px 9px;
  color: #e9efed;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #101923;
  font-size: 12px;
  font-weight: 900;
}

.file-button input {
  display: none;
}

.icon-button {
  width: 42px;
  height: 42px;
  font-size: 24px;
  font-weight: 800;
}

.primary-button {
  min-height: 42px;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-weight: 900;
}

#deletePhoto {
  color: #ff8b8b;
}

dialog {
  width: min(100% - 18px, 430px);
  max-height: calc(100dvh - 18px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-card {
  display: grid;
  gap: 11px;
  max-height: calc(100dvh - 18px);
  padding: 14px;
  overflow: auto;
  background: #0c1219;
}

.dialog-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-header .icon-button {
  background: #172533;
  color: #eff7f5;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  position: sticky;
  bottom: -14px;
  padding-top: 6px;
  background: linear-gradient(180deg, rgba(12,18,25,0.72), #0c1219 34%);
}

small {
  color: var(--muted);
}

.detail-card {
  padding: 0;
  gap: 0;
}

.detail-card .dialog-header {
  padding: 14px;
}

.detail-image {
  aspect-ratio: 4 / 3;
  min-height: 250px;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  font-weight: 900;
}

.detail-list {
  display: grid;
  gap: 0;
  margin: 12px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.detail-list div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}

.detail-list div:last-child {
  border-bottom: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.detail-list dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.detail-card .dialog-actions {
  margin: 0 12px 12px;
  bottom: 0;
}

@media (max-width: 380px) {
  .photo-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }

}
