body {
  font-family: 'Roboto', Arial, sans-serif;
  background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
  margin: 0;
  padding: 0;
  color: #333;
  height: calc(100dvh - 120px);
}

.calculator-container {
  max-width: 100%;
  margin: 0;
  padding: 1rem;
  background: #ffffff;
  height: calc(100dvh - 120px);
  display: flex;
  flex-direction: column;
}

.calculator-container:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.3);
}

.calculator-header {
  text-align: center;
  margin-bottom: 2rem;
  color: #2c3e50;
  font-size: 2rem;
  font-weight: bold;
}

#calculator {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 120px);
}

.calculation-display {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.2rem 0.5rem;
  font-size: 1.2rem;
}

.calc-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0;
}
.calc-row.unit-price {
  font-size: 1.5rem;
}

.calc-label {
  flex: 0 0 4em;
  text-align: right;
  font-weight: bold;
  color: #2c3e50;
}

.calc-value {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calc-value input {
  flex: 1;
  padding: 0.1rem 0.8rem;
  font-size: 1.2rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  max-width: 200px;
  text-align: right;
}

.calc-value input:focus {
  outline: none;
  border-color: #3498db;
}

.unit {
  color: #666;
  font-size: 1rem;
}

#unit-price {
  font-size: 1.5rem;
  color: #2c3e50;
  font-weight: bold;
  padding: 0.1rem 0.8rem;
  background: #f8f9fa;
  border-radius: 8px;
  min-width: 200px;
  display: inline-block;
  text-align: right;
}

#display {
  margin-bottom: 0.5rem;
}

#input-area {
  width: 100%;
  padding: 0.1rem 0.8rem;
  font-size: 1.5rem;
  text-align: right;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: #f8f9fa;
  transition: border-color 0.3s ease;
}

#input-area:focus {
  outline: none;
  border-color: #3498db;
}

.price-quantity-display {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.display-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.display-item label {
  font-weight: bold;
  color: #2c3e50;
  font-size: 0.9rem;
}

.display-item input {
  padding: 0.5rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}

.unit-price-display {
  text-align: center;
  padding: 1rem 0;
}

.unit-price-display h2 {
  margin: 0;
  font-size: 1rem;
  color: #666;
}

.calculation-formula {
  position: relative;
  padding: 1rem 0;
}

.formula-divider {
  width: 100%;
  height: 2px;
  background-color: #3498db;
  position: relative;
}

.formula-divider::before {
  content: "÷";
  position: absolute;
  right: -1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #3498db;
  font-size: 1.2rem;
  font-weight: bold;
}

.bottom-container {
  background: #ffffff;
  padding: 1rem;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  flex-direction: column;
  display: flex;
  flex: 1;
  min-height: 0;
  flex-shrink: 0;
  position: fixed;
  width: 100%;
  left: 0;
  bottom: 80px;
}

.calculator-flex-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

#buttons {
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  gap: 0.5rem;
  flex: 1;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

#buttons button {
  width: 100%;
  min-height: 1rem;
  padding: 0.1rem;
  height: clamp(2rem, 5vh, 2.5rem);
  font-size: clamp(1rem, 5vh, 1.2rem);
  border: none;
  border-radius: 8px;
  background: #e8f4fc;
  color: #2c3e50;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  border: 1px solid #bde0f7;
  font-weight: bold;
}

#buttons button:hover {
  background: #d1e9fa;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border-color: #3498db;
}

#buttons button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  background: #bde0f7;
}

/* 機能ボタン（CとBS）用のスタイル */
#buttons button:first-child,
#buttons button:last-child {
  background: #e8f4fc;
  border-color: #bde0f7;
  color: #2c3e50;
}

#buttons button:first-child:hover,
#buttons button:last-child:hover {
  background: #d1e9fa;
  border-color: #3498db;
}

#buttons button:first-child:active,
#buttons button:last-child:active {
  background: #bde0f7;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 0 0;
}

.action-buttons button {
  padding: 0.1rem;
  height: clamp(2.2rem, 5vh, 2.7rem);
  font-size: clamp(1.2rem, 5vh, 1.5rem);
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2);
}

.action-buttons button:hover {
  background: linear-gradient(135deg, #2980b9, #2472a4);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(52, 152, 219, 0.3);
}

.action-buttons button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2);
  background: linear-gradient(135deg, #2472a4, #2980b9);
}

