:root {
  --bg: #f6f8fc;
  --card: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --ok: #137333;
  --danger: #c5221f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Google Sans", "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafe 0%, #f6f8fc 45%, #ffffff 100%);
}

#app {
  min-height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(118px + env(safe-area-inset-bottom));
}

.app-header {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.16);
}

.app-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  margin: 0;
  color: #174ea6;
  font-size: 1.3rem;
  font-weight: 700;
}

.app-header p {
  margin: 6px 0 8px;
  color: var(--muted);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #174ea6;
  font-weight: 700;
  font-size: 0.75rem;
}

.gmail-search {
  border-radius: 999px;
  background: #eef3fd;
  color: #3c4043;
  padding: 10px 14px;
  font-size: 0.92rem;
}

main {
  margin-top: 14px;
}

.tab-content {
  display: none;
  gap: 12px;
}

.tab-content.active {
  display: grid;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.12);
}

.card h2,
.card h3 {
  margin: 0 0 10px;
  font-weight: 700;
}

.section-title {
  color: #174ea6;
  letter-spacing: 0.01em;
}

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

.hidden {
  display: none !important;
}

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

.quick-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  box-shadow: 0 1px 2px rgba(26, 115, 232, 0.25);
}

.button.ghost {
  background: var(--accent-soft);
  color: #174ea6;
  box-shadow: none;
}

.button.tiny {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.file-input-label input {
  display: none;
}

.form {
  display: grid;
  gap: 8px;
}

.field-label {
  margin: 2px 0 -2px;
  font-size: 0.82rem;
  color: #3c4043;
  font-weight: 700;
}

.field-required {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e8f0fe;
  color: #174ea6;
  font-size: 0.68rem;
  font-weight: 700;
}

.form.inline {
  grid-template-columns: 1fr 140px auto;
}

.form.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.form.grid-2 .field-label {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #d2e3fc;
  border-color: #a7c0f6;
}

textarea {
  grid-column: 1 / -1;
  resize: vertical;
}

.form-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fce8e6;
  color: #b3261e;
  font-size: 0.84rem;
  grid-column: 1 / -1;
}

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

.item-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 15px;
  display: grid;
  gap: 8px;
}

.item-main h4 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.item-main p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #edf3fd;
  color: #174ea6;
  font-size: 0.75rem;
  font-weight: 700;
}

.chip.ok {
  background: #e6f4ea;
  color: var(--ok);
}

.chip.danger {
  background: #fce8e6;
  color: var(--danger);
}

.item-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.item-actions button {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
}

.edit-btn {
  background: #edf3fd;
  color: #174ea6;
}

.delete-btn {
  background: #fce8e6;
  color: #b3261e;
}

.csv-list {
  display: grid;
  gap: 8px;
}

.csv-bulk-actions {
  margin: 4px 0 10px;
}

.csv-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.csv-row p {
  margin: 0;
  color: #3c4043;
  font-size: 0.9rem;
}

.csv-actions {
  display: flex;
  gap: 8px;
}

.time-quick-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.more-grid {
  display: grid;
  gap: 8px;
}

.more-grid .button {
  justify-self: start;
}

.detail-card {
  border-left: 4px solid #1a73e8;
}

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

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  background: #f8fafd;
}

.timeline-item h4 {
  margin: 0 0 4px;
  font-size: 0.92rem;
}

.timeline-item p {
  margin: 2px 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.tab-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
  z-index: 2000;
}

.tab-nav button {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 10px 6px;
  color: #5f6368;
  font-weight: 700;
  cursor: pointer;
}

.tab-nav button.active {
  background: #e8f0fe;
  color: #174ea6;
}

.fab {
  position: fixed;
  right: 14px;
  bottom: calc(70px + env(safe-area-inset-bottom));
  z-index: 2100;
  border: 0;
  border-radius: 999px;
  background: #1a73e8;
  color: #fff;
  font-weight: 700;
  padding: 12px 16px;
  box-shadow: 0 8px 20px rgba(26, 115, 232, 0.32);
  cursor: pointer;
}

.panel-toggle {
  margin-bottom: 8px;
}

.form-panel {
  display: none;
}

.form-panel.open {
  display: grid;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.42);
  backdrop-filter: blur(2px);
  z-index: 3000;
  display: grid;
  align-items: end;
}

.modal-sheet {
  background: #fff;
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 16px;
  max-height: 82dvh;
  overflow: auto;
}

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

.modal-head h3 {
  margin: 0;
  color: #174ea6;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(122px + env(safe-area-inset-bottom));
  background: #1d1c1d;
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.86rem;
  z-index: 3200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.dev-tools {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 6px;
}

@media (max-width: 700px) {
  .quick-actions,
  .form.inline,
  .form.grid-2,
  .csv-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .tab-nav button {
    width: 100%;
  }

  .csv-actions {
    justify-content: start;
    flex-wrap: wrap;
  }

  .fab {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    padding: 11px 14px;
  }
}
