:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --text: #2c2c2c;
  --muted: #5d5d5d;
  --danger: #dd5a0f;
  --ring-track: #e3e3e3;
  --ring-progress: #2c2c2c;
  --ring-success: #40af39;
  --panel-shadow: rgba(44, 44, 44, 0.2);
  --font-base: "Inter", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* hidden属性をCSSのdisplay設定よりも優先させるための必須リセット */
[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

body,
button,
input,
textarea {
  font-family: var(--font-base);
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  background: none;
}

.app {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
}

.header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-group-left {
  min-width: 0;
}

.title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.icon-button,
.popup-close-button,
.delete-button {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.icon-button {
  background: var(--surface);
}

.popup-close-button {
  background: var(--bg);
  flex: 0 0 48px;
}

.delete-button {
  background: var(--danger);
  color: #ffffff;
  flex: 0 0 48px;
}

.icon-button svg,
.popup-close-button svg,
.action-button svg,
.ai-button svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.counter-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.count-value {
  font-size: 48px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
}

.count-sub {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}

.ring-wrap {
  position: relative;
  width: 100px;
  height: 100px;
  flex: 0 0 100px;
}

.ring-svg {
  width: 100px;
  height: 100px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 6;
}

.ring-progress {
  fill: none;
  stroke: var(--ring-progress);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s, stroke 0.2s;
}

.ring-progress.completed {
  stroke: var(--ring-success);
}

.ring-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.target-input {
  width: 70px;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: center;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.target-input::-webkit-outer-spin-button,
.target-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.target-label {
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
}

.editor-group {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.editor {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: var(--surface);
  padding: 16px;
  resize: none;
  outline: none;
  overflow: auto;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
}

.editor::placeholder {
  color: var(--text);
  opacity: 1;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editor-actions .icon-button {
  flex: 0 0 48px;
}

.ai-button {
  width: 100%;
  min-height: 48px;
  flex: 0 0 auto;
  border-radius: 24px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
  cursor: pointer;
  text-align: center;
}

.control-panel {
  flex: 0 0 auto;
  background: var(--surface);
  border-radius: 32px 32px 0 0;
  box-shadow: 0 0 24px var(--panel-shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-button {
  flex: 1 1 0;
  min-width: 0;
  height: 48px;
  border-radius: 24px;
  background: var(--muted);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
  cursor: pointer;
  text-align: center;
}

.action-icon-button {
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--muted);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex: 0 0 48px;
}

.action-icon-button svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.status,
.popup-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 16px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  color: var(--muted);
  text-align: center;
}

.status {
  margin-top: 16px;
}

.status svg,
.popup-status svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.popup-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
}

.popup-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-radius: 32px 32px 0 0;
  box-shadow: 0 0 24px var(--panel-shadow);
  padding: 24px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-height: 80dvh;
  /* アニメーションの初期位置と動きの設定（復元） */
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.popup-layer.is-open .popup-sheet {
  transform: translateY(0);
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.popup-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.popup-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.popup-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.popup-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.popup-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popup-block-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

.popup-block-text {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text);
}

.popup-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.popup-chip {
  min-height: 48px;
  padding: 0 16px;
  border-radius: 24px;
  background: var(--bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text);
}

.popup-link {
  min-height: 48px;
  border-radius: 24px;
  background: var(--bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  text-align: center;
  cursor: pointer;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-card {
  width: 100%;
  padding: 14px 24px;
  border-radius: 24px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.history-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1;
}

.history-card-text {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes fadeUpText {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-text {
  animation: fadeUpText 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.prompt-section {
  display: flex;
  flex-direction: column;
}

.prompt-section-title {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.prompt-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prompt-card {
  width: 100%;
  padding: 14px 24px;
  border-radius: 24px;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

a.prompt-card {
  text-decoration: none;
}