:root {
  color-scheme: light;
  --bg: #fcfaf6;
  --panel: #ffffff;
  --ink: #1f2523;
  --muted: #6b746f;
  --line: #d9ddd4;
  --accent: #187b63;
  --accent-dark: #0f5c4a;
  --sun: #f2b84b;
  --berry: #9b3d66;
  --soft: #eef4ef;
  --danger: #a33838;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
  scrollbar-width: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(252, 250, 246, 0.92)),
    radial-gradient(circle at top left, rgba(242, 184, 75, 0.18), transparent 32rem),
    var(--bg);
  color: var(--ink);
  -webkit-overflow-scrolling: touch;
  user-select: none;
  -webkit-user-select: none;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel,
.entry-panel,
.diary-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(32, 36, 34, 0.08);
}

.login-panel {
  width: min(100%, 390px);
  padding: 28px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1.45rem;
}

.login-panel h1,
.topbar h1,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  margin: 18px 0 24px;
  font-size: clamp(2rem, 8vw, 3rem);
}

.topbar {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  font-size: clamp(1.8rem, 6vw, 3.4rem);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 18px 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 18px;
  align-items: start;
}

.entry-panel,
.diary-panel {
  padding: 18px;
}

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

.section-head h2 {
  font-size: 1.1rem;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea {
  resize: vertical;
}

input,
select,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 123, 99, 0.14);
}

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

.calories-grid {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.photo-drop {
  min-height: 220px;
  border: 1px dashed #aeb8b1;
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fbf6, #fff9ec);
  display: grid;
  place-items: center;
  text-align: center;
  overflow: hidden;
  position: relative;
}

.photo-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-drop img {
  width: 100%;
  height: 260px;
  object-fit: cover;
}

.camera-icon {
  width: 52px;
  height: 42px;
  border: 3px solid var(--accent);
  border-radius: 8px;
  color: transparent;
  position: relative;
}

.camera-icon::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.actions-row,
.meal-main,
.meal-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.actions-row {
  flex-wrap: wrap;
}

.primary,
.secondary,
.ghost,
.icon-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary {
  background: #24302c;
  color: #fff;
}

.ghost {
  background: var(--soft);
  color: var(--ink);
}

.logout-button {
  width: 44px;
  min-height: 44px;
  border-radius: 8px;
  padding: 0;
  background: #f8e8e8;
  color: var(--danger);
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 900;
}

.logout-button:hover {
  background: #f1d2d2;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  background: #f7efef;
  color: var(--danger);
  font-size: 1.4rem;
}

.edit-button {
  width: 38px;
  min-height: 38px;
  border-radius: 8px;
  padding: 0;
  background: #edf3f5;
  color: #36515c;
  font-size: 1.05rem;
  font-weight: 900;
}

.hidden-field {
  display: none;
}

.muted,
.form-message,
.empty {
  color: var(--muted);
}

.form-message {
  margin: 14px 0 0;
}

.analysis-box {
  border: 1px solid #d5e4d9;
  border-radius: 8px;
  padding: 13px;
  background: #f4faf5;
  display: grid;
  gap: 9px;
}

.analysis-box p {
  margin: 0;
  color: var(--muted);
}

.analysis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.analysis-head span {
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.meal-list {
  display: grid;
  gap: 12px;
}

.meal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--panel);
}

.meal-main {
  justify-content: space-between;
  align-items: flex-start;
}

.meal-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.meal-main h3 {
  margin: 4px 0 0;
  font-size: 1rem;
}

.meal-main time {
  color: var(--muted);
  font-size: 0.82rem;
}

.meal-meta {
  flex-wrap: wrap;
  margin: 12px 0;
}

.meal-meta span {
  background: #f3efe6;
  border-radius: 999px;
  color: #5f5140;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 800;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chips span {
  background: #edf3f5;
  color: #36515c;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.82rem;
  font-weight: 700;
}

.meal-card p {
  margin: 12px 0 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: #1f2523;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  width: min(420px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  text-align: center;
  font-weight: 700;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.app-version {
  width: min(1180px, 100%);
  margin: -22px auto 0;
  padding: 0 18px calc(18px + env(safe-area-inset-bottom));
  color: rgba(107, 116, 111, 0.52);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .layout {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-version {
    margin-top: -20px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .entry-panel,
  .diary-panel,
  .login-panel {
    padding: 14px;
  }
}