#history {
  height: auto;
  flex: 0 0 auto;
  display: flex;
  overflow-x: auto;
  gap: 0.25rem;
  padding: 0.5rem;
  margin: 0.5rem 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #3498db #f8f9fa;
  flex-shrink: 0;
}

#history::-webkit-scrollbar {
  height: 6px;
}

#history::-webkit-scrollbar-track {
  background: #f8f9fa;
  border-radius: 3px;
}

#history::-webkit-scrollbar-thumb {
  background-color: #3498db;
  border-radius: 3px;
}

.history-item {
  flex: 0 0 auto;
  padding: 0.5rem;
  padding-bottom: 1.5rem;
  background: white;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 30px;
  border: 1px solid #e0e0e0;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  border-color: #3498db;
}

.history-item:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.history-item::after {
  content: "タップして保存";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(52, 152, 219, 0.9);
  color: white;
  font-size: 0.7rem;
  padding: 0.1rem;
  text-align: center;
  /*transform: translateY(100%);*/
  /*transition: transform 0.3s ease;*/
}

.history-item:hover::after {
  transform: translateY(0);
}

.history-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.history-label {
  flex: 0 0 3em;
  text-align: right;
  font-weight: bold;
  color: #2c3e50;
  font-size: 0.8rem;
}

.history-value {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 1rem;
  color: #2c3e50;
  min-width: 80px;
  justify-content: flex-end;
}

.history-value .unit {
  font-size: 0.6rem;
  color: #666;
}

.history-row.unit-price .history-value {
  font-size: 1.2rem;
  padding-left: 1rem;
}

.save-button {
  padding: 0.5rem;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.save-button:hover {
  background: #2980b9;
}

.save-button:active {
  transform: translateY(1px);
}

h2 {
  color: #2c3e50;
  margin: 1.5rem 0 1rem;
  font-size: 1.5rem;
}

/* モーダル関連のスタイル */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1050;
}

.modal.show {
  display: block;
}

.modal-dialog {
  position: relative;
  width: auto;
  margin: 0.5rem auto;
  max-width: 360px;
  pointer-events: none;
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.3rem;
  outline: 0;
}

.modal-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border-bottom: 1px solid #dee2e6;
  border-top-left-radius: calc(0.3rem - 1px);
  border-top-right-radius: calc(0.3rem - 1px);
}

.modal-body {
  position: relative;
  flex: 1 1 auto;
  padding: 0.5rem;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  padding: 0.4rem;
  border-top: 1px solid #dee2e6;
  border-bottom-right-radius: calc(0.3rem - 1px);
  border-bottom-left-radius: calc(0.3rem - 1px);
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1040;
}

.modal-backdrop.show {
  display: block;
}

/* フォーム要素のスタイル */
.form-control {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-select {
  display: block;
  width: 100%;
  padding: 0.375rem 2.25rem 0.375rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-label {
  margin-bottom: 0.2rem;
  display: inline-block;
  font-weight: 500;
  font-size: 0.85rem;
}

/* ボタンのスタイル */
.btn {
  display: inline-block;
  font-weight: 400;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0.25rem;
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.btn-primary {
  color: #fff;
  background-color: #0d6efd;
  border-color: #0d6efd;
}

.btn-primary:hover {
  color: #fff;
  background-color: #0b5ed7;
  border-color: #0a58ca;
}

.btn-secondary {
  color: #fff;
  background-color: #6c757d;
  border-color: #6c757d;
}

.btn-secondary:hover {
  color: #fff;
  background-color: #5c636a;
  border-color: #565e64;
}

.btn-close {
  box-sizing: content-box;
  width: 1em;
  height: 1em;
  padding: 0.25em;
  color: #000;
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
  border: 0;
  border-radius: 0.25rem;
  opacity: 0.5;
  transition: opacity 0.15s ease-in-out;
}

.btn-close:hover {
  opacity: 0.75;
}

.preview-data {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
}

.preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 0;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.9rem;
}

.preview-item:last-child {
  border-bottom: none;
}

.preview-item .label {
  color: #2c3e50;
  font-weight: bold;
}

.preview-item .value {
  color: #3498db;
  font-size: 1.1rem;
  font-weight: bold;
}

.form-group {
  margin-bottom: 0.5rem;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 0.4rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: border-color 0.3s ease;
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: #3498db;
}
