﻿:root {
  --bg1: #f4f8ff;
  --bg2: #dce9ff;
  --ink: #102341;
  --muted: #5d6f8a;
  --card: #ffffff;
  --accent: #2166ff;
  --accent-ink: #ffffff;
  --ok: #14a44d;
  --danger: #cf2d2d;
}

html {
  min-height: 100%;
  background: linear-gradient(145deg, var(--bg1), var(--bg2));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  font-family: "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, var(--bg1), var(--bg2));
  overflow-x: hidden;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}

.hidden {
  display: none !important;
}

.top-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin-left: auto;
}

.icon-button {
  min-width: 42px;
}

h1 {
  margin: 8px 0 6px;
  font-size: 1.8rem;
}

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  margin-top: 14px;
  box-shadow: 0 10px 24px rgba(16, 35, 65, 0.08);
}

.highlight {
  border: 2px solid #d6e2ff;
}

.label {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.target {
  margin: 8px 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
}

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

input,
button {
  border-radius: 12px;
  border: 1px solid #c7d7f7;
  padding: 10px 12px;
  font-size: 16px;
  min-height: 44px;
  touch-action: manipulation;
}

button:not(.day-box) {
  border: 0;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  white-space: nowrap;
}

#settingsButton,
#logoutButton {
  flex: 0 0 auto;
}

#logoutButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 6.2em;
  white-space: nowrap !important;
  word-break: keep-all !important;
  overflow-wrap: normal !important;
  line-height: 1;
  padding-inline: 14px;
  writing-mode: horizontal-tb;
}

.auth-buttons {
  grid-template-columns: 1fr 1fr;
}

button.delete {
  background: var(--danger);
}

button:disabled {
  opacity: 0.6;
}

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

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

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.month-nav button {
  min-width: 52px;
}

.month-label {
  min-width: 86px;
  text-align: center;
  margin: 0;
  font-weight: 700;
}

.calendar-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.day-box {
  border: 1px solid #d7e2fa;
  border-radius: 10px;
  min-height: 78px;
  padding: 6px 5px;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

.day-empty {
  visibility: hidden;
}

.day-box.active {
  border-color: #2166ff;
  box-shadow: inset 0 0 0 1px #2166ff;
}

.day-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.day-number {
  font-weight: 700;
}

.day-meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.day-complete {
  color: var(--ok);
  font-weight: 700;
}

.records {
  display: grid;
  gap: 10px;
}

.record-item {
  border: 1px solid #d7e2fa;
  border-radius: 12px;
  padding: 10px;
}

.record-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 700;
}

.record-controls {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
}

.record-controls input {
  width: 100%;
}

.accounts-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.account-row {
  border: 1px solid #d7e2fa;
  border-radius: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 768px) {
  .app {
    padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
    padding-left: 12px;
    padding-right: 12px;
  }

  .top-head {
    align-items: flex-start;
    gap: 10px;
  }

  .user-bar {
    width: 100%;
    align-self: stretch;
    justify-content: flex-end;
    max-width: none;
  }

  #currentUser {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
  }

  .calendar-grid {
    gap: 6px;
  }

  .day-box {
    min-height: 84px;
    padding: 7px 6px;
  }

  .month-label {
    min-width: 78px;
  }

  #refreshAccountsButton,
  #logoutButton,
  #settingsButton {
    min-height: 44px;
  }

  #logoutButton {
    min-width: 6.2em;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .record-controls {
    grid-template-columns: 1fr;
  }

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

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

  .auth-buttons {
    grid-template-columns: 1fr;
  }
}
