:root {
  --bg: #f6f3ee;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8d2c8;
  --panel: #fffdf8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warm: #c2410c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, textarea { font: inherit; }

.app-shell {
  min-height: 100vh;
}

.frame-stage {
  min-width: 0;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  position: relative;
  display: grid;
  background: #050505;
  overflow: hidden;
}

.photo-frame {
  min-height: 0;
  width: 100%;
  height: 100%;
  background: #050505;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #050505;
}

.empty-frame {
  max-width: 520px;
  padding: 28px;
  text-align: center;
  color: #fffaf0;
}

.empty-frame h1 {
  margin: 0 0 10px;
  font-size: 2.4rem;
  letter-spacing: 0;
}

.empty-frame p {
  margin: 0;
  color: #d6d3ce;
  font-size: 1.1rem;
}

.frame-controls {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 10px;
  width: min(94vw, 560px);
  padding: 10px;
  border-radius: 8px;
  background: rgba(5, 5, 5, 0.58);
  backdrop-filter: blur(10px);
}

.frame-controls button,
.message-form button,
.upload-form button,
.upload-link {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.frame-controls button:hover,
.message-form button:hover,
.upload-form button:hover,
.upload-link:hover { background: var(--accent-dark); }

.frame-controls button {
  min-width: 56px;
  background: #fffdf8;
  color: #171717;
}

.frame-controls button:hover { background: #e9e2d8; }

.side-panel {
  min-width: 0;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px;
  background: var(--panel);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.panel-head h1,
.upload-card h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.tool-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.tool-section h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0;
}

.messages {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.message {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.message strong {
  display: block;
  margin-bottom: 4px;
}

.message p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.message-form,
.upload-form {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.message-form input,
.message-form textarea,
.upload-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

.message-form textarea {
  min-height: 84px;
  resize: vertical;
}

.call-box {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #111827;
}

.call-box iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.upload-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.upload-card {
  width: min(560px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.upload-card p {
  color: var(--muted);
  line-height: 1.45;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--accent-dark);
}

.upload-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.notice {
  padding: 10px 12px;
  border-radius: 8px;
}

.notice.error {
  color: #7f1d1d;
  background: #fee2e2;
}

.notice.success {
  color: #14532d;
  background: #dcfce7;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .frame-stage {
    min-height: 68vh;
    padding: 12px;
  }
  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .panel-head { display: grid; }
  .upload-link,
  .message-form button,
  .upload-form button { width: 100%; }
}

.frame-controls button {
  flex: 1 1 0;
  min-width: 0;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
}

.frame-controls button:hover { background: rgba(255, 255, 255, 0.26); }

.side-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 22px;
}

.panel-head {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .frame-stage {
    min-height: 100svh;
    padding: 0;
  }

  .side-panel {
    grid-template-columns: 1fr;
    padding: 18px 14px 24px;
  }
}

@media (max-width: 520px) {
  .frame-stage {
    min-height: 100svh;
    padding: 0;
  }

  .frame-controls {
    width: calc(100vw - 18px);
    gap: 6px;
    padding: 8px;
  }

  .frame-controls button {
    min-height: 42px;
    padding: 0 8px;
    font-size: 0.95rem;
  }

  .photo-frame img {
    min-width: 100%;
    min-height: 100%;
  }
}
